/* Diseño Premium CSS - FactPY Agenda */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --font-primary: 'Inter', sans-serif;
    
    /* Paleta de Colores Lila / Indigo Premium */
    --color-bg: #f8fafc;           /* Fondo gris azulado ultra limpio */
    --color-surface: #ffffff;      /* Blanco puro para tarjetas */
    --color-sidebar-bg: #f1f3f9;   /* Fondo de sidebar lila suave */
    --color-primary: #4f46e5;      /* Indigo/Lila moderno original */
    --color-primary-hover: #4338ca;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-text-main: #0f172a;    /* Slate 900 original */
    --color-text-muted: #64748b;   /* Slate 500 original */
    --color-border: #e2e8f0;       /* Slate 200 original */
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 18px rgba(79, 70, 229, 0.05), 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 10px 30px rgba(79, 70, 229, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
}

/* Layouts Generales */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header / Navbar */
header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo span {
    color: var(--color-text-main);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    list-style: none;
}

/* Botones Premium */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--color-surface);
    color: var(--color-text-main);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg);
    border-color: var(--color-text-muted);
}

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

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

/* Tarjetas y Contenedores */
.card {
    background-color: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Formularios Elegantes */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--color-text-main);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Estilos de Landing/Bienvenida */
.hero-section {
    text-align: center;
    padding: 5rem 1rem;
    background: radial-gradient(circle at 50% 50%, rgba(79, 70, 229, 0.05) 0%, transparent 80%);
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
}

/* Vistas de Autenticación (Login/Registro) */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
}

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

.auth-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.auth-header p {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Alertas de Notificación */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background-color: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: visible;
}

/* Sidebar Collapsed Styles */
.sidebar.collapsed {
    width: 72px;
    padding: 1.25rem 0.5rem;
    align-items: center;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-user-info-text,
.sidebar.collapsed .sidebar-link span:not(.sidebar-icon) {
    display: none !important;
}
.sidebar.collapsed .logo {
    font-size: 1.5rem;
}
.sidebar.collapsed .logo-container {
    justify-content: center;
}
/* Ocultar el collapse-btn cuando está colapsado */
.sidebar.collapsed .collapse-sidebar-btn {
    display: none;
}
.sidebar.collapsed nav {
    width: 100%;
    align-items: center;
}
.sidebar.collapsed .sidebar-menu {
    align-items: center;
    width: 100%;
}
.sidebar.collapsed .sidebar-link {
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    padding: 0;
}
/* Cuando colapsado: el perfil solo muestra el avatar */
.sidebar.collapsed #btn-profile-popover {
    justify-content: center;
    padding: 0.4rem;
}
.sidebar.collapsed #btn-profile-popover > div {
    flex: unset;
}
.sidebar.collapsed #btn-profile-popover > div > div:last-child,
.sidebar.collapsed #profile-chevron {
    display: none !important;
}
.sidebar.collapsed .sidebar-user-info {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.collapse-sidebar-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    transition: all var(--transition-fast);
    outline: none;
    padding: 0;
}
.collapse-sidebar-btn:hover {
    color: var(--color-primary);
    background-color: rgba(79, 70, 229, 0.08);
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--color-text-main);
    font-weight: 500;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-link:hover {
    background-color: rgba(79, 70, 229, 0.08);
    color: var(--color-primary);
}

.sidebar-link.active {
    background-color: var(--color-primary) !important;
    color: #ffffff !important;
    font-weight: 600;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 2.5rem;
    overflow-y: auto;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-info {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
}

.grid-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* Mobile Menu Helpers */
.mobile-navbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 998;
}
.mobile-menu-toggle {
    background: transparent;
    border: none;
    padding: 0.5rem;
    font-size: 1.4rem;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s;
    outline: none;
}
.mobile-menu-toggle:active {
    background-color: #f1f5f9;
}
.mobile-logo {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.1rem;
}
.mobile-logo span {
    color: var(--color-text);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
}
.sidebar-backdrop.active {
    display: block;
}

@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .mobile-navbar {
        display: flex;
    }
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 1000;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
    }
    .sidebar.active {
        left: 0;
    }
    .main-content {
        padding: 1.5rem 1rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.25rem;
    }
    .page-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    .page-header > div:last-child > .form-group {
        flex: 1 1 140px;
        width: 100%;
    }
    .page-header > div:last-child > .form-group > select,
    .page-header > div:last-child > .form-group > input {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 768px) {
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }
    .modal-content {
        width: 95% !important;
        margin: 1rem;
    }
    header {
        padding: 0.75rem 0;
    }
    .nav-container {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        width: 100%;
    }
    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem !important;
        padding: 0;
    }
    .nav-links li {
        flex: 1 1 auto;
        max-width: calc(50% - 0.25rem); /* Dos botones por fila */
    }
    .nav-links li:only-child {
        max-width: 100%;
    }
    .nav-links .btn {
        width: 100%;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem;
    }
    .nav-links .badge {
        display: none !important; /* Ocultar badge de empresa en móvil para ahorrar espacio */
    }
    .auth-wrapper {
        padding: 1rem 0.5rem;
        min-height: calc(100vh - 140px);
    }
    .auth-card {
        padding: 1.75rem 1.25rem !important;
        margin: 0.5rem;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
    }
    .hero-section {
        padding: 3rem 1rem !important;
    }
    .hero-title {
        font-size: 2rem !important;
    }

    /* Timetable Table Responsive Card Layout */
    .timetable-table, 
    .timetable-table thead, 
    .timetable-table tbody, 
    .timetable-table th, 
    .timetable-table td, 
    .timetable-table tr { 
        display: block !important; 
    }
    .timetable-table thead {
        display: none !important;
    }
    .timetable-table tr {
        border-bottom: 2px solid var(--color-border) !important;
        padding: 1rem 0.5rem !important;
    }
    .timetable-table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.5rem 0 !important;
        border: none !important;
        text-align: right !important;
    }
    .timetable-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--color-text-muted);
        float: left;
        text-align: left;
    }
    .timetable-table td input[type="time"] {
        width: 120px !important;
        padding: 0.35rem 0.5rem !important;
    }
    .timetable-table td .break-inputs {
        justify-content: flex-end;
    }
}

/* Premium Top Header Layout */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--color-bg);
}

.top-header {
    height: 60px;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 997;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.top-header-clock {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.top-header-badge {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.top-header-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.top-header-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--color-primary);
    color: #ffffff;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.top-header-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.top-header-username {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text-main);
}

.top-header-user-branch {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

@media (max-width: 1024px) {
    .top-header {
        display: none !important;
    }
}

/* Utilidades Responsivas Adicionales */
.tabs-scrollable {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.5rem;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
}
.tabs-scrollable::-webkit-scrollbar {
    display: none; /* Safari/Chrome */
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem 0.75rem !important;
    }
}
