/*
 * Layout Mobile-First — diseñado para tablet/celular como app nativa.
 * Navegacion inferior (bottom tabs), botones grandes, touch-friendly.
 * Desktop se adapta desde mobile, no al reves.
 */

/* === RESET === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}

/* === TOP BAR (compacta, como app) === */
.navbar {
    background: var(--navy);
    color: var(--white);
    padding: 0 var(--spacing-md);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.navbar-brand a {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    text-decoration: none;
    color: var(--white);
}

.navbar-logo {
    font-size: var(--font-size-lg);
    font-weight: 900;
    color: var(--orange);
    letter-spacing: 0.05em;
}

.navbar-subtitle {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

/* Menu superior oculto en mobile — se mueve a bottom tabs */
.navbar-menu {
    display: none;
}

.navbar-end {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.navbar-user {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.6);
}

/* === BOTTOM NAVIGATION (como app nativa) === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: color 0.2s;
    min-width: 64px;
    gap: 2px;
}

.bottom-nav-item.active {
    color: var(--orange);
}

.bottom-nav-item:active {
    background: var(--gray-100);
}

.bottom-nav-icon {
    font-size: 22px;
    line-height: 1;
}

/* === MAIN CONTENT (con espacio para bottom nav) === */
.main-content {
    flex: 1;
    padding: var(--spacing-md);
    padding-bottom: calc(64px + var(--spacing-lg) + env(safe-area-inset-bottom, 0));
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
}

/* === PAGE HEADER === */
.page-header {
    margin-bottom: var(--spacing-md);
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: 900;
    color: var(--navy);
    line-height: 1.2;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    margin-top: 2px;
    word-break: break-word;
}

/* === FOOTER (oculto en mobile, bottom nav lo reemplaza) === */
.footer {
    display: none;
}

/* === GRID (1 columna en mobile) === */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }

/* === STAT CARDS (compactas, 2 por fila) === */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    border: 1px solid var(--gray-200);
    text-align: center;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 900;
    color: var(--orange);
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* === SCROLL HORIZONTAL para tablas === */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    margin: 0 calc(-1 * var(--spacing-md));
    padding: 0 var(--spacing-md);
}

/* === MESSAGES/ALERTS === */
.messages {
    margin-bottom: var(--spacing-md);
}

/* === SAFE AREA (notch, home indicator) === */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* === PULL TO REFRESH indicator area === */
.main-content {
    padding-top: var(--spacing-md);
}

/* ============================================
   DESKTOP / TABLET LANDSCAPE (>= 768px)
   ============================================ */
@media (min-width: 768px) {
    .navbar {
        padding: 0 var(--spacing-xl);
        height: 60px;
    }

    .navbar-logo {
        font-size: var(--font-size-xl);
    }

    /* Mostrar menu superior en desktop */
    .navbar-menu {
        display: flex;
        gap: var(--spacing-lg);
    }

    .navbar-link {
        color: rgba(255, 255, 255, 0.8);
        text-decoration: none;
        font-size: var(--font-size-sm);
        font-weight: 500;
        padding: 0.5rem 0;
        border-bottom: 2px solid transparent;
        transition: all 0.2s;
    }

    .navbar-link:hover,
    .navbar-link.active {
        color: var(--white);
        border-bottom-color: var(--orange);
    }

    /* Ocultar bottom nav en desktop */
    .bottom-nav {
        display: none;
    }

    .main-content {
        padding: var(--spacing-xl);
        padding-bottom: var(--spacing-xl);
        max-width: 1200px;
        margin: 0 auto;
    }

    /* Mostrar footer en desktop */
    .footer {
        display: block;
        background: var(--navy-dark);
        color: rgba(255, 255, 255, 0.4);
        text-align: center;
        padding: var(--spacing-md);
        font-size: var(--font-size-xs);
    }

    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }

    .page-title {
        font-size: var(--font-size-2xl);
    }

    .stat-value {
        font-size: var(--font-size-3xl);
    }
}
