/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    max-width: 140px;
    height: auto;
    margin-bottom: 1rem;
}

.login-header i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--text-color);
}

.company-name {
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--secondary-color);
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
}

.navbar-brand i {
    font-size: 1.5rem;
}

.navbar-menu {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--secondary-color);
    border-radius: 0.5rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Content */
.main-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.view-content {
    display: none;
}

.view-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.875rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.bg-blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-icon.bg-green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.stat-icon.bg-orange { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.stat-icon.bg-purple { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }

.stat-info h3 {
    font-size: 2rem;
    font-weight: bold;
    margin: 0;
}

.stat-info p {
    color: var(--secondary-color);
    margin: 0;
}

/* Dashboard Section */
.dashboard-section {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin-top: 2rem;
}

.dashboard-section h3 {
    margin-bottom: 1rem;
}

/* Filters */
.filters-section {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

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

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

.form-control {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
}

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

.btn-secondary:hover {
    background-color: #475569;
}

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

.btn-success:hover {
    background-color: #059669;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

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

.table th {
    font-weight: 600;
    background-color: var(--bg-color);
}

.table tr:hover {
    background-color: var(--bg-color);
}

/* Cards */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Roster Calendar */
.roster-calendar {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.roster-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    table-layout: fixed;
}

.roster-table th,
.roster-table td {
    padding: 0.15rem 0.1rem;
    border: 1px solid var(--border-color);
    text-align: center;
    vertical-align: middle;
}

.roster-table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    font-size: 0.7rem;
    padding: 0.3rem 0.1rem;
    line-height: 1.2;
    width: 2.5%;
}

.roster-table th:first-child {
    width: 10%;
}

.roster-table th small {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.1rem;
}

.roster-table tbody tr {
    height: 40px;
}

.roster-table td:first-child {
    text-align: left;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.2;
    font-weight: 600;
}

.roster-table td:first-child strong {
    display: block;
    font-size: 0.8rem;
}

.roster-cell {
    padding: 0;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.roster-cell:hover {
    opacity: 0.85;
}

.roster-cell-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    min-height: 35px;
    padding: 0.2rem;
}

.roster-select-hidden {
    width: 100%;
    padding: 0.3rem 0.1rem;
    border: 2px solid var(--primary-color);
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    background: white;
}

.roster-select-hidden:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Colores para opciones en el select oculto */
.roster-select-hidden option[value=""] {
    background-color: #ffffff;
    color: #64748b;
}

.roster-select-hidden option[value="SGA"] {
    background-color: #3b82f6;
    color: white;
}

.roster-select-hidden option[value="BA"] {
    background-color: #8b5cf6;
    color: white;
}

.roster-select-hidden option[value="ST"] {
    background-color: #06b6d4;
    color: white;
}

.roster-select-hidden option[value="SJ"] {
    background-color: #10b981;
    color: white;
}

.roster-select-hidden option[value="CE"] {
    background-color: #14b8a6;
    color: white;
}

.roster-select-hidden option[value="M"] {
    background-color: #f59e0b;
    color: white;
}

.roster-select-hidden option[value="D"] {
    background-color: #ef4444;
    color: white;
}

.roster-select-hidden option[value="FO"] {
    background-color: #ec4899;
    color: white;
}

.roster-select-hidden option[value="V"] {
    background-color: #6366f1;
    color: white;
}

/* Reportes Grid */
.reportes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.reporte-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.reporte-card h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.reporte-card p {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.reporte-card .form-control {
    margin-bottom: 0.5rem;
}

.reporte-resultado {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin-top: 2rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s;
}

.modal-lg {
    max-width: 900px;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
}

.close:hover {
    color: var(--danger-color);
}

/* Error Message */
.error-message {
    background-color: #fee2e2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.success-message {
    background-color: #d1fae5;
    color: #059669;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.info-message {
    background-color: #dbeafe;
    color: #2563eb;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

/* Parte Detalle */
.parte-detalle-item {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 2fr;
    gap: 1rem;
    align-items: start;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .navbar-menu {
        flex-direction: column;
        width: 100%;
    }

    .nav-link {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filters-section {
        flex-direction: column;
    }

    .parte-detalle-item {
        grid-template-columns: 1fr;
    }

    .reportes-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: #d1fae5;
    color: #059669;
}

.badge-danger {
    background-color: #fee2e2;
    color: #dc2626;
}

.badge-warning {
    background-color: #fef3c7;
    color: #d97706;
}

.badge-info {
    background-color: #dbeafe;
    color: #2563eb;
}

/* 🆕 Animación para indicador de guardado automático en roster */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.saving-indicator {
    z-index: 10;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* 🆕 Estilos para Roster Continuo con Scroll Horizontal */
.roster-calendar {
    scroll-behavior: smooth;
}

.roster-calendar > div {
    /* Contenedor de scroll con barras personalizadas */
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling en iOS */
}

.roster-calendar > div::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}

.roster-calendar > div::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

.roster-calendar > div::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
}

.roster-calendar > div::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Hacer las celdas del roster más touch-friendly */
.roster-cell-display {
    min-width: 48px; /* Tamaño mínimo recomendado para touch targets */
    min-height: 40px;
}

/* Animación de hover suave para las celdas */
.roster-cell {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.roster-cell:active {
    transform: scale(0.95);
}

/* Resaltar el día actual con una animación sutil */
.roster-date-header[data-es-hoy="true"] {
    animation: highlightToday 2s ease-in-out infinite;
}

@keyframes highlightToday {
    0%, 100% {
        box-shadow: 0 0 0 rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
    }
}

/* ============================================================================
   RESPONSIVE DESIGN - Media Queries
   ============================================================================ */

/* Bot\u00f3n hamburguesa (oculto por defecto) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.5rem;
}

/* Tablets y pantallas medianas (\u2264 1024px) */
@media (max-width: 1024px) {
    .navbar {
        padding: 1rem 1.5rem;
    }
    
    .main-content {
        padding: 1.5rem;
    }
    
    /* Reducir gap en menu */
    .navbar-menu {
        gap: 0.25rem;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Tablets peque\u00f1as y m\u00f3viles grandes (\u2264 768px) */
@media (max-width: 768px) {
    /* Navbar responsive */
    .navbar {
        flex-wrap: wrap;
        padding: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    /* Mostrar bot\u00f3n hamburguesa */
    .mobile-menu-toggle {
        display: block;
        order: 2;
    }
    
    .navbar-brand {
        order: 1;
        flex: 1;
    }
    
    .navbar-user {
        order: 3;
        flex-basis: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }
    
    /* Men\u00fa colapsable */
    .navbar-menu {
        order: 4;
        flex-basis: 100%;
        flex-direction: column;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        gap: 0;
    }
    
    .navbar-menu.active {
        max-height: 500px;
        margin-top: 1rem;
    }
    
    .nav-link {
        width: 100%;
        padding: 0.75rem 1rem;
        border-radius: 0.25rem;
    }
    
    /* Main content */
    .main-content {
        padding: 1rem;
    }
    
    /* Header ajustado */
    .view-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .view-header h2 {
        font-size: 1.5rem;
    }
    
    /* Stat cards en columna */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Tablas responsivas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 0.875rem;
    }
    
    /* Cards de contratos */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .card-body > div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Formularios */
    .form-grid,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 1rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Roster responsivo */
    .roster-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .roster-grid {
        min-width: 800px;
    }
    
    /* Botones en columna */
    .button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .button-group button,
    .button-group .btn {
        width: 100%;
    }
}

/* M\u00f3viles medianos (\u2264 640px) */
@media (max-width: 640px) {
    /* Login responsive */
    .login-box {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    /* Reducir tama\u00f1os de fuente */
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Botones m\u00e1s grandes para touch */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        min-height: 44px;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Cards compactos */
    .card {
        padding: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    /* Inputs m\u00e1s grandes */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px; /* Evita zoom en iOS */
        min-height: 44px;
        padding: 0.625rem;
    }
    
    /* Modal full screen en m\u00f3viles */
    .modal {
        padding: 0;
    }
    
    .modal-content {
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }
    
    /* Navbar compacto */
    .navbar {
        padding: 0.75rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar-brand i {
        font-size: 1.25rem;
    }
}

/* M\u00f3viles peque\u00f1os (\u2264 480px) */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem 0.5rem;
    }
    
    /* Stat cards m\u00e1s compactos */
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    /* Formularios compactos */
    .form-group {
        margin-bottom: 1rem;
    }
    
    label {
        font-size: 0.875rem;
    }
    
    /* Roster muy compacto */
    .roster-grid {
        min-width: 600px;
        font-size: 0.75rem;
    }
    
    .roster-cell {
        min-height: 32px;
        padding: 0.25rem;
    }
    
    /* Tablas compactas */
    table {
        font-size: 0.8125rem;
    }
    
    th, td {
        padding: 0.5rem 0.25rem;
    }
}

/* Landscape mode para m\u00f3viles */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 100vh;
    }
    
    .navbar-menu.active {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Imprimir - ocultar elementos de navegaci\u00f3n */
@media print {
    .navbar,
    .mobile-menu-toggle,
    .view-header button,
    .btn,
    button {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    table {
        page-break-inside: avoid;
    }
}

/* Utilidades responsive */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}
