/* ===============================
   TOKENS / BASE VISUAL
================================= */
:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #eef4ff;
    --line: #dbe4f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning-bg: #fff7ed;
    --warning-border: #fdba74;
    --warning-text: #9a3412;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.04);
    --radius: 22px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --container: 1240px;
}

/* ===============================
   RESET / BASE
================================= */
html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(180deg, #f5f7fb 0%, #eef3f9 100%);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
    height: auto;
}

/* ===============================
   CONTENEDOR / LAYOUT
================================= */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 22px 18px;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(180deg, #f5f7fb 0%, #eef3f9 100%);
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 26px;
}

/* ===============================
   SIDEBAR GLOBAL
================================= */
.app-sidebar {
    width: 240px;
    background: #edf3ff;
    border-right: 1px solid #dbe4f0;
    padding: 26px 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    flex-shrink: 0;
    min-height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    font-weight: 800;
    font-size: 22px;
    color: #244aa5;
    line-height: 1.1;
}

.sidebar-logo {
    max-height: 38px;
    max-width: 120px;
    object-fit: contain;
    display: block;
    background: #fff;
    border-radius: 10px;
    padding: 4px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 13px 14px;
    border-radius: 14px;
    color: #475569;
    font-weight: 700;
    transition: .18s ease;
}

.sidebar-link:hover {
    background: #e6efff;
    color: #1d4ed8;
}

.sidebar-link.active {
    background: #dbeafe;
    color: #2563eb;
}

.sidebar-link.locked {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(.15);
}

.sidebar-spacer {
    margin-top: auto;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #dbe4f0;
    color: #b91c1c;
    font-weight: 800;
}

/* ===============================
   MOBILE TOPBAR + SIDEBAR DRAWER
================================= */
.mobile-topbar-global {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* ===============================
   CARDS / BLOQUES
================================= */
.page-card,
.dashboard-card,
.form-card {
    background: var(--surface);
    border-radius: 28px;
    padding: 26px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.card-soft,
.mini-card,
.chart-card,
.panel-card,
.turnos-card,
.turno-mobile-card,
.stat-card,
.summary-box,
.info-box,
.calendar-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}

/* ===============================
   TITULOS
================================= */
h1 {
    margin: 0 0 8px;
    font-size: 32px;
    line-height: 1.15;
    color: var(--text);
}

h2 {
    margin: 0 0 14px;
    font-size: 22px;
    line-height: 1.2;
    color: var(--text);
}

h3 {
    margin: 0 0 10px;
    font-size: 18px;
    line-height: 1.25;
}

.subtitle,
.page-subtitle {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 15px;
}

/* ===============================
   DASHBOARD GRID / ACCESOS
================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 24px;
    margin-bottom: 28px;
}

.dashboard-box {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px 18px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.dashboard-box:hover {
    transform: translateY(-3px);
    border-color: #bfdbfe;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.10);
}

.dashboard-box .icon {
    font-size: 28px;
    line-height: 1;
}

.dashboard-box .title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    text-align: left;
}

.dashboard-box.disabled-box {
    pointer-events: none;
    opacity: 0.45;
    filter: grayscale(0.25);
    position: relative;
}

.dashboard-box.disabled-box::after {
    content: 'Bloqueado';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #991b1b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
}

/* ===============================
   STATS
================================= */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.stat-box,
.stat-card {
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-md);
    padding: 22px 18px;
    min-height: 115px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-soft);
    text-align: center;
    border: 1px solid var(--line);
}

.stat-number {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}

.money {
    white-space: nowrap;
}

/* ===============================
   BANNERS / ALERTAS
================================= */
.restriction-banner {
    margin-top: 22px;
    margin-bottom: 22px;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning-text);
    border-radius: 16px;
    padding: 14px 16px;
    line-height: 1.5;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.alert.success {
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===============================
   FORMULARIOS
================================= */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 7px;
    color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.form-actions.full-width {
    grid-column: 1 / -1;
}

/* ===============================
   FILTROS
================================= */
.filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}

.filters input,
.filters select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: white;
    font-size: 14px;
}

/* ===============================
   BOTONES
================================= */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-danger-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.2s ease, background 0.2s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger,
.btn-danger-small {
    background: var(--danger);
    color: white;
}

.btn-danger:hover,
.btn-danger-small:hover {
    background: var(--danger-dark);
}

.btn-danger-small {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
}

.btn-link-clean {
    text-decoration: none;
}

/* ===============================
   TABLAS
================================= */
.table-responsive,
.table-wrap {
    overflow-x: auto;
    border-radius: 14px;
}

.modern-table,
.turnos-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    background: white;
}

.modern-table thead,
.turnos-table thead {
    background: #eff6ff;
}

.modern-table th,
.modern-table td,
.turnos-table th,
.turnos-table td {
    padding: 13px 14px;
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

.modern-table th,
.turnos-table th {
    color: #1f2937;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 13px;
}

.modern-table td,
.turnos-table td {
    color: #374151;
}

.modern-table tbody tr,
.turnos-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
}

.modern-table tbody tr:hover,
.turnos-table tbody tr:hover {
    background: #f9fafb;
}

/* ===============================
   TURNOS / LISTADOS
================================= */
.hora-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 14px;
}

.cliente-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cliente-main,
.profesional-name,
.turno-mobile-value {
    font-weight: 700;
    color: var(--text);
}

.cliente-phone,
.turno-mobile-label {
    color: var(--muted);
    font-size: 13px;
}

.turnos-card,
.turno-mobile-card {
    overflow: hidden;
}

.turnos-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.turnos-card-header h2 {
    margin: 0;
    font-size: 20px;
}

.turnos-card-header .mini-info {
    color: var(--muted);
    font-size: 14px;
}

.mobile-cards {
    display: none;
    gap: 14px;
    flex-direction: column;
}

.turno-mobile-card {
    padding: 16px;
}

.turno-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.turno-mobile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

/* ===============================
   EMPTY STATE
================================= */
.empty-state,
.empty-state-box {
    background: #f9fafb;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

.empty-state-box .emoji {
    font-size: 34px;
    margin-bottom: 10px;
}

.empty-state-box h3 {
    margin: 0 0 8px;
    font-size: 22px;
}

.empty-state-box p {
    margin: 0;
    color: var(--muted);
}

/* ===============================
   CALENDARIO
================================= */
.calendar-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}

.calendar-card {
    padding: 16px;
    border-left: 5px solid var(--primary);
}

.calendar-date {
    font-weight: 700;
    margin-bottom: 6px;
}

.calendar-prof {
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

/* ===============================
   MODAL
================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 9999;
}

.modal {
    width: 100%;
    max-width: 520px;
    background: white;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal h3 {
    margin: 0 0 10px;
    font-size: 22px;
    color: var(--text);
}

.modal p {
    margin: 0 0 16px;
    color: #4b5563;
    font-size: 15px;
}

.modal .actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.popup-deuda {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    color: #111827;
}

/* ===============================
   LOGIN
================================= */
.login-card form {
    max-width: 360px;
    margin: 0 auto;
}

.login-card .form-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 18px;
}

.login-card label {
    font-weight: 700;
    margin-bottom: 6px;
    text-align: left;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 15px;
}

.login-card .form-actions {
    margin-top: 10px;
}

.login-card .btn-primary {
    width: 100%;
    padding: 13px;
    font-size: 16px;
}

/* ===============================
   RESPONSIVE GENERAL
================================= */
@media (min-width: 640px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .modal .actions {
        flex-direction: row;
        justify-content: flex-end;
    }
}

@media (min-width: 900px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .calendar-view {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .container {
        padding: 28px 22px;
    }

    .page-card,
    .dashboard-card,
    .form-card {
        padding: 30px;
    }
}

@media (min-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .calendar-view {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .table-wrap {
        display: none;
    }

    .mobile-cards {
        display: flex;
    }
}

@media (max-width: 380px) {
    .container {
        padding: 12px;
    }

    .page-card,
    .dashboard-card,
    .form-card,
    .modal {
        padding: 16px;
    }

    h1 {
        font-size: 24px;
    }

    .dashboard-box {
        min-height: 100px;
    }

    .stat-number {
        font-size: 24px;
    }
}

/* ===============================
   LEGACY NAVBAR OFF
================================= */
.topbar,
.topbar-custom,
.topbar-links {
    display: none !important;
}

/* Navbar pública de autogestión */
.navbar.public-navbar {
    display: block !important;
    width: 100%;
    max-width: 1240px;
    margin: 22px auto 0;
    padding: 0 18px;
    background: transparent;
    box-shadow: none;
    border: none;
}

.empresa-header-public {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #ffffff;
    border: 1px solid #dbe4f0;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    padding: 18px 22px;
    text-align: center;
}

.empresa-logo-public {
    height: 58px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 4px;
    flex-shrink: 0;
}

.empresa-nombre-public {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
    text-align: center;
}

@media (max-width: 640px) {
    .navbar.public-navbar {
        margin-top: 14px;
        padding: 0 14px;
    }

    .empresa-header-public {
        flex-direction: column;
        justify-content: center;
        gap: 10px;
        padding: 16px 14px;
        border-radius: 18px;
    }

    .empresa-logo-public {
        height: 52px;
        max-width: 150px;
        margin: 0 auto;
    }

    .empresa-nombre-public {
        font-size: 20px;
        text-align: center;
    }
}
/* ===============================
   RESPONSIVE SIDEBAR / DRAWER
================================= */
@media (max-width: 920px) {
    .mobile-topbar-global {
        position: sticky;
        top: 0;
        z-index: 1100;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 64px;
        padding: 12px 16px;
        background: #ffffff;
        border-bottom: 1px solid #dbe4f0;
        box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
    }

    .mobile-menu-toggle {
        width: 42px;
        height: 42px;
        border: 1px solid #dbe4f0;
        background: #f8fafc;
        color: #0f172a;
        border-radius: 12px;
        font-size: 22px;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }

    .mobile-topbar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        font-size: 16px;
        font-weight: 800;
        color: #244aa5;
    }

    .mobile-topbar-brand span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-topbar-logo {
        max-height: 34px;
        max-width: 90px;
        object-fit: contain;
        background: #fff;
        border-radius: 8px;
        padding: 4px;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1198;
        display: none;
    }

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

    .app-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 86vw;
        min-height: 100vh;
        z-index: 1199;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        border-right: 1px solid #dbe4f0;
        border-bottom: none !important;
        overflow-y: auto;
        padding-top: 20px;
    }

    .app-sidebar.mobile-open {
        transform: translateX(0);
    }

    .app-main {
        padding: 16px;
    }

    .sidebar-menu {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }

    .sidebar-link {
        flex: unset !important;
        width: 100%;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .sidebar-logout {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .sidebar-brand {
        font-size: 18px;
    }
}
/* ===============================
   FORM PRO (ALTA EMPRESA)
================================= */
.form-pro {
    margin-top: 20px;
}

.form-grid-pro {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.form-group input,
.form-group select {
    border-radius: 12px;
    padding: 12px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.btn-primary.big {
    padding: 14px 28px;
    font-size: 16px;
}

/* MOBILE */
@media (max-width: 768px) {
    .form-grid-pro {
        grid-template-columns: 1fr;
    }
}

/* ===== NOTIFICACIONES EMPRESA ===== */
.sidebar-notification-link {
    position: relative;
    justify-content: flex-start;
}
.sidebar-notification-badge {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(220,38,38,.24);
}


/* ===============================
   FIX URGENTE SUPERADMIN
   Ancho y estética sin contaminar CSS
================================= */
.app-shell > .container,
.app-shell > .page-wrap,
.app-shell > .sa-page {
    width: 100%;
    max-width: none !important;
    margin: 0 !important;
    padding: 26px 34px 40px !important;
    box-sizing: border-box;
}

.app-shell .page-card,
.app-shell .dashboard-card,
.app-shell .form-card,
.app-shell .emp-section-card,
.app-shell .cob-card,
.app-shell .cc-card {
    background: #fff;
    border: 1px solid #dbe4f0;
    border-radius: 28px;
    box-shadow: 0 10px 30px rgba(15,23,42,.06);
    box-sizing: border-box;
}

.emp-table-wrap,
.tabla-wrap,
.table-responsive,
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 18px;
}

.emp-tabla,
.modern-table,
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.emp-tabla thead,
.modern-table thead,
.table thead {
    background: #eff6ff;
}

.emp-tabla th,
.emp-tabla td,
.modern-table th,
.modern-table td,
.table th,
.table td {
    padding: 13px 14px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}

.emp-tabla th,
.modern-table th,
.table th {
    color: #1f2937;
    font-weight: 800;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: .25px;
    font-size: 12px;
}

.emp-tabla tbody tr:hover,
.modern-table tbody tr:hover,
.table tbody tr:hover {
    background: #f8fafc;
}

@media (max-width: 920px) {
    .app-shell > .container,
    .app-shell > .page-wrap,
    .app-shell > .sa-page {
        padding: 16px !important;
    }
}
