/**
 * Estilos principales del sistema
 * Botanas Jonis - Sistema de Ventas en Ruta
 */

/* ============================================================
   RESET Y VARIABLES CSS
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #0B1B3D;
    --blue-mid: #1a3a6e;
    --white: #FFFFFF;
    --light-gray: #F0F2F8;
    --success-green: #10B981;
    --alert-red: #EF4444;
    --text-gray: #6B7280;
    --border-gray: #E5E7EB;
    --pink: #EC4899;
    --fuchsia: #D946EF;
    --orange: #F97316;
    --yellow: #EAB308;
    --shadow-light: 0 2px 12px rgba(11,27,61,0.07);
    --shadow-medium: 0 4px 24px rgba(11,27,61,0.13);
    --shadow-heavy: 0 8px 40px rgba(11,27,61,0.18);
    --radius: 14px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: #F0F2F8;
    color: #1a2340;
    line-height: 1.6;
    font-size: 15px;
}

/* ============================================================
   UTILIDADES
   ============================================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ============================================================
   HEADER
   ============================================================ */

.header {
    background: linear-gradient(135deg, #0B1B3D 0%, #1a3a6e 100%);
    color: var(--white);
    padding: 0.85rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(11,27,61,0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    overflow: visible;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    opacity: 0.95;
}

/* ============================================================
   NAVEGACIÓN
   ============================================================ */

.nav-tabs {
    display: flex;
    background: var(--white);
    border-bottom: none;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(11,27,61,0.06);
    gap: 0;
}

.nav-tab {
    flex: 1;
    min-width: 110px;
    padding: 0.9rem 1rem;
    text-align: center;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-gray);
    transition: all 0.25s ease;
    white-space: nowrap;
    letter-spacing: 0.1px;
}

.nav-tab:hover {
    background: #f5f7ff;
    color: var(--primary-blue);
}

.nav-tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--pink);
    font-weight: 700;
    background: #f5f7ff;
}

/* ============================================================
   CONTENEDORES
   ============================================================ */

.container {
    padding: 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================================
   CARDS - Diseño moderno
   ============================================================ */

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-light);
    border: 1px solid rgba(11,27,61,0.06);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--pink), var(--fuchsia));
    border-radius: var(--radius) 0 0 var(--radius);
}

.card-title {
    font-size: 1.15rem;
    color: var(--primary-blue);
    margin-bottom: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: -0.2px;
}

/* ============================================================
   LOGIN
   ============================================================ */

.login-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0B1B3D 0%, #1a3a6e 60%, #2d1b69 100%);
    padding: 1rem;
    z-index: 9999;
}

.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    position: relative;
    overflow: hidden;
}

.login-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 4px;
    background: linear-gradient(90deg, var(--pink), var(--fuchsia), #3B82F6);
}

.login-header {
    text-align: center;
    margin-bottom: 0;
}

.login-header h1 {
    color: var(--primary-blue);
    font-size: 2rem;
    margin-bottom: 0.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-gray);
    font-size: 0.9rem;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-gray);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all 0.25s ease;
    background: #fafbff;
    color: var(--primary-blue);
}

.form-input:focus {
    outline: none;
    border-color: var(--pink);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(236,72,153,0.1);
}

/* ============================================================
   BOTONES
   ============================================================ */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    min-height: 44px;
    letter-spacing: 0.1px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #0B1B3D, #1a3a6e);
    color: var(--white);
    width: 100%;
    box-shadow: 0 4px 14px rgba(11,27,61,0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(11,27,61,0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--light-gray);
    color: var(--primary-blue);
    border: 2px solid var(--border-gray);
    width: 100%;
}

.btn-secondary:hover {
    border-color: var(--primary-blue);
    background: #e8ecf5;
}

.btn-success {
    background: linear-gradient(135deg, #10B981, #059669);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16,185,129,0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: var(--white);
}

.btn-small {
    padding: 0.45rem 0.9rem;
    font-size: 0.83rem;
    min-height: 34px;
    width: auto;
}

.btn-logout {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
    padding: 0.45rem 1rem;
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.25s ease;
}

.btn-logout:hover {
    background: var(--alert-red);
    color: var(--white);
}

/* ============================================================
   SPINNER Y LOADING
   ============================================================ */

.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(11,27,61,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    background: var(--white);
    padding: 2rem 2.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-heavy);
}

.spinner {
    border: 3px solid var(--light-gray);
    border-top: 3px solid var(--pink);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.login-spinner {
    display: none;
    margin-top: 1rem;
    text-align: center;
}

.login-spinner.active { display: block; }

/* ============================================================
   TABLAS
   ============================================================ */

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

th, td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eef0f7;
}

th {
    background: #f5f7ff;
    color: var(--primary-blue);
    font-weight: 700;
    font-size: 0.83rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #fafbff;
}

/* ============================================================
   PRODUCTOS
   ============================================================ */

.product-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #fafbff;
    border-radius: var(--radius-sm);
    gap: 1rem;
    border: 2px solid transparent;
    transition: all 0.25s ease;
    box-shadow: 0 1px 4px rgba(11,27,61,0.05);
}

.product-item:hover {
    border-color: var(--pink);
    background: var(--white);
    box-shadow: var(--shadow-light);
}

.product-name {
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 0.2rem;
    font-size: 1rem;
}

.product-price {
    color: var(--success-green);
    font-weight: 700;
    font-size: 0.95rem;
}

.product-stock {
    font-size: 0.8rem;
    color: var(--text-gray);
    margin-top: 0.1rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn-quantity {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0B1B3D, #1a3a6e);
    color: var(--white);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(11,27,61,0.25);
}

.btn-quantity:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(11,27,61,0.35);
}

.btn-quantity:active { transform: scale(0.95); }

.quantity-display {
    min-width: 36px;
    text-align: center;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary-blue);
}

/* ============================================================
   ESTADÍSTICAS DASHBOARD
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

.stat-card {
    background: linear-gradient(135deg, #0B1B3D 0%, #1a3a6e 100%);
    color: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(11,27,61,0.25);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
}

.stat-label {
    font-size: 0.83rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* ============================================================
   TOTALES
   ============================================================ */

.total-section {
    background: #f5f7ff;
    padding: 1.1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    border: 1px solid #e8ecf5;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.total-row.final {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--success-green);
    border-top: 2px solid #e8ecf5;
    padding-top: 0.6rem;
    margin-top: 0.6rem;
}

/* ============================================================
   MODALES
   ============================================================ */

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(11,27,61,0.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(3px);
}

.modal.active { display: flex; }

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-heavy);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 2px solid #eef0f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f7ff;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title {
    font-size: 1.3rem;
    color: var(--primary-blue);
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-gray);
    padding: 0.4rem;
    border-radius: 50%;
    transition: all 0.25s;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
}

.modal-close:hover {
    background: #fee2e2;
    color: var(--alert-red);
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 2px solid #eef0f7;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ============================================================
   MENSAJES
   ============================================================ */

.success-message {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
    color: #065F46;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
    border-left: 4px solid var(--success-green);
}

.error-message {
    background: linear-gradient(135deg, #FEE2E2, #FECACA);
    color: #991B1B;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
    border-left: 4px solid var(--alert-red);
}

/* ============================================================
   ICONOS CON COLOR
   ============================================================ */

.icon-pink { color: #EC4899; }
.icon-fuchsia { color: #D946EF; }
.icon-orange { color: #F97316; }
.icon-green { color: #10B981; }
.icon-blue { color: #3B82F6; }
.icon-yellow { color: #EAB308; }

/* ============================================================
   CLIENTES
   ============================================================ */

.client-item {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 0.6rem;
    border: 1px solid #eef0f7;
    box-shadow: 0 1px 6px rgba(11,27,61,0.05);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.client-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: linear-gradient(180deg, var(--pink), var(--fuchsia));
}

.client-item:hover {
    box-shadow: var(--shadow-light);
    border-color: rgba(236,72,153,0.2);
    transform: translateX(2px);
}

.client-name {
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.client-detail {
    font-size: 0.85rem;
    color: var(--text-gray);
    margin-bottom: 0.15rem;
}

.client-item mark {
    background: #FEF08A;
    padding: 0 3px;
    border-radius: 3px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast {
    position: fixed;
    top: 20px; right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    color: var(--white);
    font-weight: 600;
    z-index: 10000;
    transform: translateX(420px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-heavy);
    max-width: 320px;
    font-size: 0.9rem;
}

.toast.show { transform: translateX(0); }

.toast-success { background: linear-gradient(135deg, #10B981, #059669); }
.toast-error { background: linear-gradient(135deg, #EF4444, #DC2626); }
.toast-info { background: linear-gradient(135deg, #0B1B3D, #1a3a6e); }

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ============================================================
   GPS
   ============================================================ */

.gps-coords {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    font-size: 0.88rem;
    color: #065F46;
    font-weight: 600;
    border-left: 3px solid var(--success-green);
}

/* ============================================================
   VIEWS
   ============================================================ */

.view { display: none; }
.view.active { display: block; }

/* ============================================================
   CREDENTIALS HINT
   ============================================================ */

.credentials-hint {
    background: #f5f7ff;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1.5rem;
    font-size: 0.83rem;
    color: var(--text-gray);
    border: 1px solid #e8ecf5;
}

.credentials-hint strong {
    color: var(--primary-blue);
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

/* ============================================================
   SWITCH TOGGLE
   ============================================================ */

.switch-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.9rem;
    background: #f5f7ff;
    border-radius: var(--radius-sm);
    border: 1px solid #e8ecf5;
}

.switch-label {
    font-weight: 600;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.switch-label.active { color: var(--success-green); }

.switch {
    position: relative;
    display: inline-block;
    width: 56px; height: 30px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #CBD5E1;
    transition: .35s;
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px; width: 22px;
    left: 4px; bottom: 4px;
    background: white;
    transition: .35s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

input:checked + .slider { background: var(--success-green); }
input:checked + .slider:before { transform: translateX(26px); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .header { padding: 0.75rem 1rem; }
    .header {
        flex-wrap: wrap;
    }
    .header h1 {
        flex: 1 1 100%;
        font-size: 1rem;
    }
    .header h1 img {
        height: 50px !important;
        position: static !important;
        transform: none !important;
        vertical-align: middle;
        margin-right: 0.5rem;
    }
    .header h1 span {
        margin-left: 0 !important;
    }
    #headerLogo {
        height: 50px !important;
        position: static !important;
        transform: none !important;
        vertical-align: middle;
    }
    #headerTitle {
        margin-left: 0.5rem !important;
        font-size: 1rem;
    }
    .user-info {
        flex: 1;
        justify-content: flex-end;
    }
    .container { padding: 0.75rem; }
    .card { padding: 1.1rem; }
    .login-card { padding: 1.75rem; }

    .product-item {
        flex-direction: column;
        align-items: stretch;
    }

    .quantity-controls {
        justify-content: center;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #eef0f7;
    }
}

@media (max-width: 480px) {
    .nav-tab {
        min-width: 90px;
        font-size: 0.8rem;
        padding: 0.75rem 0.5rem;
    }

    .stats-grid { grid-template-columns: 1fr; }
}

