/* ============================================================
   PSYOBJECTS — layout.css
   Header, footer, navigation, page structure
   ============================================================ */

/* ── PAGE WRAPPER ───────────────────────────────────────────── */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-content {
    flex: 1;
    padding: var(--space-xl) var(--space-lg);
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-sm {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-md {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* ── HEADER ─────────────────────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-near-black);
    border-bottom: 1px solid var(--color-deep-purple);
    padding: 0 var(--space-lg);
}

.site-header .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Logo */
.site-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.site-logo img {
    height: 36px;
    width: auto;
}

/* Main navigation */
.site-nav {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.nav-link {
    color: var(--color-muted-text);
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-xl);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--color-white);
    background: rgba(138, 43, 226, 0.15);
}

.nav-link.active {
    color: var(--color-light-lilac);
    background: rgba(138, 43, 226, 0.2);
}

/* Header right — user area */
.header-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

/* Credit pill */
.credit-pill {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-dark-surface);
    border: 1px solid var(--color-deep-purple);
    border-radius: var(--radius-xl);
    padding: 4px 14px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-soft-lavender);
    text-decoration: none;
    transition: border-color var(--transition);
}

.credit-pill:hover {
    border-color: var(--color-med-purple);
    color: var(--color-soft-lavender);
}

.credit-pill .credit-icon {
    width: 14px;
    height: 14px;
    fill: var(--color-soft-lavender);
}

.credit-pill.expiring {
    border-color: var(--color-warning);
    color: var(--color-warning);
}

/* Header badge pill */
.header-badge-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--color-dark-surface);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 50%;
    text-decoration: none;
    transition: border-color var(--transition), transform var(--transition);
    position: relative;
}

.header-badge-pill:hover {
    border-color: rgba(138, 43, 226, 0.7);
    transform: scale(1.1);
}

/* User avatar dropdown trigger */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xl);
    transition: background var(--transition);
}

.user-menu-trigger:hover {
    background: rgba(138, 43, 226, 0.15);
}

.user-menu-trigger img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--color-deep-purple);
}

.user-menu-trigger .chevron {
    width: 14px;
    height: 14px;
    fill: var(--color-muted-text);
    transition: transform var(--transition);
}

.user-menu.open .chevron {
    transform: rotate(180deg);
}

/* Dropdown */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--color-dark-surface);
    border: 1px solid var(--color-deep-purple);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 200;
    overflow: hidden;
}

.user-menu.open .user-dropdown {
    display: block;
}

.dropdown-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-deep-purple);
}

.dropdown-header .user-name {
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--color-light-lilac);
}

.dropdown-header .user-type {
    font-size: var(--font-size-xs);
    color: var(--color-muted-text);
    text-transform: capitalize;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-muted-text);
    font-size: var(--font-size-sm);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover {
    background: rgba(138, 43, 226, 0.15);
    color: var(--color-white);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
}

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--color-deep-purple);
    margin: var(--space-xs) 0;
}

.dropdown-item.danger {
    color: var(--color-error);
}

.dropdown-item.danger:hover {
    background: rgba(220, 70, 80, 0.12);
    color: var(--color-error);
}

/* Auth buttons (logged out state) */
.header-auth {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
    color: var(--color-muted-text);
}

.mobile-menu-toggle svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* ── FOOTER ─────────────────────────────────────────────────── */
.site-footer {
    background: var(--color-dark-surface);
    border-top: 1px solid var(--color-deep-purple);
    padding: var(--space-xl) var(--space-lg);
    margin-top: auto;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    max-width: 1100px;
    margin: 0 auto;
}

.footer-logo img {
    height: 28px;
    width: auto;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.footer-logo:hover img {
    opacity: 1;
}

.footer-links {
    display: flex;
    gap: var(--space-lg);
    list-style: none;
    padding: 0;
    flex-wrap: wrap;
}

.footer-links a {
    font-size: var(--font-size-xs);
    color: var(--color-muted-text);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--color-soft-lavender);
}

.footer-copy {
    font-size: var(--font-size-xs);
    color: var(--color-muted-text);
    text-align: right;
}

/* ── PAGE TITLES ────────────────────────────────────────────── */
.page-title {
    margin-bottom: var(--space-xl);
}

.page-title h1 {
    margin-bottom: var(--space-sm);
}

.page-title p {
    font-size: var(--font-size-md);
    color: var(--color-muted-text);
    max-width: 560px;
}

/* ── SECTION ────────────────────────────────────────────────── */
.section {
    margin-bottom: var(--space-xxl);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-light-lilac);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-deep-purple);
}

/* ── DAILY LIMIT BAR ────────────────────────────────────────── */
.limit-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-dark-surface);
    border: 1px solid var(--color-deep-purple);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-xs);
    color: var(--color-muted-text);
    margin-bottom: var(--space-md);
}

.limit-bar .limit-label {
    white-space: nowrap;
    flex-shrink: 0;
}

.limit-bar .progress-bar {
    flex: 1;
    height: 4px;
}

.limit-bar .limit-count {
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 600;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .site-nav {
        display: none;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--color-near-black);
        border-bottom: 1px solid var(--color-deep-purple);
        flex-direction: column;
        padding: var(--space-md);
        gap: var(--space-xs);
        z-index: 99;
    }

    .site-nav.mobile-open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: var(--space-md);
        border-radius: var(--radius-md);
    }

    .mobile-menu-toggle {
        display: block;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .footer-copy {
        text-align: center;
    }

    .page-content {
        padding: var(--space-lg) var(--space-md);
    }
}

/* ============================================================
   PSYOBJECTS — layout.css ADDITIONS
   Append these rules to the bottom of css/layout.css
   ============================================================ */

/* ── COOKIE CONSENT BANNER ──────────────────────────────────── */
#cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--color-dark-surface);
    border-top: 1px solid var(--color-deep-purple);
    padding: var(--space-md) var(--space-xl);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
    #cookie-banner {
        padding: var(--space-md);
    }
}

/* ── AD COLUMN LAYOUT ───────────────────────────────────────── */
/*
 * .page-with-ads wraps .page-content on free/guest accounts.
 * Structure:
 *   <div class="page-with-ads">
 *     <div class="ad-col ad-col-left">  ... </div>
 *     <div class="page-content"> ... </div>
 *     <div class="ad-col ad-col-right"> ... </div>
 *   </div>
 *
 * Applied in header.php when account_type is free or guest
 * and advertising consent has been given.
 */

.page-with-ads {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-height: 100%;
}

.ad-col {
    width: 15%;
    flex-shrink: 0;
    padding-top: var(--space-xl);
    position: sticky;
    top: 64px; /* matches header height */
    max-height: calc(100vh - 64px);
    overflow: hidden;
}

.ad-col-left  { padding-right: var(--space-md); }
.ad-col-right { padding-left:  var(--space-md); }

/* The actual content column fills the remaining 70% */
.page-with-ads .page-content {
    flex: 1;
    min-width: 0; /* prevents flex blowout */
}

/* Ad placeholder (shown while AdSense loads or consent not given) */
.ad-placeholder {
    width: 100%;
    min-height: 250px;
    background: var(--color-dark-surface);
    border: 1px dashed var(--color-deep-purple);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder span {
    font-size: var(--font-size-xs);
    color: var(--color-muted-text);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.08em;
}

/* Hide ad columns on smaller screens — not worth showing */
@media (max-width: 1100px) {
    .ad-col {
        display: none;
    }
}
