/**
 * MiSeguroSP Layout System
 * Modern, responsive layout structure
 * Version: 2.0
 */

/* ========================================
   RESET & BASE
   ======================================== */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-gray-900);
    background: var(--color-bg-gradient);
    min-height: 100vh;
}

/* ========================================
   MAIN APP STRUCTURE
   ======================================== */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    width: 100%;
}

.header-container {
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-logo-container {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.app-logo {
    height: 50px;
    width: auto;
    transition: transform var(--transition-base);
}

.app-logo:hover {
    transform: scale(1.02);
}

.logo-decorative {
    height: 60px;
    width: auto;
    opacity: 0.9;
}

/* Header for logged out users (consistent logo) */
.header-guest .app-logo {
    height: 50px;
}

/* ========================================
   MOBILE HEADER ADJUSTMENTS
   ======================================== */
@media (max-width: 767px) {
    .app-header {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
        /* Softer shadow */
        height: 60px;
        /* Fixed height for consistency */
        display: flex;
        align-items: center;
    }

    .header-container {
        padding: 0 var(--space-4);
        width: 100%;
        justify-content: center;
        /* Center logo */
        height: 100%;
    }

    .app-logo-container {
        /* If there are other elements, ensure logo is centered */
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    .app-logo {
        height: 32px;
        /* Nicer mobile size */
    }

    /* Ensure decorative elements don't mess up layout */
    .logo-decorative {
        display: none;
    }
}

/* ========================================
   NAVIGATION - DESKTOP
   ======================================== */
.navbar-desktop {
    display: none;
}

@media (min-width: 768px) {
    .navbar-desktop {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        background: var(--bg-surface);
        padding: var(--space-1);
        border-radius: var(--radius-full);
        /* Optional: Add shadow or border if distinct container needed, 
           but usually cleaner as just items */
    }

    .nav-item {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        padding: var(--space-2) var(--space-4);
        color: var(--color-gray-600);
        font-weight: var(--font-weight-semibold);
        font-size: var(--font-size-sm);
        text-decoration: none;
        border: none;
        /* Removed vertical borders */
        border-radius: var(--radius-full);
        /* Pill shape */
        transition: all var(--transition-base);
        cursor: pointer;
        background: transparent;
        height: 40px;
        /* Consistent height */
    }

    .nav-item:first-child {
        border-left: none;
    }

    /* Hover State: Light background pill */
    .nav-item:hover,
    .nav-item:focus {
        background: var(--color-gray-100);
        color: var(--color-primary);
        transform: translateY(0);
        /* Reset any card transforms */
        text-decoration: none;
    }

    /* Active State (if needed logic exists) */
    .nav-item.active {
        background: var(--color-primary-light);
        color: var(--color-primary);
    }

    /* Icon refinements */
    .nav-item i {
        font-size: 1.1em;
        opacity: 0.8;
    }

    .nav-item:hover i {
        opacity: 1;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        border-radius: var(--radius-full);
        object-fit: cover;
        border: 2px solid var(--color-primary-light);
        margin: -4px 0;
        /* Adjust to keep item height consistent */
    }

    /* Dropdown Overrides for Modern Look */
    .dropdown-menu {
        border: none;
        box-shadow: var(--shadow-xl);
        border-radius: var(--radius-xl);
        padding: var(--space-2);
        margin-top: var(--space-2);
        animation: fadeIn 0.2s ease-out;
        min-width: 240px;
    }

    .dropdown-item {
        padding: var(--space-3) var(--space-4);
        border-radius: var(--radius-lg);
        transition: background var(--transition-fast);
        color: var(--color-secondary);
    }

    .dropdown-item:hover {
        background: var(--color-gray-50);
        color: var(--color-primary);
        text-decoration: none;
    }

    .dropdown-divider {
        margin: var(--space-2) 0;
        border-top-color: var(--color-gray-100);
    }

    /* Keyframes for smooth dropdown */
    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
main {
    flex: 1;
    width: 100%;
    padding: var(--space-8) var(--space-4);
}

.main-container {
    max-width: var(--container-xl);
    margin: 0 auto;
}

/* Centered layout for auth pages */
.layout-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: var(--space-6) var(--space-4);
}

/* ========================================
   FOOTER
   ======================================== */
.app-footer {
    background: var(--bg-surface);
    padding: var(--space-6) var(--space-4);
    margin-top: auto;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
}

.footer-container {
    max-width: var(--container-xl);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.footer-logo {
    height: 40px;
    width: auto;
}

.footer-links {
    display: flex;
    gap: var(--space-6);
    flex-wrap: wrap;
}

.footer-link {
    color: var(--color-gray-600);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color var(--transition-base);
}

.footer-link:hover {
    color: var(--color-accent);
}

/* ========================================
   MOBILE NAVIGATION (BOTTOM BAR)
   ======================================== */
.navbar-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-fixed);
    display: flex;
    justify-content: space-around;
    padding: var(--space-2) 0;
}

.nav-mobile-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2);
    color: var(--color-gray-600);
    text-decoration: none;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-base);
    border: none;
    background: transparent;
    cursor: pointer;
    flex: 1;
    max-width: 100px;
}

.nav-mobile-item i {
    font-size: var(--font-size-xl);
}

.nav-mobile-item.active,
.nav-mobile-item:active {
    color: var(--color-primary);
    background: var(--color-gray-50);
}

/* Divider between mobile nav items */
.nav-mobile-divider {
    width: 1px;
    background: var(--color-gray-200);
    margin: var(--space-2) 0;
}

@media (min-width: 768px) {
    .navbar-mobile {
        display: none;
    }
}

/* ========================================
   HAMBURGER MENU (MOBILE)
   ======================================== */
.hamburger-button {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    background: var(--color-secondary);
    color: var(--color-white);
    border: none;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-3xl);
    cursor: pointer;
    z-index: calc(var(--z-fixed) + 50);
    /* Force above menu sheet */
    transition: all var(--transition-base);
}

.hamburger-button:hover {
    transform: scale(1.05);
    background: var(--color-secondary-dark);
}

.hamburger-button:active {
    transform: scale(0.95);
}

@media (min-width: 768px) {
    .hamburger-button {
        display: none;
    }
}

/* Mobile Menu Panel */
/* Mobile Menu Panel (Bottom Sheet) */
.mobile-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    /* Override top: 0 */
    background: var(--bg-surface);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    /* More prominent shadow for sheet */
    padding: var(--space-6) var(--space-4) var(--space-8);
    /* Padding bottom for safety */
    z-index: var(--z-fixed);
    transform: translateY(100%);
    /* Start hidden below screen */
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    /* Smooth spring-like ease */
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    /* Rounded top corners */
    max-height: 85vh;
    /* Don't cover entire screen */
    overflow-y: auto;
}

.mobile-menu.show {
    transform: translateY(0);
    /* Slide up */
    max-height: 85vh;
    /* Keep limit */
}

/* Handle indicator for bottom sheet */
.mobile-menu::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--color-gray-300);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-6);
    opacity: 0.6;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    color: var(--color-secondary);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    border-bottom: 1px solid var(--color-gray-100);
    transition: background var(--transition-fast);
    border-radius: var(--radius-lg);
    /* Rounded items */
}

.mobile-menu-item:hover {
    background: var(--color-gray-50);
    text-decoration: none;
}

.mobile-menu-item:last-child {
    border-bottom: none;
}

.mobile-menu-item i {
    font-size: var(--font-size-2xl);
    color: var(--color-primary);
    width: 30px;
    text-align: center;
}

.mobile-menu-item-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    margin-bottom: 2px;
}

.mobile-menu-item-description {
    font-size: var(--font-size-xs);
    color: var(--color-gray-500);
}

/* ========================================
   FLOATING ACTION BUTTONS
   ======================================== */
.floating-actions {
    position: fixed;
    bottom: 100px;
    right: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    z-index: var(--z-fixed);
}

.floating-btn {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    color: var(--color-white);
    text-decoration: none;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
}

.floating-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.floating-btn.whatsapp {
    background: #25d366;
}

.floating-btn.emergency {
    background: var(--color-primary);
}

/* Adjust for mobile to not overlap bottom nav */
@media (max-width: 767px) {
    .floating-actions {
        bottom: 90px;
        right: var(--space-4);
    }

    .floating-btn {
        width: 48px;
        height: 48px;
        font-size: var(--font-size-xl);
    }
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 768px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Spacing utilities for content above mobile nav */
.mobile-nav-spacer {
    height: 80px;
}

@media (min-width: 768px) {
    .mobile-nav-spacer {
        display: none;
    }
}

/* ========================================
   GLOBAL LOADER OVERLAY
   ======================================== */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    /* Flex but hidden via inline style or class toggle usually */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.loader-content {
    text-align: center;
    padding: var(--space-8);
    max-width: 400px;
    width: 90%;
}

[data-theme="dark"] .loader-overlay {
    background: rgba(15, 23, 42, 0.95);
}

.loader-logo-container {
    margin-bottom: var(--space-6);
}

.loader-logo-img {
    height: 60px;
    width: auto;
    animation: pulse 2s infinite ease-in-out;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto var(--space-6);
    animation: spin 1s linear infinite;
}

.loader-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    color: var(--color-secondary);
    margin: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}