@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root{
    --primary-color: #03999f;
    --primary-dark: #027b80;
    --primary-soft: #e6f7f8;
    --secondary-color: #0f172a;
    --info-color: #0ea5e9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-text: #0f172a;
    --muted-text: #64748b;
    --soft-bg: #f8fafc;
    --border-soft: #e2e8f0;
    --card-bg: rgba(255,255,255,.96);
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #111827 55%, #0b1220 100%);
    --shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.08);
    --shadow-medium: 0 18px 35px rgba(15, 23, 42, 0.12);
    --shadow-strong: 0 24px 50px rgba(15, 23, 42, 0.18);
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --sidebar-width: 290px;
}

*{ box-sizing: border-box; }

html, body{
    min-height: 100%;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(3, 153, 159, 0.12), transparent 32rem),
        linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
    color: var(--dark-text);
    overflow-x: hidden;
}

p {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.65;
    color: var(--muted-text);
}

a,
a:hover,
a:focus {
    color: inherit;
    text-decoration: none;
    transition: all 0.25s ease;
}

.wrapper{
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* -----------------------------------
   SIDEBAR
----------------------------------- */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040;
    background: var(--sidebar-bg);
    color: #fff;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 12px 0 30px rgba(15, 23, 42, 0.18);
    padding: 18px 16px 20px;
}

#sidebar.active{
    margin-left: calc(var(--sidebar-width) * -1);
}

#sidebar::-webkit-scrollbar{
    width: 6px;
}
#sidebar::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,.14);
    border-radius: 999px;
}

#dismiss {
    width: 38px;
    height: 38px;
    line-height: 38px;
    text-align: center;
    background: rgba(255,255,255,.08);
    color: #fff;
    cursor: pointer;
    border-radius: 12px;
    margin-left: auto;
    margin-bottom: 16px;
    z-index: 1050;
    transition: all 0.2s ease;
    display: none;
}

#sidebar.active #dismiss {
    display: block;
}


#dismiss:hover {
    background: rgba(255,255,255,.16);
    transform: scale(1.03);
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1030;
}

.overlay.active {
    display: block;
}

#sidebar .sidebar-header {
    text-align: center;
    padding: 8px 10px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 12px;
}

.logo-sidebar {
    width: 100%;
    max-width: 180px;
    max-height: 120px;
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
    background: #fff;
    padding: 8px;
}

.sidebar-brand-title{
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    margin-top: 14px;
    margin-bottom: 2px;
}

.sidebar-brand-subtitle{
    color: rgba(255,255,255,.7);
    font-size: .82rem;
}

.menu-section-title{
    color: rgba(255,255,255,.55);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 18px 12px 12px;
    font-weight: 700;
}

#sidebar ul.components {
    padding: 4px 0 0;
    margin: 0;
    list-style: none;
}

#sidebar ul li {
    margin-bottom: 8px;
}

#sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #e5e7eb;
    font-size: .96rem;
    font-weight: 600;
    position: relative;
}

#sidebar ul li a .menu-icon{
    width: 18px;
    min-width: 18px;
    text-align: center;
    font-size: 1rem;
}

#sidebar ul li a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    transform: translateX(4px);
}

#sidebar ul li.active > a,
#sidebar ul li > a.active,
a[aria-expanded="true"] {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), #22c1c7);
    box-shadow: 0 12px 25px rgba(3, 153, 159, 0.28);
}

#sidebar ul li.active > a::after,
#sidebar ul li > a.active::after{
    content: '';
    position: absolute;
    right: 10px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,.95);
}

#sidebar ul ul {
    margin-top: 8px;
    padding-left: 10px;
}

#sidebar ul ul li a {
    font-size: .9rem !important;
    padding: 11px 12px 11px 16px !important;
    background: rgba(255,255,255,.04);
    color: #dbeafe;
}

#sidebar ul ul li a:hover {
    background: rgba(255,255,255,.09);
}

/* -----------------------------------
   CONTENT + TOPBAR
----------------------------------- */
#content{
    width: 100%;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: all 0.3s ease;
    background: transparent;
}

#content.expanded{
    margin-left: 0;
}

.topbar{
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(226,232,240,.8);
    border-radius: 22px;
    padding: 12px 18px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 22px;
}

.menu-btn{
    border: none;
    background: linear-gradient(135deg, var(--primary-color), #22c1c7);
    color: #fff;
    padding: 10px 18px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(3, 153, 159, .22);
    transition: .2s ease;
}

.menu-btn:hover{
    transform: translateY(-1px);
    color: #fff;
}

.topbar-title{
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    font-size: 1.1rem;
}

.topbar-subtitle{
    color: #64748b;
    font-size: .86rem;
    margin: 0;
}

.page-container{
    background: transparent;
    border-radius: 22px;
}

/* USER DROPDOWN */
.user-dropdown-toggle{
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 8px 12px;
    transition: .2s ease;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}
.user-dropdown-toggle:hover{ background: #f8fafc; }
.user-avatar{
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid #dbeafe;
}
.user-avatar-placeholder{
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #22c1c7);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
}
.user-info{ line-height: 1.2; }
.user-name{ display: block; font-weight: 700; color: #0f172a; font-size: .95rem; }
.user-role{ display: block; font-size: .8rem; color: #64748b; }
.dropdown-menu{
    border: none; border-radius: 16px; padding: 10px; box-shadow: 0 18px 35px rgba(15, 23, 42, 0.12);
}
.dropdown-item{
    border-radius: 12px; padding: 10px 14px; font-weight: 600;
}
.dropdown-item:hover{ background: #f8fafc; }

/* -----------------------------------
   CARDS + GENERIC PANELS
----------------------------------- */
.card, .content-card, .stats-card, .chart-card, .history-card{
    border: none;
    border-radius: 22px;
    background: var(--card-bg);
    box-shadow: var(--shadow-soft);
}

.card:hover,
.stats-card:hover,
.history-card:hover{
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
}

.content-card .card-body,
.chart-card .card-body,
.stats-card .card-body{
    padding: 24px;
}

.page-hero{
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.96) 0%, rgba(3, 153, 159, 0.94) 100%),
        url('../img/Consultorio.jpeg') center/cover;
    border-radius: 24px;
    padding: 24px;
    color: #fff;
    box-shadow: 0 15px 35px rgba(3, 153, 159, 0.20);
    margin-bottom: 22px;
}
.page-hero h2{ font-size: 1.85rem; font-weight: 800; margin-bottom: 8px; }
.page-hero p{ margin-bottom: 0; color: rgba(255,255,255,0.88); }
.hero-badge,
.mini-badge,
.payment-note{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.12);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 700;
}
.mini-badge,
.payment-note{
    background: #eff6ff;
    color: var(--primary-dark);
}

.custom-breadcrumb{
    background: #eff6ff;
    border-radius: 14px;
    display: inline-flex;
    padding: 10px 14px;
    margin-bottom: 18px;
}
.breadcrumb{ margin-bottom: 0; }
.breadcrumb-item,
.breadcrumb-item.active{ font-weight: 700; color: var(--primary-dark); }

.section-top{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.section-title{ margin: 0; font-size: 1.2rem; font-weight: 800; color: var(--dark-text); }
.section-subtitle{ margin: 4px 0 0; color: var(--muted-text); font-size: .92rem; }

.filter-card, .table-card, .section-card{
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}
.filter-title, .section-card-title{
    font-size: 1rem;
    font-weight: 800;
    color: var(--dark-text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-card{ overflow: hidden; padding: 0; }
.table-toolbar{
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
    gap: 10px; padding: 16px 18px; background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border-soft);
}
.table-toolbar h5{ margin: 0; font-size: 1rem; font-weight: 800; color: var(--dark-text); }
.table-toolbar span{ color: var(--muted-text); font-size: .9rem; }
.table-responsive{ padding: 14px; }

.table th {
    min-width: 80px;
    white-space: nowrap;
}

/* -----------------------------------
   FORMS + BUTTONS
----------------------------------- */
.form-label{ font-weight: 700; color: var(--dark-text); margin-bottom: 8px; }
.form-control, .form-select{
    min-height: 48px; border-radius: 14px; border: 1px solid var(--border-soft); box-shadow: none !important;
}
.form-control:focus, .form-select:focus{
    border-color: #93c5fd; box-shadow: 0 0 0 0.15rem rgba(37,99,235,.12) !important;
}
.input-group-text{
    background: #fff;
    border: 1px solid var(--border-soft);
    border-right: none;
    border-radius: 14px 0 0 14px;
    color: var(--muted-text);
    min-width: 46px;
    justify-content: center;
}
.input-with-icon .form-control,
.input-with-icon .form-select{ border-left: none; border-radius: 0 14px 14px 0; }
.password-toggle-btn{
    border: 1px solid var(--border-soft); border-left: none; background: #fff; border-radius: 0 14px 14px 0;
    min-width: 54px; color: var(--muted-text);
}

.two-tone-button, .two-tone-button-two, .button-secondary, .button-color-tone, .button-consult-tone,
.btn-modern, .btn-register{
    position: relative; font-size: 15px; border-radius: 14px; cursor: pointer; transition: all .25s ease;
    font-weight: 700; padding: 11px 18px; border: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.two-tone-button, .btn-primary-modern, .btn-register, .menu-btn{
    background: linear-gradient(135deg, var(--primary-color), #22c1c7); color: #fff; box-shadow: 0 12px 24px rgba(3, 153, 159, 0.2);
}
.two-tone-button:hover, .btn-primary-modern:hover, .btn-register:hover{
    color: #fff; transform: translateY(-2px); box-shadow: 0 18px 30px rgba(3, 153, 159, 0.25);
}
.two-tone-button-two, .btn-success-modern{
    background: linear-gradient(135deg, #059669, #10b981); color: #fff; box-shadow: 0 12px 24px rgba(16,185,129,.2);
}
.two-tone-button-two:hover, .btn-success-modern:hover{ color: #fff; transform: translateY(-2px); }
.button-secondary, .btn-secondary-modern{
    background: #fff; color: #475569; border: 1px solid var(--border-soft); box-shadow: 0 10px 20px rgba(15,23,42,.06);
}
.button-secondary:hover, .btn-secondary-modern:hover{ color: #1e293b; background: #f8fafc; transform: translateY(-2px); }
.button-color-tone{ background: linear-gradient(135deg, #ef4444, #f87171); color: #fff; }
.button-consult-tone, .btn-warning-modern{ background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; }
.button-consult-tone:hover, .btn-warning-modern:hover, .button-color-tone:hover{ color:#fff; transform: translateY(-2px); }

.btn-outline-primary, .btn-outline-secondary{
    border-radius: 12px; font-weight: 700; padding: 10px 14px;
}

/* -----------------------------------
   TABLES / DATATABLES
----------------------------------- */
.custom-table, table.dataTable{
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
}
.datatable-shell{
    width: 100%;
}
.dataTables_wrapper{
    color: #334155;
}
.dataTables_wrapper .row{
    margin-left: 0;
    margin-right: 0;
}
.datatable-length,
.datatable-search,
.datatable-info,
.datatable-pagination{
    padding-left: 0;
    padding-right: 0;
}
.custom-table thead th,
table.dataTable thead th{
    background: linear-gradient(180deg, #eff6ff 0%, #e0f7fa 100%) !important;
    color: #0f3f57 !important;
    font-weight: 800 !important;
    border: none !important;
    padding: 14px 12px !important;
    font-size: .92rem;
    white-space: nowrap;
}
.custom-table thead th:first-child,
table.dataTable thead th:first-child{
    border-top-left-radius: 14px;
    border-bottom-left-radius: 14px;
}
.custom-table thead th:last-child,
table.dataTable thead th:last-child{
    border-top-right-radius: 14px;
    border-bottom-right-radius: 14px;
}
.custom-table tbody tr,
table.dataTable tbody tr{
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.custom-table tbody tr:hover,
table.dataTable tbody tr:hover{
    background: #f8feff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.09);
}
.custom-table tbody td,
table.dataTable tbody td{
    padding: 14px 12px !important;
    vertical-align: middle;
    border-top: 1px solid #f1f5f9 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    color: #334155;
    font-size: .93rem;
}
.custom-table tbody tr td:first-child,
table.dataTable tbody tr td:first-child{
    border-left: 1px solid #f1f5f9 !important;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}
.custom-table tbody tr td:last-child,
table.dataTable tbody tr td:last-child{
    border-right: 1px solid #f1f5f9 !important;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select{
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 8px 12px;
    background: #fff;
    box-shadow: none;
}
.dataTables_wrapper .dataTables_filter{
    text-align: right;
}
.dataTables_wrapper .dataTables_filter input{
    min-width: min(100%, 260px);
    min-height: 40px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center;
    padding-left: 40px;
}
.dataTables_wrapper .dataTables_length select{
    min-width: 86px;
    min-height: 40px;
}
.dataTables_wrapper .dataTables_info{
    color: #64748b;
    font-weight: 600;
    padding-top: 0 !important;
}
.dataTables_wrapper .dataTables_paginate{
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    padding-top: 0 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button{
    border: 1px solid var(--border-soft) !important;
    border-radius: 10px !important;
    background: #fff !important;
    color: #475569 !important;
    margin: 0 !important;
    padding: 7px 12px !important;
    font-weight: 700;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover{
    background: #eff6ff !important;
    color: var(--primary-dark) !important;
    border-color: #bae6fd !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current{
    background: linear-gradient(135deg, var(--primary-color), #22c1c7) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled{
    opacity: .45;
}
.dataTables_wrapper .dataTables_scroll{
    border-radius: 18px;
}
.dataTables_wrapper .dataTables_scrollHead{
    border-radius: 18px 18px 0 0;
}
.dataTables_scrollBody {
    overflow-y: auto !important;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #94dfe2 #f1f5f9;
}
.dataTables_scrollBody::-webkit-scrollbar { width: 8px; height: 8px; }
.dataTables_scrollBody::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 999px; }
.dataTables_scrollBody::-webkit-scrollbar-thumb { background: #94dfe2; border-radius: 999px; }
#nuevopago th, #nuevopago td { white-space: nowrap; }

@media (max-width: 767.98px){
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_paginate{
        justify-content: flex-start;
        text-align: left;
    }
    .dataTables_wrapper .dataTables_filter input{
        width: 100%;
        min-width: 100%;
    }
    .dataTables_wrapper .dataTables_paginate{
        flex-wrap: wrap;
    }
}

/* -----------------------------------
   STATUS / ACTIONS / HELPERS
----------------------------------- */
.badge-role, .badge-status, .status-badge{
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700;
}
.badge-admin{ background: #dbeafe; color: #1d4ed8; }
.badge-medico, .status-active, .badge-enabled{ background: #dcfce7; color: #166534; }
.status-inactive, .badge-disabled{ background: #fee2e2; color: #991b1b; }
.badge-neutral, .status-neutral{ background: #f1f5f9; color: #475569; }

.btn-action{
    width: 42px; height: 42px; border-radius: 12px; border: none; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem; transition: all .22s ease; text-decoration: none;
}
.btn-action:hover{ transform: translateY(-2px); }
.btn-action-schedule{ color:#fff; background: linear-gradient(135deg, var(--primary-color), #22c1c7); }
.btn-action-edit-schedule{ color:#475569; background:#fff; border:1px solid var(--border-soft); }
.btn-action-edit-data{ color:#fff; background: linear-gradient(135deg, #059669, #10b981); }
.actions-group, .action-group, .action-right{ display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
.action-right{ justify-content:flex-end; }
.search-actions{ display:flex; justify-content:flex-end; align-items:end; height:100%; }

/* -----------------------------------
   SPECIAL CARDS / EMPTY / LOGIN / REGISTER / HISTORY
----------------------------------- */
.empty-state{
    border: 1px dashed #cbd5e1; border-radius: 20px; background: #f8fafc; padding: 32px 20px; text-align: center; color: var(--muted-text);
}
.empty-state i{ font-size: 2.2rem; color: #94a3b8; margin-bottom: 12px; display:block; }
.history-card{ height:100%; overflow:hidden; position:relative; }
.history-card::before{ content:''; position:absolute; top:0; left:0; width:100%; height:5px; background: linear-gradient(135deg, var(--primary-color), #22c1c7); }
.history-card .card-body{ padding:22px; }
.history-card-title{ display:flex; align-items:center; gap:10px; font-size:1.05rem; font-weight:800; color:var(--dark-text); margin-bottom:16px; }
.history-icon{ width:42px; height:42px; border-radius:12px; background:#eff6ff; color:var(--primary-dark); display:flex; align-items:center; justify-content:center; font-size:1.15rem; }
.history-item{ margin-bottom:10px; color:#334155; line-height:1.5; }
.history-label{ color:var(--dark-text); font-weight:700; }
.history-footer{ margin-top:18px; display:flex; justify-content:flex-end; }

.design_body{
    background: linear-gradient(160deg, #0f172a 0%, var(--primary-color) 60%, #22c1c7 100%);
}
.register_text{ display:flex; align-items:center; justify-content:center; text-align:center; }
.register-wrapper{ background:#fff; border-radius:28px; overflow:hidden; box-shadow: var(--shadow-soft); }
.register-side, .login-side{
    height:100%; color:#fff; position:relative; display:flex; align-items:center; justify-content:center; padding:34px; overflow:hidden;
    background: linear-gradient(160deg, #0f172a 0%, var(--primary-color) 60%, #22c1c7 100%);
}
.register-side::before, .login-side::before,
.register-side::after, .login-side::after{
    content:''; position:absolute; border-radius:50%; background: rgba(255,255,255,.08);
}
.register-side::before, .login-side::before{ width:220px; height:220px; top:-50px; right:-50px; }
.register-side::after, .login-side::after{ width:180px; height:180px; bottom:-50px; left:-50px; }
.side-content{ position:relative; z-index:2; text-align:center; max-width:320px; }
.side-icon{ width:86px; height:86px; border-radius:24px; display:flex; align-items:center; justify-content:center; background: rgba(255,255,255,.12); margin:0 auto 20px; font-size:2rem; }
.side-title{ font-size:1.8rem; font-weight:800; margin-bottom:10px; }
.side-text{ color: rgba(255,255,255,.88); line-height:1.6; margin-bottom:18px; }
.side-list .item, .side-points .item{ display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:12px; background: rgba(255,255,255,.10); margin-bottom:10px; }
.side-list .item i, .side-points .item i{ color:#bfdbfe; }

/* -----------------------------------
   MODALS / TOAST / LOADER
----------------------------------- */
.modal-content{
    border:none; border-radius:24px; overflow:hidden; box-shadow: 0 20px 45px rgba(15,23,42,.18);
}
.modal-header{
    background: linear-gradient(135deg, #0f172a 0%, var(--primary-color) 100%);
    color:#fff; border-bottom:none; padding:18px 22px;
}
.modal-header .btn-close{ filter: brightness(0) invert(1); }
.modal-title{ font-weight:800; }
.modal-body{ padding:22px; background:#fff; }
.modal-footer{ border-top:1px solid var(--border-soft); padding:16px 22px; }
.toast{ border:none; border-radius:16px; box-shadow: 0 12px 28px rgba(15,23,42,.15); }
.toast-header{ font-weight:700; }

.global-loader, #global-loader {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    justify-content: center;
    align-items: center;
}
.loader-box{
    background:#fff; padding:22px 28px; border-radius:20px; box-shadow: 0 15px 35px rgba(15,23,42,.15); text-align:center; min-width:260px;
}
.loader-text{ margin-top:12px; font-weight:700; color:var(--dark-text); }

/* -----------------------------------
   MISC
----------------------------------- */
.select-atendido { border-color: rgb(1, 255, 1); background-color: #d4edda; }
.select-no-atendido { border-color: red; background-color: #f8d7da; }
input[type="checkbox"] { accent-color: var(--primary-color); }
.diente { display:flex; justify-content:center; align-items:center; margin-top:50px; width:100%; height:auto; max-width:100%; }
svg { width:100%; height:auto; }
.borde-form { box-shadow: 5px 4px 3px 3px rgba(0,0,0,.08); border-radius: 20px; overflow-x:auto; }

/* -----------------------------------
   RESPONSIVE
----------------------------------- */
/* -----------------------------------
   RESPONSIVE
----------------------------------- */
@media (max-width: 991.98px){
    #sidebar{ margin-left: calc(var(--sidebar-width) * -1); }
    #sidebar.active{ margin-left: 0; }
    #content{ margin-left: 0; padding: 15px; }
    .topbar{ border-radius: 18px; }
    .action-right, .search-actions{ justify-content: flex-start; }
    .dashboard-header{ padding: 18px; }
    .stats-card .card-body{ padding: 16px; }
}

@media (max-width: 767.98px){
    .page-hero{ padding: 20px; }
    .page-hero h2{ font-size: 1.5rem; }
    .content-card .card-body, .card .card-body, .modal-body{ padding: 18px; }
    .btn-modern, .two-tone-button, .two-tone-button-two, .button-secondary, .button-color-tone, .button-consult-tone, .btn-register{ width: 100%; }
    .menu-btn span, .user-info{ display:none; }
    .dashboard-header h2{ font-size: 1.4rem; }
    .stats-card{ margin-bottom: 16px; }
}

@media (max-width: 767.98px){
    .page-hero{ padding: 20px; }
    .page-hero h2{ font-size: 1.5rem; }
    .content-card .card-body, .card .card-body, .modal-body{ padding: 18px; }
    .btn-modern, .two-tone-button, .two-tone-button-two, .button-secondary, .button-color-tone, .button-consult-tone, .btn-register{ width: 100%; }
    .menu-btn span, .user-info{ display:none; }
}

    .calculator-card {
        border: 1px solid #e5e7eb;
        border-radius: 20px;
        background: linear-gradient(135deg, #f8fbff 0%, #ffffff 100%);
        box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
    }

    .calculator-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        flex-wrap: wrap;
        margin-bottom: 1.2rem;
    }

    .calculator-title {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 700;
        color: #0f172a;
    }

    .calculator-subtitle {
        margin: 0.35rem 0 0 0;
        color: #64748b;
        font-size: 0.93rem;
    }

    .calc-box {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 18px;
        padding: 1rem;
        height: 100%;
    }

    .calc-box h6 {
        font-weight: 700;
        color: #1e293b;
        margin-bottom: 0.8rem;
    }

    .result-panel {
        background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
        border: 1px solid #bfdbfe;
        border-radius: 18px;
        padding: 1rem;
    }

    .result-label {
        font-size: 0.9rem;
        color: #475569;
        margin-bottom: 0.35rem;
    }

    .result-value {
        font-size: 2rem;
        font-weight: 800;
        color: #1d4ed8;
        line-height: 1;
    }

    .result-helper {
        margin-top: 0.45rem;
        font-size: 0.92rem;
        color: #475569;
    }

    .example-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        border-radius: 999px;
        background: #f8fafc;
        border: 1px solid #cbd5e1;
        color: #0f172a;
        font-size: 0.9rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        margin: 4px 6px 4px 0;
    }

    .example-chip:hover {
        background: #eff6ff;
        border-color: #93c5fd;
        color: #1d4ed8;
    }

    .mini-guide {
        margin-top: 0.75rem;
        padding: 0.85rem 1rem;
        border-radius: 14px;
        background: #f8fafc;
        border: 1px dashed #cbd5e1;
        color: #475569;
        font-size: 0.9rem;
    }

    .btn-info-modern {
        background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
        border: none;
        color: #fff;
    }

    .btn-info-modern:hover {
        color: #fff;
        opacity: 0.95;
    }

    .divider-text {
        display: flex;
        align-items: center;
        gap: 10px;
        color: #64748b;
        font-size: 0.9rem;
        margin: 0.75rem 0;
    }

    .divider-text::before,
    .divider-text::after {
        content: "";
        flex: 1;
        height: 1px;
        background: #e2e8f0;
    }

    .hint-text {
        font-size: 0.82rem;
        color: #64748b;
        margin-top: 0.4rem;
    }

    .input-group-text-custom {
        min-width: 80px;
        justify-content: center;
        font-weight: 600;
        background: #f8fafc;
        border-color: #dbe2ea;
    }

    @media (max-width: 768px) {
        .result-value {
            font-size: 1.6rem;
        }
    }

    .appointment-layout {
        display: grid;
        grid-template-columns: 420px 1fr;
        gap: 20px;
    }

    .form-panel,
    .calendar-panel {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 22px;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
    }

    .panel-header {
        padding: 18px 22px;
        border-bottom: 1px solid #e2e8f0;
    }

    .panel-header h4 {
        margin: 0;
        font-weight: 800;
        color: #0f172a;
    }

    .panel-body {
        padding: 20px 22px;
    }

    .calendar-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 16px;
    }

    .legend-item {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 0.9rem;
        color: #334155;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        padding: 8px 12px;
        border-radius: 999px;
    }

    .legend-dot {
        width: 12px;
        height: 12px;
        border-radius: 999px;
        display: inline-block;
    }

    .legend-red { background: #ef4444; }
    .legend-orange { background: #f59e0b; }
    .legend-gray { background: #94a3b8; }
    .legend-green { background: #14b8a6; }

    .calendar-helper {
        border: 1px dashed #cbd5e1;
        background: #f8fafc;
        border-radius: 14px;
        padding: 12px 14px;
        margin-bottom: 16px;
        color: #475569;
        font-size: 0.93rem;
    }

    .calendar-box {
        border: 1px solid #e2e8f0;
        border-radius: 18px;
        padding: 12px;
        background: #fff;
        margin-bottom: 18px;
    }

    .available-list {
        border: 1px solid #e2e8f0;
        border-radius: 18px;
        background: #fff;
        overflow: hidden;
    }

    .available-list-header {
        padding: 14px 16px;
        border-bottom: 1px solid #e2e8f0;
        font-weight: 700;
        color: #0f172a;
        background: #f8fafc;
    }

    .available-list-body {
        max-height: 260px;
        overflow-y: auto;
        padding: 12px;
    }

    .slot-btn {
        width: 100%;
        border: 1px solid #bfdbfe;
        background: #eff6ff;
        color: #1d4ed8;
        border-radius: 12px;
        padding: 10px 12px;
        text-align: left;
        font-weight: 700;
        margin-bottom: 10px;
        transition: all 0.2s ease;
    }

    .slot-btn:hover {
        background: #dbeafe;
        border-color: #93c5fd;
    }

    .slot-btn.active {
        background: linear-gradient(135deg, #14b8a6 0%, #0f766e 100%);
        border-color: #0f766e;
        color: #fff;
    }

    .selected-box {
        border-radius: 14px;
        padding: 12px 14px;
        border: 1px solid #bfdbfe;
        background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
        margin-top: 14px;
    }

    .selected-box .label {
        font-size: 0.88rem;
        color: #475569;
        margin-bottom: 4px;
    }

    .selected-box .value {
        font-size: 1rem;
        font-weight: 800;
        color: #1d4ed8;
    }

    .fc .fc-toolbar-title {
        font-size: 1rem;
        font-weight: 700;
    }

    .fc .fc-button {
        background: #0f766e !important;
        border: none !important;
        box-shadow: none !important;
    }

    .fc-event.occupied-slot {
        border: none !important;
        border-radius: 10px !important;
    }

    .fc-event.lunch-slot {
        border: none !important;
        border-radius: 10px !important;
    }

    .fc-bg-event {
        opacity: 0.18 !important;
    }

    @media (max-width: 1100px) {
        .appointment-layout {
            grid-template-columns: 1fr;
        }
    }

        .visor-page .filter-card {
        background: #ffffff;
        border-radius: 18px;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
        border: 1px solid #e2e8f0;
        padding: 24px;
    }

    .visor-page .calendar-card {
        background: #ffffff;
        border-radius: 18px;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
        border: 1px solid #e2e8f0;
        overflow: hidden;
    }

    .visor-page .calendar-card .panel-header {
        padding: 18px 22px;
        border-bottom: 1px solid #e2e8f0;
        background: linear-gradient(135deg, #f8fafc, #eef2ff);
    }

    .visor-page .calendar-card .panel-header h4 {
        margin: 0;
        font-weight: 700;
        color: #0f172a;
    }

    .visor-page .calendar-card .panel-body {
        padding: 20px;
    }

    .calendar-helper {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        padding: 16px 18px;
        color: #475569;
        margin-bottom: 18px;
    }

    .calendar-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        margin-bottom: 18px;
    }

    .legend-item {
        display: flex;
        align-items: center;
        gap: 8px;
        color: #334155;
        font-weight: 500;
        font-size: 0.95rem;
    }

    .legend-dot {
        width: 14px;
        height: 14px;
        border-radius: 50%;
        display: inline-block;
    }

    .legend-red {
        background: #ef4444;
    }

    .legend-orange {
        background: #f59e0b;
    }

    .legend-gray {
        background: #94a3b8;
    }

    .calendar-box {
        border: 1px solid #e2e8f0;
        border-radius: 18px;
        background: #fff;
        padding: 14px;
    }

    #calendarMedico {
        min-height: 760px;
    }

    .fc .fc-toolbar-title {
        font-size: 1.15rem;
        font-weight: 700;
        color: #0f172a;
    }

    .fc .fc-button {
        background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
        border: none !important;
        color: #fff !important;
        border-radius: 12px !important;
        padding: 0.45rem 0.9rem !important;
        font-weight: 600 !important;
        box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18) !important;
    }

    .fc .fc-button:hover {
        background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
        transform: translateY(-1px);
    }

    .fc .fc-button:disabled {
        opacity: 0.65 !important;
        box-shadow: none !important;
    }

    .fc .fc-button-active {
        background: linear-gradient(135deg, #1e40af, #1d4ed8) !important;
    }

    .fc .fc-timegrid-event {
        border-radius: 10px;
        padding: 2px 4px;
    }

    .fc .fc-event-title {
        font-weight: 600;
    }

    .fc-button-group {
        display: flex;
        gap: 8px;
    }

    @media (max-width: 768px) {
        #calendarMedico {
            min-height: 620px;
        }
    }

/* -----------------------------------
   PREMIUM INTRANET REFRESH
----------------------------------- */
:root {
    --primary-color: #03999f;
    --primary-dark: #0b7285;
    --primary-deep: #164e63;
    --primary-soft: #ecfeff;
    --gold-color: #c99a2e;
    --gold-soft: #f8edd5;
    --surface: #ffffff;
    --surface-soft: #f7fbfb;
    --surface-muted: #eef7f8;
    --border-soft: #dbe7ea;
    --dark-text: #0f172a;
    --muted-text: #64748b;
    --sidebar-bg: linear-gradient(180deg, #07171d 0%, #0f2f3a 48%, #08151b 100%);
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
    --shadow-medium: 0 24px 60px rgba(15, 23, 42, 0.12);
    --shadow-strong: 0 32px 90px rgba(15, 23, 42, 0.18);
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

body {
    background:
        radial-gradient(circle at 8% 0%, rgba(201, 154, 46, 0.10), transparent 28rem),
        radial-gradient(circle at 95% 8%, rgba(3, 153, 159, 0.14), transparent 30rem),
        linear-gradient(180deg, #f7fbfb 0%, #edf6f7 100%);
    color: var(--dark-text);
}

#sidebar {
    padding: 16px 14px 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 16px 0 50px rgba(8, 21, 27, 0.22);
}

#sidebar .sidebar-header {
    margin: 0 0 14px;
    padding: 10px 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.logo-sidebar {
    max-width: 156px;
    max-height: 94px;
    border-radius: 16px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.25);
}

.sidebar-brand-title {
    font-size: 1.08rem;
    letter-spacing: 0.01em;
}

.sidebar-brand-subtitle {
    color: rgba(236, 254, 255, 0.70);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.menu-section-title {
    color: rgba(236, 254, 255, 0.56);
    letter-spacing: 0.14em;
    margin: 20px 12px 10px;
}

#sidebar ul li {
    margin-bottom: 6px;
}

#sidebar ul li a {
    min-height: 44px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.91rem;
    font-weight: 700;
    padding: 10px 12px;
}

#sidebar ul li a .menu-icon {
    color: rgba(207, 250, 254, 0.86);
}

#sidebar ul li a:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    transform: translateX(2px);
}

#sidebar ul li.active > a,
#sidebar ul li > a.active,
a[aria-expanded="true"] {
    background: linear-gradient(135deg, #03999f, #0b7285);
    box-shadow: 0 14px 30px rgba(3, 153, 159, 0.28);
}

#sidebar ul li.active > a::after,
#sidebar ul li > a.active::after {
    right: 12px;
    background: #f8edd5;
}

#sidebar ul ul li a {
    background: rgba(255, 255, 255, 0.055);
    color: rgba(236, 254, 255, 0.78);
}

#content {
    padding: 18px 22px 26px;
}

.topbar {
    position: sticky;
    top: 16px;
    z-index: 1020;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(16px);
}

.menu-btn {
    min-height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #03999f, #0b7285);
    box-shadow: 0 14px 28px rgba(3, 153, 159, 0.22);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
}

.topbar-subtitle {
    font-size: 0.82rem;
    color: #64748b;
}

.user-dropdown-toggle {
    border-radius: 14px;
    background: #fff;
    border-color: rgba(219, 231, 234, 0.95);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.user-dropdown-toggle:hover {
    background: #f7fbfb;
    border-color: #cfe5e8;
}

.user-avatar,
.user-avatar-placeholder {
    width: 40px;
    height: 40px;
    border: 2px solid #cffafe;
}

.user-avatar-placeholder {
    background: linear-gradient(135deg, #03999f, #0b7285);
}

.page-container {
    padding-top: 4px;
}

.dashboard-header,
.page-hero {
    background:
        linear-gradient(135deg, rgba(7, 23, 29, 0.96), rgba(3, 153, 159, 0.90)),
        url('../img/Consultorio.jpeg') center/cover;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(3, 153, 159, 0.20);
}

.dashboard-header h2,
.page-hero h2 {
    font-weight: 800;
    letter-spacing: 0;
}

.mini-badge,
.hero-badge,
.payment-note {
    border: 1px solid rgba(3, 153, 159, 0.14);
    background: #ecfeff;
    color: #0b7285;
    border-radius: 999px;
    font-weight: 800;
}

.card,
.content-card,
.stats-card,
.chart-card,
.history-card,
.filter-card,
.table-card,
.section-card,
.filter-box,
.form-panel,
.calendar-panel,
.calculator-card,
.visor-page .filter-card,
.visor-page .calendar-card {
    border: 1px solid rgba(219, 231, 234, 0.94);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.card:hover,
.stats-card:hover,
.history-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.stats-card {
    overflow: hidden;
}

.stats-card::after {
    content: '';
    position: absolute;
    inset: auto 18px 0 18px;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: linear-gradient(90deg, #03999f, #c99a2e);
    opacity: 0.75;
}

.stats-icon,
.history-icon {
    border-radius: 14px;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

.bg-primary-soft,
.bg-info-soft {
    background: linear-gradient(135deg, #03999f, #0b7285) !important;
}

.bg-warning-soft {
    background: linear-gradient(135deg, #c99a2e, #e9c46a) !important;
}

.filter-card,
.filter-box,
.section-card {
    padding: 20px;
}

.filter-title,
.section-card-title,
.table-toolbar h5,
.panel-header h4,
.chart-title,
.calculator-title {
    color: #0f172a;
    font-weight: 800;
}

.table-toolbar,
.panel-header,
.available-list-header,
.visor-page .calendar-card .panel-header {
    background: linear-gradient(180deg, #ffffff 0%, #f7fbfb 100%);
    border-bottom: 1px solid #dbe7ea;
}

.custom-table thead th,
table.dataTable thead th {
    background: linear-gradient(180deg, #ecfeff 0%, #dff7f8 100%) !important;
    color: #164e63 !important;
    font-size: 0.86rem;
    letter-spacing: 0.01em;
}

.custom-table tbody tr,
table.dataTable tbody tr {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.045);
}

.custom-table tbody tr:hover,
table.dataTable tbody tr:hover {
    background: #f7fdfd;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.form-label {
    color: #1e293b;
    font-size: 0.9rem;
}

.form-control,
.form-select,
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-color: #d5e4e7;
    border-radius: 12px;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus,
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: #03999f;
    box-shadow: 0 0 0 0.18rem rgba(3, 153, 159, 0.13) !important;
}

.input-group-text {
    border-color: #d5e4e7;
    background: #f7fbfb;
}

.two-tone-button,
.btn-primary-modern,
.btn-register,
.btn-info-modern,
.fc .fc-button {
    background: linear-gradient(135deg, #03999f, #0b7285) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 14px 28px rgba(3, 153, 159, 0.22) !important;
}

.two-tone-button:hover,
.btn-primary-modern:hover,
.btn-register:hover,
.btn-info-modern:hover {
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 18px 34px rgba(3, 153, 159, 0.28) !important;
}

.button-secondary,
.btn-secondary-modern,
.btn-outline-secondary,
.btn-outline-primary {
    background: #fff;
    border-color: #dbe7ea;
    color: #334155;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.055);
}

.button-secondary:hover,
.btn-secondary-modern:hover,
.btn-outline-secondary:hover,
.btn-outline-primary:hover {
    background: #ecfeff;
    border-color: #b6edf0;
    color: #0b7285;
}

.button-consult-tone,
.btn-warning-modern {
    background: linear-gradient(135deg, #c99a2e, #e9c46a);
    color: #fff;
}

.modal-content {
    border-radius: 18px;
    box-shadow: var(--shadow-strong);
}

.modal-header {
    background: linear-gradient(135deg, #07171d 0%, #0b7285 100%);
}

.modal-body {
    background: #f7fbfb;
}

.dropdown-menu {
    border: 1px solid #dbe7ea;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
}

.empty-state {
    background: #f7fbfb;
    border-color: #cfe5e8;
}

.global-loader,
#global-loader {
    background: rgba(247, 251, 251, 0.78);
}

@media (max-width: 991.98px) {
    #content {
        padding: 14px;
    }

    .topbar {
        top: 10px;
        border-radius: 16px;
    }
}

@media (max-width: 767.98px) {
    .topbar {
        padding: 10px;
    }

    .dashboard-header,
    .page-hero {
        border-radius: 18px;
    }

    .filter-card,
    .filter-box,
    .section-card {
        padding: 16px;
    }
}

/* =====================================================
   RESPONSIVE HARDENING GLOBAL - INTRANET
   ===================================================== */
html {
    overflow-x: hidden;
}

body {
    width: 100%;
    max-width: 100vw;
}

img,
video,
svg,
canvas,
iframe {
    max-width: 100%;
}

img,
video {
    height: auto;
}

.container,
.container-fluid {
    max-width: 100%;
}

.row,
[class*="col-"],
.card,
.content-card,
.stats-card,
.chart-card,
.history-card,
.filter-card,
.table-card,
.section-card,
.modal-content,
.form-panel,
.calendar-panel,
.calculator-card {
    min-width: 0;
}

.table-responsive,
.dataTables_wrapper,
.dataTables_scroll,
.dataTables_scrollBody,
.datatable-shell {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table,
.dataTables_wrapper table,
table.dataTable {
    width: max-content !important;
    min-width: 100%;
}

.dataTables_wrapper .row {
    row-gap: 12px;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    width: 100%;
}

.dataTables_wrapper .dataTables_filter input,
.form-control,
.form-select,
.btn,
button,
input,
select,
textarea {
    max-width: 100%;
}

.section-title,
.topbar-title,
.chart-title,
.filter-title,
.table-toolbar h5,
.panel-header h4 {
    overflow-wrap: anywhere;
}

textarea {
    resize: vertical;
}

.modal-dialog {
    max-width: min(100% - 24px, var(--bs-modal-width, 900px));
}

.modal-body {
    overflow-x: hidden;
}

.fc,
.fc-view-harness,
.fc-scrollgrid {
    max-width: 100%;
}

.fc .fc-toolbar {
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 1199.98px) {
    :root {
        --sidebar-width: 270px;
    }

    #content {
        padding: 16px;
    }
}

@media (max-width: 991.98px) {
    :root {
        --sidebar-width: min(86vw, 300px);
    }

    .wrapper {
        display: block;
    }

    #sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        max-width: var(--sidebar-width);
    }

    #content,
    #content.expanded {
        width: 100%;
        margin-left: 0;
        padding: 14px;
    }

    .topbar {
        position: sticky;
        top: 8px;
        margin-bottom: 16px;
    }

    .topbar .container-fluid > .d-flex {
        align-items: stretch !important;
    }

    .user-dropdown-toggle {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-header .d-flex,
    .page-hero .d-flex,
    .section-top,
    .table-toolbar,
    .calculator-header,
    .panel-header {
        align-items: flex-start !important;
    }

    .appointment-layout,
    .contact-panel,
    .web-admin-shell {
        grid-template-columns: 1fr !important;
    }

    .canvas-wrapper,
    .canvas-wrapper-sm {
        height: 280px;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 14px;
    }

    #content,
    #content.expanded {
        padding: 10px;
    }

    .topbar {
        border-radius: 14px;
        padding: 10px;
    }

    .topbar .container-fluid > .d-flex,
    .section-top,
    .table-toolbar,
    .admin-page-heading,
    .actions-group,
    .action-group,
    .action-right,
    .search-actions,
    .modal-footer {
        flex-direction: column;
        align-items: stretch !important;
    }

    .menu-btn,
    .user-dropdown-toggle,
    .btn,
    .two-tone-button,
    .two-tone-button-two,
    .button-secondary,
    .button-color-tone,
    .button-consult-tone,
    .btn-modern,
    .btn-register,
    .btn-primary-modern,
    .btn-secondary-modern,
    .btn-success-modern,
    .btn-warning-modern {
        width: 100%;
        justify-content: center;
    }

    .btn-action {
        width: 40px;
        min-width: 40px;
    }

    .dashboard-header,
    .page-hero,
    .filter-card,
    .filter-box,
    .section-card,
    .table-card,
    .card,
    .content-card,
    .stats-card,
    .chart-card,
    .history-card,
    .form-panel,
    .calendar-panel,
    .calculator-card {
        border-radius: 16px;
    }

    .dashboard-header,
    .page-hero,
    .content-card .card-body,
    .chart-card .card-body,
    .stats-card .card-body,
    .history-card .card-body,
    .panel-body,
    .modal-body {
        padding: 16px;
    }

    .dashboard-header h2,
    .page-hero h2 {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .stats-value,
    .result-value {
        font-size: 1.45rem;
    }

    .table-responsive {
        padding: 8px;
    }

    .dataTables_wrapper .dataTables_filter {
        text-align: left;
    }

    .dataTables_wrapper .dataTables_filter input,
    .dataTables_wrapper .dataTables_length select {
        width: 100%;
        min-width: 100%;
        margin-left: 0;
    }

    .dataTables_wrapper .dataTables_paginate {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }

    .custom-table thead th,
    table.dataTable thead th,
    .custom-table tbody td,
    table.dataTable tbody td {
        padding: 10px 9px !important;
        font-size: 0.82rem;
    }

    .modal-dialog {
        margin: 0.75rem auto;
        max-width: calc(100% - 18px);
    }

    .modal-dialog-scrollable .modal-content,
    .modal-content {
        max-height: calc(100vh - 1.5rem);
    }

    .modal-dialog-scrollable .modal-body,
    .modal-body {
        max-height: calc(100vh - 150px);
    }

    .fc .fc-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .fc .fc-toolbar-title {
        font-size: 1rem;
    }

    .fc .fc-button-group,
    .fc .fc-button {
        width: 100%;
    }

    #calendarMedico {
        min-height: 520px;
    }
}

@media (max-width: 575.98px) {
    #content,
    #content.expanded {
        padding: 8px;
    }

    .row {
        --bs-gutter-x: 0.85rem;
        --bs-gutter-y: 0.85rem;
    }

    .input-group {
        flex-wrap: nowrap;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        min-width: 0;
    }

    .canvas-wrapper,
    .canvas-wrapper-sm {
        height: 240px;
    }

    .loader-box {
        min-width: 0;
        width: calc(100% - 32px);
    }
}

/* Layout contract: content must use the remaining viewport beside the sidebar. */
@media (min-width: 992px) {
    #content {
        width: calc(100vw - var(--sidebar-width)) !important;
        max-width: calc(100vw - var(--sidebar-width)) !important;
        margin-left: var(--sidebar-width) !important;
        overflow-x: hidden;
    }

    #content.expanded {
        width: 100vw !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
    }

    #content .page-container,
    #content .container,
    #content .container-fluid,
    #content .table-card,
    #content .table-responsive,
    #content .dataTables_wrapper,
    #content .datatable-shell {
        max-width: 100%;
    }
}
