﻿:root {
    --color-primary: #1d71b8;
    --color-primary-dark: #155a94;
    --color-secondary: #009d45;
    --color-secondary-dk: #007a35;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    background-color: #f4f6fb;
    color: #333;
    margin: 0;
}

.label-titulo {
    font-size: 12px
}

/* ── Layout ── */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left .3s;
}

    .main-content.expanded {
        margin-left: var(--sidebar-collapsed);
    }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--color-primary) 0%, #134e80 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width .3s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

    .sidebar.collapsed {
        width: var(--sidebar-collapsed);
    }

/* ── Sidebar Header (perfil de usuario) ── */
.sidebar-header {
    padding: 20px 15px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    text-align: center;
}

    .sidebar-header .user-photo {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        object-fit: cover;
        border: 3px solid rgba(255,255,255,.4);
        margin-bottom: 10px;
    }

    .sidebar-header .user-photo-placeholder {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        background: rgba(255,255,255,.2);
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 10px;
        font-size: 2rem;
    }

    .sidebar-header .user-name {
        font-weight: 600;
        font-size: .95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-header .user-role {
        font-size: .75rem;
        opacity: .75;
    }

    .sidebar-header .user-puesto {
        font-size: .78rem;
        opacity: .85;
        margin-top: 2px;
    }

/* ── Sidebar Nav ── */
.sidebar-nav {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    flex: 1;
}

    .sidebar-nav .nav-section {
        font-size: .68rem;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: rgba(255,255,255,.5);
        padding: 12px 20px 4px;
        white-space: nowrap;
        overflow: hidden;
    }

    .sidebar-nav .nav-item a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 20px;
        color: rgba(255,255,255,.85);
        text-decoration: none;
        border-left: 3px solid transparent;
        transition: background .2s, border-color .2s, color .2s;
        white-space: nowrap;
        overflow: hidden;
    }

        .sidebar-nav .nav-item a:hover {
            background: rgba(255,255,255,.1);
            color: #fff;
        }

        .sidebar-nav .nav-item a.active {
            background: rgba(255,255,255,.15);
            border-left-color: var(--color-secondary);
            color: #fff;
            font-weight: 600;
        }

        .sidebar-nav .nav-item a i {
            font-size: 1.1rem;
            min-width: 22px;
        }

    .sidebar-nav .nav-label {
        transition: opacity .2s;
    }

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role,
.sidebar.collapsed .user-puesto {
    opacity: 0;
    pointer-events: none;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e0e4ed;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

    .topbar .btn-toggle {
        background: none;
        border: none;
        cursor: pointer;
        color: var(--color-primary);
        font-size: 1.3rem;
        padding: 5px 10px;
    }

    .topbar .page-title {
        font-size: 1.05rem;
        font-weight: 600;
        color: #333;
        margin: 0;
    }

    .topbar .topbar-right {
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 12px;
    }

/* ── Page Content ── */
.page-content {
    padding: 12px;
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    margin-bottom: 1.5rem;
}

.card-header {
    background: #fff;
    border-bottom: 2px solid #f0f3f8;
    border-radius: 10px 10px 0 0 !important;
    padding: 14px 20px;
    font-weight: 600;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
    margin-bottom: 1rem;
}

    .stat-card.blue {
        background: linear-gradient(135deg, var(--color-primary), #2196f3);
    }

    .stat-card.green {
        background: linear-gradient(135deg, var(--color-secondary), #4caf50);
    }

    .stat-card.orange {
        background: linear-gradient(135deg, #f57c00, #ffb300);
    }

    .stat-card.red {
        background: linear-gradient(135deg, #c62828, #e53935);
    }

    .stat-card .stat-icon {
        font-size: 2.2rem;
        opacity: .85;
    }

    .stat-card .stat-num {
        font-size: 2rem;
        font-weight: 700;
        line-height: 1;
    }

    .stat-card .stat-lbl {
        font-size: .8rem;
        opacity: .9;
    }

/* ── Buttons ── */
.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

    .btn-primary:hover {
        background-color: var(--color-primary-dark);
        border-color: var(--color-primary-dark);
    }

.btn-success {
    background-color: var(--color-secondary);
    border-color: var(--color-secondary);
}

    .btn-success:hover {
        background-color: var(--color-secondary-dk);
        border-color: var(--color-secondary-dk);
    }

/* ── Tables ── */
.table thead th {
    background-color: #f0f4fb;
    color: var(--color-primary);
    font-weight: 600;
    border-bottom: 2px solid #d0daf0;
}

.table-hover tbody tr:hover {
    background-color: #f5f8ff;
}

/* ── Badges de estado ── */
.badge-pendiente {
    background-color: #fff3cd;
    color: #856404;
}

.badge-aprobado {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-rechazado {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-cancelado {
    background-color: #f3f4f6;
    color: #374151;
}

/* ── Forms ── */
.form-label {
    font-weight: 500;
    color: #444;
    margin-bottom: .3rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 .2rem rgba(29,113,184,.15);
}

.field-validation-error {
    color: #dc3545;
    font-size: .8rem;
}

/* ── Photo preview ── */
.photo-preview {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-primary);
}

/* ── Overlay — controlled entirely by JS (.visible class) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    transition: opacity .25s ease;
}

    .sidebar-overlay.visible {
        display: block;
    }

/* ── Body: block scroll while sidebar open on mobile ── */
body.sidebar-open {
    overflow: hidden;
    touch-action: none;
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        transition: transform .3s ease;
        padding-top: max(0px, env(safe-area-inset-top));
    }

        .sidebar.open {
            transform: translateX(0);
            box-shadow: 4px 0 24px rgba(0,0,0,.3);
        }

    .main-content,
    .main-content.expanded {
        margin-left: 0;
    }

    .topbar {
        padding-top: max(0px, env(safe-area-inset-top));
    }

    /* Prevent topbar title from overflowing into avatar area */
    .topbar .page-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100vw - 160px);
        font-size: .9rem;
    }

    /* Touch-friendly nav links */
    .sidebar-nav .nav-item > a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Horizontal scroll on wide tables */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Small phones (≤480px) ── */
@media (max-width: 480px) {
    .page-content {
        padding: 8px;
    }

    .card-body {
        padding: .75rem;
    }

    .card-header {
        padding: .6rem 1rem;
        font-size: .9rem;
    }

    .stat-card {
        padding: 12px 14px;
    }

        .stat-card .stat-num {
            font-size: 1.4rem;
        }

    /* Hide username text — keep only avatar icon */
    .topbar-username {
        display: none !important;
    }

    /* Stack form button rows */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}
