/* ==========================================================================
   Qalbs theme — shared by every page (base.html and index.html)
   Maroon + antique gold on ivory, inspired by nikah cards and Islamic
   geometric art. Page templates keep their own <style> blocks; this file
   sets tokens, base components and the mobile layer underneath them.
   ========================================================================== */

:root {
    /* Brand (names kept: templates reference these) */
    --primary-color: #8B1538;
    --secondary-color: #6B0F2A;
    --maroon-900: #3F0918;
    --maroon-800: #5E0D25;

    --gold: #B8913A;
    --gold-deep: #94722A;
    --gold-light: #E9D9B0;
    --gold-soft: #F5ECD9;

    --ivory: #FBF7F1;
    --ivory-2: #F4ECDF;
    --surface: #FFFFFF;
    --ink: #2B1A1F;
    --muted: #6E5C61;
    --line: #EADFCF;

    --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-arabic: 'Amiri', 'Traditional Arabic', serif;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(63, 9, 24, 0.06), 0 2px 8px rgba(63, 9, 24, 0.05);
    --shadow-md: 0 10px 30px rgba(63, 9, 24, 0.10);
    --shadow-lg: 0 24px 60px rgba(63, 9, 24, 0.16);

    /* Eight-point star lattice (gold on light, ivory on maroon) */
    --pattern-gold: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23B8913A' stroke-width='0.8'%3E%3Cpath d='M32 14L50 32L32 50L14 32Z'/%3E%3Crect x='19.3' y='19.3' width='25.4' height='25.4'/%3E%3Cpath d='M0 0L19.3 19.3M64 0L44.7 19.3M0 64L19.3 44.7M64 64L44.7 44.7M32 0V14M32 50V64M0 32H14M50 32H64'/%3E%3C/g%3E%3C/svg%3E");
    --pattern-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23F5ECD9' stroke-width='0.8'%3E%3Cpath d='M32 14L50 32L32 50L14 32Z'/%3E%3Crect x='19.3' y='19.3' width='25.4' height='25.4'/%3E%3Cpath d='M0 0L19.3 19.3M64 0L44.7 19.3M0 64L19.3 44.7M64 64L44.7 44.7M32 0V14M32 50V64M0 32H14M50 32H64'/%3E%3C/g%3E%3C/svg%3E");
    --star-gold: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='%23B8913A'%3E%3Crect x='7' y='7' width='18' height='18'/%3E%3Crect x='7' y='7' width='18' height='18' transform='rotate(45 16 16)'/%3E%3C/g%3E%3C/svg%3E");

    /* Bootstrap overrides */
    --bs-primary: #8B1538;
    --bs-primary-rgb: 139, 21, 56;
    --bs-link-color: #8B1538;
    --bs-link-color-rgb: 139, 21, 56;
    --bs-link-hover-color: #6B0F2A;
    --bs-link-hover-color-rgb: 107, 15, 42;
    --bs-body-font-family: var(--font-body);
    --bs-body-color: #2B1A1F;
    --bs-body-bg: #FBF7F1;
    --bs-border-color: #EADFCF;
    --bs-border-radius: 10px;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--ivory);
    color: var(--ink);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, .display-font {
    font-family: var(--font-display);
    font-variant-numeric: lining-nums;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

h3, h4, h5, h6 {
    font-family: var(--font-body);
    font-weight: 700;
}

img, video { max-width: 100%; }

.arabic {
    font-family: var(--font-arabic);
    direction: rtl;
    unicode-bidi: isolate;
}

::selection { background: var(--gold-light); color: var(--maroon-900); }

:focus-visible {
    outline: 3px solid rgba(184, 145, 58, 0.6);
    outline-offset: 2px;
}

/* ---------- Ornaments ---------- */
.ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto;
    max-width: 220px;
}

.ornament::before,
.ornament::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold));
}

.ornament::after { background: linear-gradient(90deg, var(--gold), transparent); }

.ornament span {
    width: 14px;
    height: 14px;
    background: var(--star-gold) center / contain no-repeat;
    flex-shrink: 0;
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

/* ---------- Navbar ---------- */
.navbar.fixed-top {
    background: rgba(251, 247, 241, 0.92) !important;
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--line);
    box-shadow: none;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color) !important;
    font-family: var(--font-display);
    font-size: 1.85rem !important;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
}

.navbar-brand .brand-arabic {
    font-family: var(--font-arabic);
    font-size: 1.05rem;
    color: var(--gold-deep);
    font-weight: 400;
    margin-top: 4px;
}

.navbar .nav-link {
    color: var(--ink);
    font-weight: 500;
    font-size: 0.95rem;
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus,
.navbar .nav-link.active { color: var(--primary-color); }

.navbar-toggler {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 10px;
}

.navbar-toggler:focus { box-shadow: 0 0 0 3px rgba(184, 145, 58, 0.35); }

.nav-btn-signin,
.nav-btn-signup {
    border-radius: 999px !important;
    padding: 8px 22px !important;
    font-weight: 600 !important;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease !important;
}

.nav-btn-signin {
    border: 1.5px solid var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.nav-btn-signin:hover { background: var(--primary-color) !important; color: #fff !important; }

.nav-btn-signup {
    background: var(--primary-color) !important;
    border: 1.5px solid var(--primary-color) !important;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(139, 21, 56, 0.22);
}

.nav-btn-signup:hover { background: var(--secondary-color) !important; color: #fff !important; }

.nav-link.nav-logout { color: #B42318 !important; font-weight: 600; }

@media (max-width: 991.98px) {
    .navbar-collapse {
        padding: 8px 0 12px;
        max-height: calc(100vh - 110px);
        overflow-y: auto;
    }

    .navbar .nav-link { padding: 10px 4px !important; border-bottom: 1px solid var(--line); }
    .navbar .nav-item:last-child .nav-link { border-bottom: 0; }

    .navbar-collapse .nav-btn-signin,
    .navbar-collapse .nav-btn-signup {
        display: block;
        margin-left: 0 !important;
        text-align: center;
        border-bottom: 1.5px solid var(--primary-color) !important;
    }

    .navbar-collapse .nav-btn-signin { margin-top: 10px; margin-bottom: 10px; }
}

@media (max-width: 400px) {
    .navbar-brand { font-size: 1.55rem !important; }
    .navbar-brand .brand-arabic { display: none; }
}

/* ---------- Buttons & forms ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; }

.btn-primary {
    --bs-btn-bg: #8B1538;
    --bs-btn-border-color: #8B1538;
    --bs-btn-hover-bg: #6B0F2A;
    --bs-btn-hover-border-color: #6B0F2A;
    --bs-btn-active-bg: #5E0D25;
    --bs-btn-active-border-color: #5E0D25;
    --bs-btn-disabled-bg: #8B1538;
    --bs-btn-disabled-border-color: #8B1538;
    --bs-btn-focus-shadow-rgb: 139, 21, 56;
}

.btn-outline-primary {
    --bs-btn-color: #8B1538;
    --bs-btn-border-color: #8B1538;
    --bs-btn-hover-bg: #8B1538;
    --bs-btn-hover-border-color: #8B1538;
    --bs-btn-active-bg: #6B0F2A;
    --bs-btn-active-border-color: #6B0F2A;
}

.btn-gold {
    background: var(--gold);
    border: 1px solid var(--gold);
    color: #fff;
}

.btn-gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: #DCCDB8;
    padding: 0.65rem 0.9rem;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.22rem rgba(139, 21, 56, 0.12);
}

.form-check-input:checked { background-color: var(--primary-color); border-color: var(--primary-color); }

.form-check-input:focus { box-shadow: 0 0 0 0.22rem rgba(139, 21, 56, 0.15); border-color: var(--primary-color); }

label, .form-label { font-weight: 600; font-size: 0.92rem; color: #4A3B3F; margin-bottom: 6px; }

.alert { border-radius: var(--radius-sm); }

.card { border-radius: var(--radius); border-color: var(--line); }

.table > thead { background: var(--ivory-2); }

.nav-tabs .nav-link.active,
.nav-pills .nav-link.active { color: var(--primary-color); }

/* ---------- Auth / form pages (.hero in base.html) ---------- */
.hero {
    min-height: 100vh;
    min-height: 100svh;
    height: auto;
    padding: 120px 16px 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: var(--ivory);
    background-image:
        radial-gradient(ellipse at top, rgba(251, 247, 241, 0.2), var(--ivory) 70%),
        var(--pattern-gold);
    background-size: auto, 64px 64px;
    color: var(--ink);
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(251, 247, 241, 0.55), rgba(251, 247, 241, 0.92) 65%);
    pointer-events: none;
}

.hero > * { position: relative; }

.form-container {
    background: var(--surface);
    padding: 44px 40px 36px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    max-width: 460px;
    width: 100%;
    position: relative;
}

.form-container::before {
    content: '';
    display: block;
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
    background: var(--star-gold) center / contain no-repeat;
}

.form-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 40px;
    right: 40px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.form-container h2 {
    margin-bottom: 24px;
    text-align: center;
    font-size: 2.1rem;
    color: var(--primary-color);
}

.form-container .btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: 999px;
    margin-top: 6px;
}

.form-container .signup-link,
.form-container .login-link { text-align: center; margin-top: 18px; color: var(--muted); }

.form-group { margin-bottom: 18px; }

.create-profile-form { max-width: 675px; }

/* ---------- Page headers on dashboards: add the lattice ---------- */
body .dashboard-header,
body .review-header,
body .subscribe-header {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-radius: var(--radius);
    border-bottom: 3px solid var(--gold);
}

body .dashboard-header::after,
body .review-header::after,
body .subscribe-header::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--pattern-light) 0 0 / 56px 56px;
    opacity: 0.12;
    pointer-events: none;
}

/* ---------- Footer ---------- */
.site-footer {
    position: relative;
    isolation: isolate;
    background: var(--maroon-900);
    color: rgba(245, 236, 217, 0.78);
    padding: 56px 0 28px;
    font-size: 0.92rem;
    border-top: 3px solid var(--gold);
    overflow: hidden;
}

.site-footer::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--pattern-light) 0 0 / 64px 64px;
    opacity: 0.06;
}

.site-footer .footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    line-height: 1;
}

.site-footer .footer-brand .arabic { color: var(--gold-light); font-size: 1.2rem; }

.site-footer .footer-tagline { margin: 12px 0 0; max-width: 360px; }

.site-footer h3 {
    font-family: var(--font-body);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-bottom: 14px;
}

.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 8px; }

.site-footer a { color: rgba(245, 236, 217, 0.85); text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.site-footer .footer-dua {
    text-align: center;
    font-variant-numeric: lining-nums;
    margin: 40px 0 0;
    padding-top: 28px;
    border-top: 1px solid rgba(233, 217, 176, 0.18);
}

.site-footer .footer-dua .arabic { display: block; font-size: 1.35rem; color: var(--gold-light); margin-bottom: 4px; }

.site-footer .footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    margin-top: 20px;
    font-size: 0.82rem;
    color: rgba(245, 236, 217, 0.6);
}

/* ---------- Dialogs ---------- */
.app-dialog-box {
    background: #fff;
    border-radius: var(--radius);
    max-width: 460px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: appDialogSlide 0.25s ease-out;
}

.app-dialog-header {
    padding: 18px 24px;
    background: linear-gradient(135deg, #8B1538 0%, #5E0D25 100%);
    border-bottom: 3px solid var(--gold);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.coffee-box {
    position: relative;
    background: var(--ivory);
    background-image: linear-gradient(rgba(251, 247, 241, 0.94), rgba(251, 247, 241, 0.94)), var(--pattern-gold);
    background-size: auto, 64px 64px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: 44px 36px 28px;
    max-width: 480px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s ease-out;
    text-align: center;
}

@keyframes appDialogSlide {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   Mobile layer: page templates were written desktop-first with large paddings,
   fixed widths and inline styles. These rules tame them on small screens.
   ========================================================================== */
@media (max-width: 767.98px) {
    body .dashboard-container,
    body .review-container,
    body .subscribe-container,
    body .result-container,
    body .legal-container { padding-left: 0 !important; padding-right: 0 !important; }

    body .profile-form-container { padding: 32px 22px; margin: 28px auto; border-radius: var(--radius); }
    body .profile-form-container h2 { font-size: 1.9rem; }

    body .legal-card,
    body .subscribe-card,
    body .result-card,
    body .no-profile-card { padding: 28px 20px; }

    body .dashboard-header,
    body .review-header { padding: 22px 20px; }

    body .dashboard-header h1,
    body .review-header h1 { font-size: 1.6rem; }

    /* Inline grids / flex children with fixed minimums overflow narrow phones */
    [style*="minmax(300px"],
    [style*="minmax(250px"] { grid-template-columns: 1fr !important; }

    [style*="min-width: 250px"],
    [style*="min-width:250px"],
    [style*="min-width: 220px"] { min-width: 0 !important; }

    /* Large circular profile photos */
    img[style*="width: 250px"][style*="height: 250px"] { width: 180px !important; height: 180px !important; }
    img[style*="width: 200px"][style*="height: 200px"] { width: 160px !important; height: 160px !important; }

    /* Chat windows and the contacts menu become bottom sheets */
    body .chat-window {
        left: 8px !important;
        right: 8px !important;
        bottom: 8px !important;
        width: auto !important;
        max-height: 75vh !important;
        border-radius: var(--radius) !important;
    }

    body #chatContactsMenu {
        right: 12px !important;
        width: min(300px, calc(100vw - 24px)) !important;
    }

    /* Tables scroll inside their card instead of the page */
    body .table-container,
    body .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    body .tooltip-text { width: min(250px, 70vw) !important; }
}

@media (max-width: 575.98px) {
    .container,
    .container-fluid { padding-left: 16px; padding-right: 16px; }

    .hero { padding: 104px 16px 40px; align-items: flex-start; }
    .form-container { padding: 32px 22px 26px; border-radius: 20px; }
    .form-container::after { left: 22px; right: 22px; }
    .form-container h2 { font-size: 1.75rem; }

    .coffee-box { padding: 40px 22px 22px; }

    /* Inline-styled modal cards use 40-60px padding on desktop */
    [style*="position: fixed"] > div[style*="padding: 40px"],
    [style*="position:fixed"] > div[style*="padding:40px"],
    .notification-content { padding: 26px 20px !important; }

    [style*="padding: 60px 40px"],
    [style*="padding: 50px 40px"] { padding: 32px 20px !important; }

    .btn[style*="min-width"] { min-width: 0 !important; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
