/* ============================================
   THÁNHCA.NET - Main Layout v61
   Premium Catholic Purple/Gold Design
   ============================================ */

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size:clamp(14px, 13.2px + 0.36vw, 16px); scroll-behavior:smooth; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
body {
    font-family: var(--font-body);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    background: #1a0a2e;
    font-kerning: normal;
    overflow-x: hidden;
}
button, input, textarea, select { font: inherit; }
.app-shell,
.main-wrapper,
.content-row,
.top-header,
.header-brand,
.header-nav-row,
.header-nav,
.header-auth,
.main-content,
.right-sidebar {
    min-width: 0;
}

/* ======= SCENIC BACKGROUND ======= */
.scenic-bg {
    position: fixed; inset: 0; z-index: -1;
    background: url('../img/bg-scenic.png') center top / cover no-repeat fixed;
    filter: brightness(.7) saturate(.9);
}
.scenic-bg::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg,
        rgba(60,20,100,.6) 0%,
        rgba(90,40,140,.4) 25%,
        rgba(200,180,230,.5) 60%,
        rgba(230,220,245,.88) 100%);
}

/* ======= APP SHELL ======= */
.app-shell { display: flex; min-height: 100vh; }

/* ============================================================
   LEFT SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, rgba(28,8,56,.97) 0%, rgba(42,12,80,.95) 100%);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255,255,255,.06);
    display: flex; flex-direction: column;
    z-index: 200;
    box-shadow: 4px 0 18px rgba(20,0,50,.24);
}

.sidebar-brand {
    padding: 16px 0 14px;
    display: flex; align-items: center; justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand-icon {
    width: 46px; height: 46px;
    background: linear-gradient(135deg, rgba(200,150,60,.3), rgba(107,70,150,.3));
    border: 1.5px solid rgba(200,150,60,.5);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--gold);
    box-shadow: 0 0 12px rgba(200,150,60,.12), 0 2px 8px rgba(0,0,0,.2);
}

.sidebar-nav {
    flex: 1; padding: 10px 8px;
    display: flex; flex-direction: column; gap: 2px;
    overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-divider {
    height: 1px; background: rgba(255,255,255,.06);
    margin: 6px 10px;
}

.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-radius: 8px;
    cursor: pointer; transition: all .2s ease;
    color: rgba(255,255,255,.62); font-size: .82rem;
    font-weight: 500; text-decoration: none;
    user-select: none;
}
.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.9);
    transform: translateX(2px);
}
.nav-item.active {
    background: linear-gradient(135deg, rgba(107,70,150,.5), rgba(80,40,120,.4));
    color: #fff; font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(200,150,60,.18), 0 2px 6px rgba(107,70,150,.14);
}
.nav-item.active .nav-icon { color: var(--gold); }
.nav-item.highlight {
    color: var(--gold);
    background: rgba(200,150,60,.1);
    border: 1px solid rgba(200,150,60,.15);
}
.nav-item.highlight:hover { background: rgba(200,150,60,.18); }

.nav-icon { font-size: .92rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; font-size: .88rem; }

.sidebar-bottom {
    padding: 8px 8px 14px;
    border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-social {
    display: flex; gap: 6px; justify-content: center; padding-top: 8px;
}
.sidebar-social a {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700;
    color: rgba(255,255,255,.6); text-decoration: none;
    transition: all .2s ease;
}
.sidebar-social a:hover {
    background: rgba(200,150,60,.25); color: var(--gold);
    border-color: rgba(200,150,60,.4);
}

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    flex: 1; margin-left: var(--sidebar-w);
    display: flex; flex-direction: column; min-height: 100vh;
}

/* ============================================================
   TOP HEADER  (tall, Jesus image on right)
   ============================================================ */
.top-header {
    position: relative;
    background: linear-gradient(135deg, rgba(28,8,56,.96) 0%, rgba(50,18,90,.94) 40%, rgba(35,12,65,.9) 100%);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(200,150,60,.2);
    min-height: var(--header-h);
    overflow: hidden;
    box-shadow: 0 4px 18px rgba(20,0,60,.22);
    display: flex; flex-direction: column;
}

/* Gold line accent at top */
.top-header::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), rgba(200,150,60,.6), transparent);
}

/* Jesus image — right side of header, tall */
.header-jesus-wrap {
    position: absolute; right: 290px; top: 0; bottom: 0;
    width: 160px; pointer-events: none; z-index: 1;
    overflow: hidden;
}
.header-jesus-img {
    position: absolute; bottom: 0; right: 0;
    height: 130%; object-fit: contain; object-position: bottom center;
    filter: drop-shadow(0 0 24px rgba(200,150,60,.35));
    opacity: .95;
}
/* Decorative cross radiant behind Jesus */
.header-jesus-wrap::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at center bottom, rgba(200,150,60,.12) 0%, transparent 70%);
}

/* Brand + nav area */
.header-brand {
    padding: 16px 22px 8px;
    flex-shrink: 0; z-index: 2; position: relative;
}
.brand-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl); font-weight: 800;
    color: #fff; letter-spacing: 1.5px;
    text-shadow: 0 2px 16px rgba(200,150,60,.3);
    line-height: 1.05;
    display: block;
    max-width: 100%;
    text-wrap: balance;
}
.brand-title span { color: var(--gold); }
.brand-sub {
    font-size: .68rem; color: rgba(255,255,255,.58);
    letter-spacing: .7px; margin-top: 3px; text-transform: uppercase;
    display: block;
}

/* Navigation bar row */
.header-nav-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px; flex: 1;
    position: relative; z-index: 2;
    gap: 16px;
}
.header-nav {
    display: flex; gap: 0; align-items: stretch; height: 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }
.header-nav-link {
    padding: 0 16px; height: 100%; min-height: 38px;
    display: flex; align-items: center;
    font-size: .9rem; font-weight: 500;
    color: rgba(255,255,255,.72); text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all .2s ease;
    white-space: nowrap; position: relative;
}
.header-nav-link:hover, .header-nav-link.active {
    color: #fff; background: rgba(255,255,255,.05);
    border-bottom-color: var(--gold);
}

/* Dropdown */
.header-nav-link.has-dropdown::after { content: ' ▾'; font-size: .65rem; opacity: .7; }
.dropdown-menu {
    position: absolute; top: 100%; left: 0;
    min-width: 160px;
    background: rgba(28,8,56,.97);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(200,150,60,.2);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    display: none; flex-direction: column;
    z-index: 999; overflow: hidden;
}
.header-nav-link:hover .dropdown-menu { display: flex; }
.dropdown-item {
    padding: 10px 16px; color: rgba(255,255,255,.75);
    font-size: .82rem; font-weight: 500; text-decoration: none;
    transition: all .15s ease;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.dropdown-item:hover { background: rgba(200,150,60,.15); color: var(--gold); }

/* Auth buttons */
.header-auth {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}
#auth-toolbar,
#user-logged-in {
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.header-icon-btn {
    width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.8); cursor: pointer; font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s; flex-shrink: 0;
}
.header-icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.header-btn-outline {
    padding: 7px 14px; border-radius: 20px;
    border: 1px solid rgba(255,255,255,.25);
    background: transparent; color: rgba(255,255,255,.85);
    cursor: pointer; font-size: .86rem; font-weight: 500;
    font-family: var(--font-primary); transition: all .2s;
}
.header-btn-outline:hover { background: rgba(255,255,255,.1); color: #fff; }
.header-btn-filled {
    padding: 7px 16px; border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, var(--gold), #b87828);
    color: #1a0a2e; cursor: pointer; font-size: .86rem; font-weight: 700;
    font-family: var(--font-primary); transition: all .2s;
    box-shadow: 0 2px 8px rgba(200,150,60,.3);
}
.header-btn-filled:hover { box-shadow: 0 4px 16px rgba(200,150,60,.5); transform: translateY(-1px); }
.user-chip { font-size: .76rem; color: rgba(255,255,255,.88); }

/* ============================================================
   CONTENT ROW
   ============================================================ */
.content-row {
    flex: 1; display: flex; align-items: stretch; min-width: 0;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1 1 auto; min-width: 0;
    background: rgba(255,255,255,.98);
    backdrop-filter: none;
    min-height: calc(100vh - var(--header-h) - var(--footer-h));
    border-right: 1px solid rgba(107,70,150,.08);
}
.page { display: none; padding: 20px 22px; animation: fadeIn .25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }
.page-header { margin-bottom: 18px; }
.page-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; color: var(--purple-dark); }

/* ============================================================
   RIGHT SIDEBAR
   ============================================================ */
.right-sidebar {
    width: var(--rsidebar-w); flex-shrink: 0;
    padding: 14px 10px; display: flex; flex-direction: column; gap: 11px;
    background: rgba(248,244,255,.96);
    backdrop-filter: none;
    border-left: 1px solid rgba(107,70,150,.08);
    min-height: calc(100vh - var(--header-h) - var(--footer-h));
    min-width: 0;
}

/* Top songs box */
.rsidebar-box {
    background: #fff;
    border: 1px solid rgba(107,70,150,.1);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(61,32,102,.05);
}
.rsidebar-box-title {
    padding: 10px 12px;
    font-size: .8rem; font-weight: 700;
    color: var(--purple-dark);
    background: linear-gradient(135deg, rgba(107,70,150,.07), rgba(200,150,60,.05));
    border-bottom: 1px solid rgba(107,70,150,.08);
    letter-spacing: .2px;
}
.top-songs-list { padding: 4px 0; }
.top-song-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; cursor: pointer;
    transition: background .15s ease;
    border-bottom: 1px solid rgba(107,70,150,.04);
}
.top-song-item:last-child { border-bottom: none; }
.top-song-item:hover { background: rgba(107,70,150,.05); }
.top-song-thumb {
    width: 38px; height: 38px; border-radius: 7px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--purple-dark), var(--purple));
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: rgba(255,255,255,.8);
    box-shadow: 0 1px 6px rgba(61,32,102,.2);
}
.top-song-info { flex: 1; min-width: 0; }
.top-song-title {
    font-size: .88rem; font-weight: 600;
    color: var(--text-primary); line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 1px;
}
.top-song-author { font-size: .76rem; color: var(--text-muted); }
.top-song-views { font-size: .78rem; color: var(--purple); font-weight: 600; margin-top: 1px; }

.rsidebar-see-more {
    display: block; text-align: center; padding: 7px;
    font-size: .68rem; color: var(--purple); font-weight: 500;
    text-decoration: none; border-top: 1px solid rgba(107,70,150,.08);
    transition: all .15s ease; cursor: pointer;
}
.rsidebar-see-more:hover { background: rgba(107,70,150,.05); color: var(--purple-dark); }

/* Link cards */
.rsidebar-link-card {
    background: #fff;
    border: 1px solid rgba(107,70,150,.1);
    border-left: 4px solid var(--card-accent, var(--purple));
    border-radius: 10px; padding: 11px 12px;
    display: flex; align-items: center; gap: 9px;
    cursor: pointer; transition: all .2s ease;
    box-shadow: 0 2px 8px rgba(61,32,102,.05);
}
.rsidebar-link-card:hover {
    box-shadow: 0 4px 12px rgba(61,32,102,.08);
    transform: translateX(3px);
    background: #faf8ff;
}
.rsidebar-link-icon { font-size: 1rem; flex-shrink: 0; }
.rsidebar-link-label { flex: 1; font-size: .86rem; font-weight: 600; color: var(--text-primary); }
.rsidebar-link-arrow { font-size: .85rem; color: var(--text-muted); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: linear-gradient(135deg, rgba(28,8,56,.92), rgba(42,12,80,.9));
    backdrop-filter: none;
    color: rgba(255,255,255,.55); padding: 0 20px;
    height: var(--footer-h);
    display: flex; align-items: center; justify-content: space-between;
    font-size: .72rem;
    border-top: 1px solid rgba(200,150,60,.15);
}
.footer-left { display: flex; gap: 18px; align-items: center; }
.footer-right { display: flex; align-items: center; gap: 12px; }
.footer-social { display: flex; gap: 7px; }
.footer-social a {
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; color: rgba(255,255,255,.6);
    font-size: .6rem; font-weight: 700; transition: all .2s;
}
.footer-social a:hover { background: rgba(200,150,60,.3); color: var(--gold); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay { position:fixed; inset:0; background:rgba(20,0,50,.56); backdrop-filter:blur(4px); z-index:1000; display:none; align-items:center; justify-content:center; padding:clamp(8px, 2vw, 20px); }
.modal-overlay.active { display:flex; }
.modal { background:#fff; border:1px solid rgba(107,70,150,.1); border-radius:16px; width:100%; max-width:620px; max-height:85vh; overflow-y:auto; box-shadow:0 12px 34px rgba(30,0,80,.18); }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid rgba(107,70,150,.08); position:sticky; top:0; background:#fff; z-index:1; }
.modal-title { font-family:var(--font-display); font-size:.95rem; font-weight:700; color:var(--purple-dark); }
.modal-close { width:30px; height:30px; border-radius:7px; border:none; background:rgba(107,70,150,.07); color:var(--text-muted); cursor:pointer; font-size:.95rem; display:flex; align-items:center; justify-content:center; transition:all .15s; }
.modal-close:hover { background:rgba(231,76,60,.1); color:#e74c3c; }
.modal-body { padding:20px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom:14px; }
.form-label { display:block; font-size:.72rem; font-weight:600; color:var(--text-secondary); margin-bottom:5px; }
.form-input, .form-select, .form-textarea { width:100%; padding:10px 14px; border-radius:8px; border:1.5px solid rgba(107,70,150,.15); background:#fff; color:var(--text-primary); font-family:var(--font-primary); font-size:.8rem; transition:all .2s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline:none; border-color:var(--purple); box-shadow:0 0 0 3px rgba(107,70,150,.1); }
.form-textarea { resize:vertical; min-height:80px; }
.form-select { cursor:pointer; }
.form-input::placeholder { color: rgba(107,70,150,.35); }

/* ============================================================
   BUTTONS
   ============================================================ */
.action-btn { padding:8px 16px; border-radius:8px; border:1.5px solid rgba(107,70,150,.15); background:#fff; color:var(--text-secondary); cursor:pointer; font-family:var(--font-primary); font-size:.76rem; font-weight:500; box-shadow:0 1px 4px rgba(61,32,102,.06); transition:all .2s; display:inline-flex; align-items:center; gap:5px; }
.action-btn:hover { border-color:var(--purple); color:var(--purple); box-shadow:0 3px 10px rgba(61,32,102,.12); transform:translateY(-1px); }
.action-btn.primary { background:linear-gradient(135deg,#3d2066,#6b4696); color:#fff; border-color:transparent; font-weight:600; box-shadow:0 2px 10px rgba(61,32,102,.25); }
.action-btn.primary:hover { box-shadow:0 4px 18px rgba(61,32,102,.35); transform:translateY(-1px); }

/* ============================================================
   BADGES
   ============================================================ */
.badge { display:inline-flex; align-items:center; gap:3px; padding:2px 9px; border-radius:20px; font-size:.66rem; font-weight:500; }
.badge-imprimatur { display:inline-flex; align-items:center; gap:3px; padding:2px 8px; border-radius:20px; font-size:.65rem; font-weight:500; }
.badge-imprimatur.approved, .badge-category.approved { background:rgba(39,174,96,.1); color:#27ae60; }
.badge-imprimatur.nihil-obstat { background:rgba(230,126,34,.1); color:#e67e22; }
.badge-imprimatur.pending { background:rgba(149,165,166,.1); color:#7f8c8d; }

/* ============================================================
   TOAST
   ============================================================ */
.toast { position:fixed; bottom:24px; right:24px; padding:12px 20px; border-radius:10px; background:#fff; color:var(--text-primary); font-size:.8rem; font-weight:500; box-shadow:0 8px 24px rgba(30,0,80,.18); z-index:9999; border-left:4px solid var(--purple); animation:slideUp .3s ease; }
.toast.error { border-left-color:#e74c3c; }
.toast.warning { border-left-color:#e67e22; }
.toast.success { border-left-color:#27ae60; }
@keyframes slideUp { from{opacity:0;transform:translateY(14px)} to{opacity:1;transform:translateY(0)} }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:rgba(107,70,150,.18); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:rgba(107,70,150,.32); }

/* ============================================================
   MISC
   ============================================================ */
.empty-state { text-align:center; padding:40px 20px; }
.empty-icon { font-size:2rem; margin-bottom:8px; opacity:.25; }
.empty-text { font-size:.82rem; color:var(--text-muted); }
.stagger-item { animation:fadeIn .3s ease backwards; }

/* ============================================================
   RESPONSIVE — See css/mobile.css for comprehensive mobile styles
   ============================================================ */
@media (max-width:1000px) { .right-sidebar { display:none; } }

/* --------- Tablet (768px - 1000px) --------- */
@media (min-width: 769px) and (max-width: 1000px) {
    :root {
        --sidebar-w: 60px;
    }
    .sidebar { width: 60px; }
    .nav-label { display: none; }
    .nav-item { justify-content: center; padding: 10px 8px; }
    .nav-icon { width: auto; font-size: 1.1rem; }
    .sidebar-brand-icon { width: 38px; height: 38px; font-size: 18px; }
    .sidebar-social a { width: 24px; height: 24px; font-size: .6rem; }
    .sidebar-bottom .nav-item { justify-content: center; }
    .main-wrapper { margin-left: 60px; }

    /* Fluid content padding */
    .page { padding: clamp(14px, 2vw, 22px); }
    .header-brand { padding: 14px clamp(14px, 2vw, 22px) 6px; }
    .header-nav-row { padding: 0 clamp(14px, 2vw, 22px); }
    .header-nav-link { padding: 0 clamp(8px, 1.2vw, 16px); font-size: var(--fs-sm); }
}

/* --------- Compact desktops / tablets (769px - 1280px) --------- */
@media (min-width: 769px) and (max-width: 1280px) {
    .top-header { min-height: auto; }
    .header-brand { padding-bottom: 10px; }
    .header-jesus-wrap {
        right: 18px;
        width: clamp(88px, 10vw, 118px);
    }
    .header-nav-row {
        padding: 0 clamp(14px, 2vw, 20px) 12px;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }
    .header-auth {
        margin-left: auto;
    }
    .header-nav {
        order: 2;
        width: 100%;
        height: auto;
        padding-bottom: 2px;
    }
    .header-nav-link {
        height: auto;
        min-height: 40px;
        padding: 10px 12px;
        border-radius: 10px 10px 0 0;
    }
}

@media (min-width: 1001px) and (max-width: 1280px) {
    :root {
        --sidebar-w: 176px;
        --rsidebar-w: 220px;
    }
    .page { padding: clamp(14px, 1.6vw, 20px); }
    .right-sidebar { padding-inline: 8px; }
}

/* --------- Wide screens (>1400px) --------- */
@media (min-width: 1400px) {
    .main-content { max-width: 1200px; }
    :root { --rsidebar-w: 280px; }
}
