@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;800&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
    --primary: #1E3A5F;
    --primary-soft: rgba(30, 58, 95, 0.1);
    --secondary: #0F172A;
    --accent: #D4AF37;
    --accent-soft: rgba(212, 175, 55, 0.15);
    
    --bg: #F1F5F9;
    --bg-dark: #0F172A;
    --bg-alt: #1E293B;
    --white: #FFFFFF;
    
    --text: #334155;
    --text-muted: #64748B;
    --text-light: #94a3B8;
    --text-dark: #0F172A;
    --border: #E2E8F0;

    --font-heading: 'Playfair Display', serif;
    --font-body: 'DM Sans', sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);

    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--text-dark);
    font-weight: 700;
}

h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
h3 { font-size: clamp(1rem, 2.5vw, 1.25rem); }
h4 { font-size: clamp(0.9rem, 2vw, 1rem); }

p { font-size: clamp(0.85rem, 1.5vw, 1rem); }

/* ═══ SIDEBAR ═══ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100svh;
    background: var(--bg-dark);
    color: white;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 1005; /* Asegura que cubra el overlay y la topbar */
    transition: transform 0.3s ease;
}

.sidebar-logo {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo span {
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

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

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 1rem;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: #F87171;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-logout:hover {
    background: rgba(248, 113, 113, 0.1);
}

/* ═══ MAIN CONTENT ═══ */
.main-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100svh;
    background: var(--bg);
    max-width: 100vw;
    overflow-x: hidden;
}

/* ═══ STATS CARDS ═══ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }
.stat-icon.green { background: rgba(34, 197, 94, 0.1); color: #22C55E; }
.stat-icon.yellow { background: rgba(234, 179, 8, 0.1); color: #EAB308; }
.stat-icon.red { background: rgba(239, 68, 68, 0.1); color: #EF4444; }

.stat-info h4 {
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-change {
    font-size: 0.8rem;
    margin-top: 4px;
}

.stat-change.positive { color: #22C55E; }
.stat-change.negative { color: #EF4444; }

/* ═══ PAGE HEADER ═══ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ═══ CARDS ═══ */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-body {
    padding: 1.5rem;
}

/* ═══ SEARCH ═══ */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    border: 2px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 350px;
}

.search-bar input {
    border: none;
    background: none;
    outline: none;
    font-size: 0.9rem;
    width: 100%;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

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

table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #F8FAFC;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

tr:hover td {
    background: #F8FAFC;
}

/* ═══ STATUS BADGES ═══ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.confirmado { background: rgba(34, 197, 94, 0.1); color: #22C55E; }
.badge.pendiente { background: rgba(234, 179, 8, 0.1); color: #EAB308; }
.badge.urgente { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.badge.completado { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }

/* ═══ BUTTONS ═══ */
.btn {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

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

.btn-primary:hover {
    background: #2D4A6F;
}

.btn-success {
    background: #22C55E;
    color: white;
}

.btn-success:hover {
    background: #16A34A;
}

.btn-danger {
    background: #EF4444;
    color: white;
}

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

.btn-outline {
    border: 2px solid var(--border);
    background: transparent;
}

.btn-outline:hover {
    background: var(--bg);
}

/* ═══ FORMS ═══ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* ═══ GRID ═══ */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

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

/* ═══ PROGRESS BARS ═══ */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.green { background: #22C55E; }
.progress-fill.yellow { background: #EAB308; }
.progress-fill.red { background: #EF4444; }
.progress-fill.blue { background: #3B82F6; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
        padding-top: calc(60px + 1.5rem);
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2, .grid-4 {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .stat-card {
        padding: 1rem;
    }
}

/* ═══ MOBILE TOPBAR ═══ */
.mobile-topbar {
    display: none;
}

@media (max-width: 992px) {
    .mobile-topbar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-dark);
        color: white;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
        z-index: 1001;
    }
    .mobile-topbar span {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mobile-menu-btn {
        background: none;
        border: none;
        color: white;
        padding: 8px;
    }
    .main-content {
        padding-top: calc(60px + 1.5rem);
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1004; /* Ajustado para estar por encima de la topbar pero debajo del sidebar */
}

.sidebar-overlay.active {
    display: block;
}

@media (min-width: 993px) {
    .sidebar-overlay { display: none !important; }
}

/* ═══ UTILITIES ═══ */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }