/* ============================================
   Sistema de Control de Asistencia - ISTB
   CSS Responsivo
   ============================================ */

:root {
    --primary: #1a56db;
    --primary-dark: #1e429f;
    --primary-light: #3f83f8;
    --success: #0e9f6e;
    --success-light: #84e1bc;
    --warning: #c27803;
    --warning-light: #fce96a;
    --danger: #e02424;
    --danger-light: #f8b4b4;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============ LAYOUT ============ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* ============ HEADER ============ */
.header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.nav a:hover, .nav a.active {
    background: rgba(255,255,255,0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.user-badge {
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

/* ============ CARDS ============ */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 1.5rem;
}

/* ============ MARCACIÓN ============ */
.marcacion-container {
    max-width: 500px;
    margin: 2rem auto;
}

.reloj {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    color: var(--gray-800);
    font-family: 'Courier New', monospace;
    padding: 1rem;
    background: var(--gray-100);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.fecha-actual {
    text-align: center;
    color: var(--gray-600);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.botones-marcacion {
    display: flex;
    gap: 1rem;
    flex-direction: column;
}

.btn-marcar {
    padding: 1.5rem 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-marcar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-entrada {
    background: var(--success);
    color: white;
}

.btn-entrada:hover:not(:disabled) {
    background: #0c8a5f;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-salida {
    background: var(--danger);
    color: white;
}

.btn-salida:hover:not(:disabled) {
    background: #c81e1e;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.estado-marcacion {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 8px;
}

.estado-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

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

/* ============ FORMULARIOS ============ */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-input, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

/* ============ BOTONES ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #0c8a5f;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c81e1e;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

/* ============ ALERTAS ============ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: #def7ec;
    color: #03543f;
    border: 1px solid var(--success-light);
}

.alert-danger {
    background: #fde8e8;
    color: #9b1c1c;
    border: 1px solid var(--danger-light);
}

.alert-warning {
    background: #fdf6b2;
    color: #723b13;
    border: 1px solid var(--warning-light);
}

.alert-info {
    background: #e1effe;
    color: #1e429f;
    border: 1px solid #a4cafe;
}

/* ============ TABLAS ============ */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}

.table tr:hover {
    background: var(--gray-50);
}

.table .text-center {
    text-align: center;
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 20px;
}

.badge-success {
    background: #def7ec;
    color: #03543f;
}

.badge-danger {
    background: #fde8e8;
    color: #9b1c1c;
}

.badge-warning {
    background: #fdf6b2;
    color: #723b13;
}

.badge-info {
    background: #e1effe;
    color: #1e429f;
}

.badge-gray {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* ============ STATS GRID ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.danger { border-left: 4px solid var(--danger); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.info { border-left: 4px solid var(--primary); }

/* ============ LOGIN ============ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: var(--gray-50);
    padding: 2rem;
    text-align: center;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-top: 1rem;
}

.login-header p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.login-body {
    padding: 2rem;
}

/* ============ IP WARNING ============ */
.ip-warning {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--gray-100);
}

.ip-warning-card {
    max-width: 500px;
    text-align: center;
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.ip-warning-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.ip-warning h1 {
    color: var(--danger);
    margin-bottom: 1rem;
}

.ip-warning p {
    color: var(--gray-600);
    margin-bottom: 1.5rem;
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ============ FILTROS ============ */
.filtros {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 8px;
}

.filtros .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .nav {
        width: 100%;
        justify-content: center;
    }
    
    .user-info {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    
    .reloj {
        font-size: 2.5rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .table th, .table td {
        padding: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filtros {
        flex-direction: column;
    }
    
    .filtros .form-group {
        width: 100%;
    }
    
    .btn-block-mobile {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .reloj {
        font-size: 2rem;
    }
    
    .btn-marcar {
        padding: 1rem;
        font-size: 1rem;
    }
}

/* ============ UTILIDADES ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--primary); }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none; }

/* ============ CONTADOR DE JORNADA EN VIVO ============ */
.contador-jornada-frame {
    background: linear-gradient(135deg, #1e3a5f 0%, #1a56db 100%);
    color: white;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.contador-jornada-frame.pausado {
    background: linear-gradient(135deg, #92400e 0%, #c27803 100%);
}

.contador-jornada-frame.completado {
    background: linear-gradient(135deg, #065f46 0%, #0e9f6e 100%);
}

.contador-label {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.contador-display {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

.contador-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 0.5rem;
}

.contador-barra {
    height: 6px;
    background: rgba(255,255,255,0.25);
    border-radius: 3px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.contador-barra-progreso {
    height: 100%;
    background: white;
    border-radius: 3px;
    width: 0%;
    transition: width 1s linear;
}

/* ============ FRAME DE ALMUERZO ============ */
.almuerzo-frame {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.almuerzo-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 0.5rem;
}

.almuerzo-contador {
    font-size: 2.25rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: #92400e;
    margin: 0.5rem 0;
}

.almuerzo-info {
    font-size: 0.85rem;
    color: #78350f;
    margin-bottom: 1rem;
}

/* ============ AVISO SALIDA PERSONAL ============ */
.aviso-personal-frame {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.aviso-personal-icon {
    font-size: 2rem;
}

.aviso-personal-texto strong {
    display: block;
    color: #92400e;
    margin-bottom: 0.25rem;
}

.aviso-personal-texto p {
    font-size: 0.85rem;
    color: #78350f;
    margin: 0;
}

/* ============ MODAL DE MOTIVO SALIDA ============ */
.motivo-opciones {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.motivo-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 0.95rem;
    width: 100%;
}

.motivo-btn:hover {
    border-color: var(--primary);
    background: #e1effe;
}

.motivo-btn .motivo-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.motivo-btn .motivo-texto strong {
    display: block;
    color: var(--gray-800);
}

.motivo-btn .motivo-texto small {
    color: var(--gray-500);
    font-size: 0.8rem;
}

/* ============ SUB-MODAL OFICIAL ============ */
.submodal-oficial {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

/* ============ RESPONSIVE CONTADOR ============ */
@media (max-width: 480px) {
    .contador-display {
        font-size: 1.8rem;
    }
    .almuerzo-contador {
        font-size: 1.8rem;
    }
}
