:root {
    --primary: #2C3E50;
    --primary-light: #34495E;
    --secondary: #95A5A6;
    --success: #27AE60;
    --danger: #E74C3C;
    --bg-color: #F8F9FA;
    --text-color: #333333;
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0;
    --border-radius: 12px; /* Mayor radio para look de app */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --bottom-nav-height: 70px;
    /* Misma altura que #unifiedTopbar en nav.php (position: fixed) */
    --topbar-height: 60px;
}

/* Prevenir scroll horizontal en todos los dispositivos */
html {
    overflow-x: hidden;
    max-width: 100%;
    /* Scroll padding para anclas (no queden tapadas por topbar) */
    scroll-padding-top: calc(var(--topbar-height) + 16px);
}

/* Padding global en body para que el topbar fijo no tape nada (sin hueco extra) */
body {
    padding-top: var(--topbar-height) !important;
}

html {
    overflow-x: hidden; /* Evita scroll horizontal en mobile */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    max-width: 100%;
    touch-action: manipulation; /* Evita zoom por doble toque rápido */
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: 0;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Authentication Layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 20px;
    background-color: #EDF2F7;
    padding-bottom: 20px; /* Sin nav bar aqui */
}

.auth-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    padding: 30px 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.auth-card h1, .auth-card h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--primary);
    font-weight: 600;
}

.auth-logo {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -1px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    color: #4A5568;
}

/* ── Anti-zoom iOS: el browser hace zoom cuando font-size < 16px ── */
input, select, textarea, button {
    font-size: 16px; /* mínimo requerido por iOS para no hacer zoom */
    font-family: inherit;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px; /* explícito — nunca menos de 16px */
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #FFFFFF;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234A5568' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Buttons */
/* ── Botón principal — optimizado para mobile ── */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 17px 28px;
    background: linear-gradient(135deg, #2C3E50 0%, #3d5166 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    text-decoration: none;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(44,62,80,.35);
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 54px; /* zona táctil mínima */
}

.btn:hover {
    background: linear-gradient(135deg, #3d5166 0%, #4a6278 100%);
    box-shadow: 0 6px 18px rgba(44,62,80,.40);
}

.btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 6px rgba(44,62,80,.30);
}

.btn-danger    { background: linear-gradient(135deg, #c0392b, #e74c3c); box-shadow: 0 4px 14px rgba(231,76,60,.35); }
.btn-danger:hover { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.btn-success   { background: linear-gradient(135deg, #27ae60, #2ecc71); box-shadow: 0 4px 14px rgba(39,174,96,.35); }
.btn-success:hover { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn-secondary { background: linear-gradient(135deg, #718096, #95a5a6); box-shadow: 0 4px 14px rgba(113,128,150,.30); }

/* Botón pequeño — para acciones secundarias (no guardado) */
.btn-sm {
    padding: 10px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    width: auto;
    min-height: 40px;
    border-radius: 10px;
    box-shadow: none;
    letter-spacing: 0;
}


/* Floating Action Button (FAB) */
.fab {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 56px;
    height: 56px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    text-decoration: none;
    z-index: 100;
    transition: transform 0.2s;
}
.fab:active {
    transform: scale(0.9);
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}

.alert-error {
    background-color: #FED7D7;
    color: #C53030;
    border: 1px solid #FEB2B2;
}

.alert-success {
    background-color: #C6F6D5;
    color: #2F855A;
    border: 1px solid #9AE6B4;
}

/* Dashboard Layout */
.dashboard-header {
    display: none !important; /* Ocultamos la vieja cabecera porque ahora se usa Unified Topbar en nav.php */
}

.dashboard-header .brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-content {
    padding: 0 20px 80px; /* Quitamos padding-top 16px para que no haya hueco arriba del buscador */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.section-title {
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 1.3rem;
    font-weight: 600;
}

/* ── Navegación: el CSS del drawer está en nav.php (self-contained) ── */
/* Las clases .nav-item, #mainNav, #navToggleBtn, #navOverlay viven en nav.php */

/* Compatibilidad: si alguna página vieja usa .bottom-nav, ocultarla */
.bottom-nav:not(#mainNav) { display: none !important; }

/* Search Bar Mobile */
.search-container {
    background: #FFF;
    padding: 20px;
    position: relative; /* Cambiado de sticky para evitar solapamientos con la grilla */
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    margin-bottom: 25px; /* Más espacio para las cards */
    border-radius: 0 0 16px 16px; /* Bordes redondeados abajo para look moderno */
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #A0AEC0;
}

.search-input-wrapper input {
    padding-left: 44px;
    border-radius: 30px;
    background-color: #EDF2F7;
    border: none;
}

.search-input-wrapper input:focus {
    background-color: #FFF;
    border: 1px solid var(--primary);
}

/* Mobile Cards (Reemplazo de Tablas) */
.data-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.data-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    border-bottom: 1px solid #EDF2F7;
    padding-bottom: 12px;
}

.data-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
}

.data-card-subtitle {
    font-size: 0.85rem;
    color: #718096;
    margin-top: 4px;
}

.data-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
}

.data-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4A5568;
}

.data-row i {
    color: #A0AEC0;
    width: 16px;
    text-align: center;
}

.data-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #EDF2F7;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    text-decoration: none;
    color: white;
    font-size: 1.1rem;
}

.btn-edit { background-color: #E2E8F0; color: #4A5568; }
.btn-delete { background-color: #FED7D7; color: #C53030; }
.btn-whatsapp { background-color: #25D366; color: white; }

/* ── Botón hamburguesa — visible en TODOS los tamaños ── */
#sidebarToggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    margin-right: 10px;
    flex-shrink: 0;
    transition: background 0.15s;
}
#sidebarToggle:hover { background: #EDF2F7; }

/* ── Desktop grid ── */
@media (min-width: 900px) {
    .data-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    .fab {
        bottom: 40px;
        right: 40px;
    }
}
