/* ═══════════════════════════════════════════════════════════
   LAYOUT.CSS - Main layout styles (nav, footer, drawer, flashes)
   ═══════════════════════════════════════════════════════════ */

/* --- Variables & Base --- */
:root {
    --color-primary: #086F48;
    --color-secondary: #FBBF24;
    --color-accent: #10B981;
}

/* Fix: Override Tailwind's .container to always be 1200px */
.container {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    width: 100% !important;
}

html, body {
    min-height: 100vh;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    display: flex;
    flex-direction: column;
}

#main-content {
    flex: 1;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
}

/* --- Navigation --- */
.main-nav {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.nav-logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.nav-logo-img {
    max-height: var(--logo-height, 44px);
    width: auto;
    border-radius: 6px;
}

.nav-logo-fallback {
    width: var(--logo-height, 44px);
    height: var(--logo-height, 44px);
    background: var(--color-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-logo-text {
    color: white;
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Space Grotesk', sans-serif;
}

.nav-brand-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-primary);
}

/* Desktop Menu */
.nav-desktop-menu {
    display: flex;
    gap: 2rem;
    margin-left: 2rem;
    align-items: center;
}

.nav-link {
    position: relative;
    color: var(--color-primary-light);
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--color-secondary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-secondary);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* User Area */
.nav-user-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user-greeting {
    font-size: 0.875rem;
    color: var(--color-primary-light);
}

.nav-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    margin-left: 4px;
}

.nav-badge-admin {
    background: #086F48;
    color: white;
}

.nav-badge-premium {
    background: #FEF3C7;
    color: #92400E;
}

.nav-badge-free {
    background: #F1F5F9;
    color: #64748B;
}

.nav-admin-link {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    background: #086F48;
    color: white;
}

.nav-logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.nav-logout-btn {
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
    line-height: 1;
    min-height: auto !important;
    width: auto !important;
}

/* Public Auth Buttons */
.nav-auth-buttons {
    display: flex;
    gap: 0.5rem;
}

.nav-auth-login {
    background: transparent !important;
    color: var(--color-primary) !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
    box-shadow: none !important;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-lg);
}

.nav-auth-login:hover {
    background: var(--color-primary) !important;
    color: white !important;
}

.nav-auth-register {
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
    background: var(--color-primary) !important;
    color: white !important;
    border-radius: var(--radius-lg);
}

.nav-auth-register:hover {
    background: var(--color-primary-dark) !important;
}

/* --- Alerts --- */
.alert {
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    border-left: 4px solid;
}

.alert-success {
    background: #F0FDF4;
    border-color: var(--color-accent);
    color: #14532D;
}

.alert-error {
    background: #FEF2F2;
    border-color: var(--color-danger);
    color: #7F1D1D;
}

.alert-flex {
    display: flex;
    gap: 0.75rem;
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.flash-container {
    margin-top: 1.5rem;
}

/* --- Footer --- */
.footer-link {
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: white;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-main {
    background: var(--color-primary);
    color: white;
    padding: 4rem 0 2rem;
}

.footer-logo-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.footer-logo-img {
    max-height: var(--logo-height, 44px);
    width: auto;
    border-radius: 8px;
}

.footer-logo-fallback {
    width: var(--logo-height, 44px);
    height: var(--logo-height, 44px);
    background: var(--color-secondary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-logo-fallback-text {
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    font-family: 'Space Grotesk', sans-serif;
}

.footer-brand-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
}

.footer-desc {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.7;
}

.footer-heading {
    color: white;
    margin-bottom: 1.5rem;
}

.footer-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-list-item {
    margin-bottom: 0.75rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 2rem;
    text-align: center;
}

.footer-copy {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.footer-legal {
    margin: 0;
}

.footer-legal-link {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-legal-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

.footer-legal-link + .footer-legal-link {
    margin-left: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE DRAWER NAVIGATION
   ═══════════════════════════════════════════════════════════ */
.mobile-drawer {
    position: fixed;
    right: 0; top: 0;
    width: 280px; height: 100vh;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1002;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}
.mobile-drawer.open {
    transform: translateX(0);
}
.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.mobile-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.drawer-close {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: none;
    background: #F1F5F9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.drawer-close:hover {
    background: #E2E8F0;
}
.drawer-nav {
    flex: 1;
    padding: 0.75rem 0;
}
.drawer-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.5rem;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s;
}
.drawer-link:hover,
.drawer-link:active {
    background: #F8FAFC;
    color: var(--color-secondary);
}
.drawer-link-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.drawer-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.5rem 1.5rem;
}
.drawer-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: #F8FAFC;
}
.drawer-user-info {
    font-size: 0.875rem;
    color: var(--color-primary-light);
    margin-bottom: 0.75rem;
}
.drawer-user-info strong {
    color: var(--color-primary);
}
.drawer-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    border-radius: 10px;
    border: 2px solid var(--color-border);
    background: white;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}
.drawer-logout-btn:hover {
    border-color: #EF4444;
    color: #EF4444;
    background: #FEF2F2;
}

/* Hamburger button */
.hamburger-btn {
    display: none;
    width: 44px; height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    transition: background 0.2s;
}
.hamburger-btn:hover {
    background: #F1F5F9;
}
.hamburger-btn svg {
    width: 28px; height: 28px;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .desktop-menu { display: none !important; }
    .desktop-user { display: none !important; }
    .hamburger-btn { display: flex; align-items: center; justify-content: center; }
    .nav-auth-buttons .btn { padding: 0.375rem 0.625rem; font-size: 0.7rem; }
    .footer-grid { grid-template-columns: 1fr !important; gap: 2rem !important; }
    .footer-main { padding: 2.5rem 0 1.5rem !important; }
}

@media (max-width: 380px) {
    .nav-auth-buttons { flex-direction: column; gap: 0.375rem; }
}

/* ═══════════════════════════════════════════════════════════
   SKIP LINK (Accessibility)
   ═══════════════════════════════════════════════════════════ */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: #086F48;
    color: white;
    padding: 0.75rem 1.5rem;
    z-index: 9999;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 0 0 8px 0;
    text-decoration: none;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* ═══════════════════════════════════════════════════════════
   BREADCRUMB (Visual Navigation)
   ═══════════════════════════════════════════════════════════ */
.breadcrumb-bar {
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    padding: 0.5rem 0;
}
.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
}
.breadcrumb-item {
    color: #64748B;
}
.breadcrumb-item + .breadcrumb-item::before {
    content: '›';
    margin-right: 0.375rem;
    color: #94A3B8;
}
.breadcrumb-link {
    color: #086F48;
    text-decoration: none;
}
.breadcrumb-link:hover {
    text-decoration: underline;
}
.breadcrumb-current {
    color: #086F48;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   FOCUS VISIBLE (Accessibility)
   ═══════════════════════════════════════════════════════════ */
:focus-visible {
    outline: 3px solid #086F48;
    outline-offset: 2px;
    border-radius: 4px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #086F48;
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   PREFERS REDUCED MOTION (Accessibility)
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   SAFE AREA INSETS (Notch / iPhone X+)
   ═══════════════════════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-top)) {
    .main-nav {
        padding-top: env(safe-area-inset-top);
    }
    .footer-main {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-drawer {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}
