/* ==============================================================================
   ESTILOS PRINCIPALES - SISTEMA ADMINISTRATIVO DE CITAS Y NEGOCIO
   Diseño Mobile-First, Adaptativo de 320px a 4K, Glassmorphism & UI Moderna
   ============================================================================== */

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

:root {
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Colores Principales */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;

    /* Superficies y Fondos */
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* Sombras Elevadas */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --header-height: 64px;
    --radius-lg: 14px;
    --radius-md: 10px;
}

/* ------------------------------------------------------------------------------
   Base & Reset
   ------------------------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-size: clamp(0.9rem, 0.85rem + 0.25vw, 1.05rem);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.4rem, 1.2rem + 1vw, 2.2rem); }
h2 { font-size: clamp(1.2rem, 1rem + 0.8vw, 1.8rem); }
h3 { font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.4rem); }

/* ------------------------------------------------------------------------------
   Layout Estructura: Wrapper, Sidebar, Contenido
   ------------------------------------------------------------------------------ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Escritorio */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: #f8fafc;
    flex-shrink: 0;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 1040;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 0.75rem;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    text-decoration: none;
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 1.15rem;
}

.sidebar-logo i {
    font-size: 1.5rem;
    color: #818cf8;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.menu-category {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.25rem;
    font-weight: 700;
}

.menu-item {
    margin-bottom: 0.25rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.85rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s ease;
}

.menu-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    color: #94a3b8;
    transition: color 0.2s ease;
}

.menu-link:hover {
    color: #ffffff;
    background-color: var(--bg-sidebar-hover);
}

.menu-link:hover i {
    color: #818cf8;
}

.menu-link.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.menu-link.active i {
    color: #ffffff;
}

/* Contenedor Principal */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Previene desbordamiento en Flexbox */
}

/* Navbar Superior */
.app-navbar {
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1rem, 2vw, 2rem);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.navbar-brand-mobile {
    display: none;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 1.1rem;
    color: #0f172a;
    text-decoration: none;
}

/* Contenido Principal de Páginas */
.app-content {
    flex-grow: 1;
    padding: clamp(1rem, 2vw, 2.2rem);
    max-width: 1920px;
    width: 100%;
    margin: 0 auto;
}

/* ------------------------------------------------------------------------------
   Tarjetas & Widgets Dashboard (Ultra-Adaptables)
   ------------------------------------------------------------------------------ */
.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 1.5vw, 1.4rem);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-value {
    font-family: var(--font-primary);
    font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.85rem);
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
    margin-bottom: 0.2rem;
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Contenedor tipo Card Moderno */
.card-modern {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header-modern {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-body-modern {
    padding: clamp(1rem, 1.5vw, 1.5rem);
}

/* ------------------------------------------------------------------------------
   Tablas Responsive & Usabilidad
   ------------------------------------------------------------------------------ */
.table-responsive-custom {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.table-modern th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table-modern td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    vertical-align: middle;
}

.table-modern tr:hover td {
    background-color: #f8fafc;
}

/* ------------------------------------------------------------------------------
   Badges de Estado
   ------------------------------------------------------------------------------ */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 9999px;
    letter-spacing: 0.02em;
    text-transform: capitalize;
}

.badge-scheduled { background-color: var(--primary-light); color: var(--primary); }
.badge-confirmed { background-color: var(--info-light); color: #0891b2; }
.badge-completed { background-color: var(--success-light); color: #059669; }
.badge-cancelled { background-color: var(--danger-light); color: #dc2626; }
.badge-no_show   { background-color: #f1f5f9; color: #64748b; }

/* ------------------------------------------------------------------------------
   Botones & Controles Táctiles (Mínimo 44px)
   ------------------------------------------------------------------------------ */
.btn {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    padding: 0.55rem 1.1rem;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.form-control, .form-select {
    min-height: 42px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.92rem;
    padding: 0.5rem 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

/* ------------------------------------------------------------------------------
   FullCalendar Overrides & Mejoras
   ------------------------------------------------------------------------------ */
.fc {
    font-family: var(--font-body);
}

.fc .fc-toolbar-title {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.35rem) !important;
}

.fc .fc-button-primary {
    background-color: #ffffff !important;
    border-color: var(--border-color) !important;
    color: var(--text-main) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm) !important;
}

.fc .fc-button-primary:hover {
    background-color: #f1f5f9 !important;
}

.fc .fc-button-active {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
}

.fc-event {
    border-radius: 6px !important;
    padding: 2px 5px !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* ------------------------------------------------------------------------------
   Ticket Imprimible & Comprobante (POS Style)
   ------------------------------------------------------------------------------ */
.ticket-wrapper {
    max-width: 420px;
    margin: 1.5rem auto;
    background: #ffffff;
    padding: 2rem 1.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-family: 'Courier New', Courier, monospace;
}

.ticket-header {
    text-align: center;
    border-bottom: 2px dashed #cbd5e1;
    padding-bottom: 1.2rem;
    margin-bottom: 1.2rem;
}

.ticket-header h4 {
    font-family: var(--font-primary);
    margin-bottom: 0.25rem;
    font-weight: 800;
}

.ticket-items {
    border-bottom: 2px dashed #cbd5e1;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.ticket-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.ticket-row.total {
    font-weight: bold;
    font-size: 1.15rem;
    margin-top: 0.5rem;
}

@media print {
    body {
        background: #ffffff !important;
        padding: 0 !important;
    }
    .no-print {
        display: none !important;
    }
    .ticket-wrapper {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0.5rem !important;
    }
}

/* ------------------------------------------------------------------------------
   Responsive Breakpoints: Mobile (<992px)
   ------------------------------------------------------------------------------ */
@media (max-width: 991.98px) {
    .app-sidebar {
        display: none; /* Se oculta el sidebar regular, se usa Offcanvas en móvil */
    }
    .navbar-brand-mobile {
        display: flex;
    }
    .app-content {
        padding: 1rem 0.75rem;
    }
    .stat-card {
        padding: 1rem;
    }
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Pantallas Extra Pequeñas (<= 380px) */
@media (max-width: 380px) {
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    .card-header-modern {
        padding: 0.85rem 1rem;
    }
    .table-modern td, .table-modern th {
        padding: 0.65rem 0.75rem;
    }
}
