/* ============================================
   ESTILOS - SISTEMA DENTAL
   css/style.css
   ============================================ */

:root {
    --primary:    #2563eb;
    --primary-dk: #1d4ed8;
    --secondary:  #0ea5e9;
    --success:    #16a34a;
    --danger:     #dc2626;
    --warning:    #d97706;
    --info:       #0891b2;
    --light:      #f8fafc;
    --dark:       #1e293b;
    --border:     #e2e8f0;
    --shadow:     0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,.1);
    --radius:     8px;
    --sidebar-w:  260px;
    --topbar-h:   64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    color: var(--dark);
    min-height: 100vh;
}

/* ---- LAYOUT ---- */
.layout {
    display: flex;
    min-height: 100vh;
}
.iconimage {
    width: 20px;
    aspect-ratio: 1/1;
    object-fit: contain;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-logo {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo .logo-icon {
    font-size: 28px;
}

.sidebar-logo h2 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-logo span {
    font-size: 11px;
    color: #94a3b8;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #64748b;
    padding: 12px 20px 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    transition: all .2s;
    border-radius: 0;
    cursor: pointer;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-nav a.active {
    border-left: 3px solid var(--primary);
    background: rgba(37,99,235,.15);
    color: #60a5fa;
}

.sidebar-nav a .nav-icon { font-size: 18px; width: 20px; }

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- TOPBAR ---- */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---- PAGE SECTIONS ---- */
.page-section {
    display: none;
    padding: 24px;
    flex: 1;
}

.page-section.active {
    display: block;
}

/* ---- CARDS ---- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* ---- STATS GRID ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.purple { background: #5f3bf7; }

.stat-info p { font-size: 12px; color: #64748b; }
.stat-info h3 { font-size: 24px; font-weight: 700; }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #15803d; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #b91c1c; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--dark); }
.btn-outline:hover { background: var(--light); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---- FORMS ---- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.full { grid-column: 1 / -1; }

label { font-size: 13px; font-weight: 500; color: #475569; }

input, select, textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .2s;
    background: #fff;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

textarea { resize: vertical; min-height: 80px; }

/* ---- TABLE ---- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: #f8fafc;
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #64748b;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ---- BADGES ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-blue     { background: #dbeafe; color: #1d4ed8; }
.badge-green    { background: #dcfce7; color: #15803d; }
.badge-red      { background: #fee2e2; color: #b91c1c; }
.badge-yellow   { background: #fef9c3; color: #a16207; }
.badge-gray     { background: #f1f5f9; color: #475569; }
.badge-purple   { background: #ede9fe; color: #7c3aed; }

/* ---- MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn .2s ease;
}

.modal-lg { max-width: 860px; }

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #64748b;
    padding: 4px;
    line-height: 1;
}

/* ---- TOAST NOTIFICATIONS ---- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    background: #1e293b;
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: fadeIn .3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.alarm   { border-left-color: #f97316; background: #431407; }

.toast-icon { font-size: 18px; margin-top: 1px; }
.toast-msg  { flex: 1; }
.toast-title { font-weight: 600; font-size: 13px; }
.toast-body  { font-size: 12px; color: #94a3b8; margin-top: 2px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ---- CALENDAR ---- */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-header {
    background: #f8fafc;
    padding: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.cal-day {
    background: #fff;
    min-height: 80px;
    padding: 6px;
    cursor: pointer;
    transition: background .15s;
    position: relative;
}

.cal-day:hover { background: #f0f9ff; }
.cal-day.other-month { background: #f8fafc; }
.cal-day.today { background: #eff6ff; }
.cal-day.selected { background: #dbeafe; }

.cal-day-num {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.cal-day.today .cal-day-num { color: var(--primary); font-weight: 700; }

.cal-event {
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 3px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- CRONOGRAMA TIMELINE ---- */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
    padding: 14px 16px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 3px solid var(--primary);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 18px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item.completada  { border-left-color: var(--success); }
.timeline-item.completada::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.cancelada   { border-left-color: #94a3b8; opacity: .7; }

/* ---- SEARCH BOX ---- */
.search-box {
    position: relative;
    max-width: 320px;
}

.search-box input { padding-left: 36px; }

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
}

/* ---- MISC ---- */
.text-muted    { color: #64748b; font-size: 13px; }
.text-center   { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- CRONOGRAMA CITAS FORM ---- */
.cita-row {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    position: relative;
}

.cita-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cita-row-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: #dbeafe;
    padding: 2px 10px;
    border-radius: 50px;
}

/* ---- HAMBURGER BUTTON ---- */
.btn-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    flex-direction: column;
    gap: 5px;
    transition: background .2s;
}

.btn-hamburger:hover { background: var(--light); }

.btn-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--dark);
    border-radius: 2px;
    transition: all .3s ease;
}

/* Animación X al abrir */
.btn-hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.btn-hamburger.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.btn-hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ---- OVERLAY OSCURO (toca fuera para cerrar) ---- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
    animation: fadeInBg .2s ease;
}

.sidebar-backdrop.open { display: block; }

@keyframes fadeInBg {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .btn-hamburger { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .3s ease;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.25);
    }

    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}