/* --- VARIABLES & THEME --- */
:root {
    /* Palette: Zinc & Indigo (Premium SaaS feel) */
    --color-bg-body: #f4f4f5;
    /* Zinc 100 */
    --color-bg-surface: #ffffff;
    --color-bg-sidebar: #0f172a;
    /* Slate 900 (Deep, rich dark) */

    --color-primary: #4f46e5;
    /* Indigo 600 */
    --color-primary-hover: #4338ca;
    /* Indigo 700 */
    --color-primary-light: #e0e7ff;
    /* Indigo 100 */

    --color-text-main: #27272a;
    /* Zinc 800 */
    --color-text-muted: #71717a;
    /* Zinc 500 */
    --color-border: #e4e4e7;
    /* Zinc 200 */

    --color-success: #10b981;
    --color-success-bg: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-bg: #fef3c7;
    --color-danger: #ef4444;
    --color-danger-bg: #fee2e2;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Dimensions */
    --sidebar-width: 200px;
    /* Wider for better readability */
    --header-height: 64px;
}

/* --- RESET & BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--color-bg-body);
    color: var(--color-text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 0.925rem;
    width: 100%;
    display: flex;
}

/* --- FLEXBOX LAYOUT STRUCTURE --- */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-bg-sidebar);
    color: #94a3b8;
    /* Slate 400 */
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0) 100%);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    color: white;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: opacity 0.2s;
}

.sidebar-brand:hover {
    opacity: 0.9;
}

.brand-icon {
    font-size: 1.75rem;
    line-height: 1;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.brand-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: white;
}

.brand-subtitle {
    font-size: 0.625rem;
    font-weight: 400;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* SIDEBAR PROFILE */
.sidebar-profile {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.profile-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.profile-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #fca5a5;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(239, 68, 68, 0.08);
    transition: all 0.2s;
    width: fit-content;
    margin-left: -4px;
}

.profile-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.menu-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.menu-link.activo {
    background-color: rgba(79, 70, 229, 0.15);
    /* Primary transparent */
    color: #818cf8;
    /* Primary light text */
    border-left: 3px solid #818cf8;
    border-radius: 0.25rem 0.5rem 0.5rem 0.25rem;
}

.sidebar-footer {
    padding: 1rem;
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.8rem;
}

.sidebar-copyright {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    font-size: 0.65rem;
    color: #64748b;
    line-height: 1.4;
}

.copyright-text {
    margin-bottom: 0.25rem;
}

.copyright-creator {
    color: #94a3b8;
}

.copyright-creator strong {
    color: #cbd5e1;
    font-weight: 600;
}

/* MAIN CONTENT AREA */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Important for flex child with overflow */
    background: var(--color-bg-body);
}

.top-bar-mobile {
    display: none;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--color-border);
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
}

/* SCROLLABLE VIEWPORT */
.contenedor {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 2rem;
    position: relative;
}

.container-fluid {
    width: 100%;
    margin: 0 auto;
}

/* --- COMPONENTS --- */

/* Cards */
.card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-main);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
    box-shadow: 0 1px 2px 0 rgb(79 70 229 / 0.3);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    border-color: var(--color-border);
    color: var(--color-text-main);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #d4d4d8;
}

.btn-success {
    background-color: var(--color-success);
    color: white;
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text-main);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-control,
select {
    font-family: inherit;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

input[type="time"] {
    cursor: pointer;
}


/* Utilities */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-1 {
    flex: 1;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

/* --- MODALS --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.activo {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(to bottom, #fafafa, white);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-main);
}

.modal-header .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.25rem;
    opacity: 0.6;
    transition: all 0.2s;
}

.modal-header .btn:hover {
    opacity: 1;
    background-color: #f1f5f9;
    transform: rotate(90deg);
}

.modal-content form {
    padding: 2rem;
    overflow-y: auto;
    max-height: calc(90vh - 150px);
}

.modal-content>p {
    padding: 2rem;
}

.modal-content form>div:last-child {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.modal-content form>div:last-child .btn {
    min-width: 100px;
}

.text-center {
    text-align: center;
}

/* --- RESPONSIVE --- */
/* --- RESPONSIVE --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.activo {
    opacity: 1;
    pointer-events: auto;
}

.barra-movil {
    display: none;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--color-border);
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    justify-content: space-between;
}

.btn-toggle-movil {
    background: none;
    border: none;
    color: var(--color-text-main);
    cursor: pointer;
}

.marca-movil {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.marca-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.marca-texto {
    font-weight: 800;
    font-size: 1.125rem;
    color: var(--color-primary);
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.movil-activo {
        transform: translateX(0);
    }

    .barra-movil {
        display: flex;
    }

    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .contenedor {
        padding: 1rem;
    }

    body {
        overflow-x: hidden;
        width: 100vw;
    }
}

/* --- MODERN DATA TABLES --- */
.table-container {
    overflow-x: auto;
    margin-top: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: white;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.data-table th {
    background-color: #f8fafc;
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background-color: #f8fafc;
}

/* --- BADGES --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #e0f2fe;
    color: #075985;
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
}

/* --- AVATARS --- */
.avatar-text {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.employee-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.employee-name-container {
    display: flex;
    flex-direction: column;
}

.employee-name {
    font-weight: 600;
    color: var(--color-text-main);
}

/* --- SEARCH REFINEMENT --- */
.buscador-empleados {
    display: flex;
    gap: 0.5rem;
    background: white;
    padding: 0.25rem;
    border-radius: 0.625rem;
    border: 1px solid var(--color-border);
    max-width: 400px;
    width: 100%;
}

.buscador-empleados input {
    border: none !important;
    padding: 0.5rem 0.75rem;
    flex: 1;
    font-size: 0.875rem;
    background: transparent;
}

.buscador-empleados input:focus {
    box-shadow: none !important;
}

.buscador-empleados .btn {
    padding: 0.5rem 1rem;
}

/* --- MODAL MODERNO REFINEMENTS --- */
.modal-moderno-content {
    max-width: 550px !important;
}

.modal-moderno-body {
    padding: 1.5rem 2rem;
}

.modal-moderno-footer {
    padding: 1.25rem 2rem;
    background: #f8fafc;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* --- STAT CARDS (DASHBOARD/REPORTS) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue {
    background: #eff6ff;
    color: #3b82f6;
}

.stat-icon-green {
    background: #f0fdf4;
    color: #22c55e;
}

.stat-icon-amber {
    background: #fffbeb;
    color: #f59e0b;
}

.stat-icon-red {
    background: #fef2f2;
    color: #ef4444;
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-main);
}

/* --- TABS (SEGMENTED CONTROL) --- */
.tab-group {
    display: inline-flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: 0.75rem;
    gap: 0.25rem;
}

.tab-item {
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s;
}

.tab-item:hover {
    color: var(--color-text-main);
}

.tab-item.active {
    background: white;
    color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- MODERN ALERT MODAL --- */
.modal-alert {
    max-width: 400px !important;
    text-align: center;
}

.modal-alert .modal-header {
    border-bottom: none;
    padding-bottom: 0.5rem;
    justify-content: center;
}

.modal-alert .modal-content {
    padding: 1.5rem;
}

.alert-icon-container {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
    font-size: 2rem;
    animation: alertIconPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes alertIconPop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.alert-icon-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.alert-icon-error {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.alert-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-main);
    margin-bottom: 0.75rem;
}

.alert-message {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.alert-footer {
    display: flex;
    justify-content: center;
}

.alert-footer .btn {
    min-width: 120px;
}

/* --- MODERN FORM REFINEMENTS --- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    /* Slate 600 */
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-label svg,
.form-label span.icon {
    font-size: 1rem;
    opacity: 0.8;
}

.form-control {
    border: 1.5px solid var(--color-border);
    background-color: #f8fafc;
    /* Slate 50 */
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--color-text-main);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:hover {
    border-color: #cbd5e1;
}

.form-control:focus {
    background-color: white;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-light);
}

/* Specific styling for select to look more premium */
select.form-control {
    padding-right: 2.5rem;
}

/* Divider for forms */
.form-divider {
    height: 1px;
    background: var(--color-border);
    margin: 1.5rem 0;
    opacity: 0.5;
}