:root {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --card-border: #e2e8f0;
    --body-bg: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 260px;
}

body {
    background-color: var(--body-bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    min-height: 100vh;
    transition: transform 0.25s ease-in-out, left 0.25s ease-in-out;
    z-index: 1045;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    margin: 0.2rem 0.75rem;
    transition: all 0.15s ease-in-out;
}

.sidebar .nav-link:hover {
    color: var(--sidebar-text-active);
    background-color: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: #ffffff;
    background-color: var(--primary-color);
}

/* Mobile Sidebar Drawer (< 992px) */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(2px);
        z-index: 1040;
        display: none;
        opacity: 0;
        transition: opacity 0.25s ease-in-out;
    }

    .sidebar-backdrop.show {
        display: block;
        opacity: 1;
    }
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--body-bg);
    min-width: 0; /* Prevents flex children from overflowing container */
}

.top-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 0.75rem 1.5rem;
}

.content-container {
    padding: 1.5rem;
    flex: 1;
}

/* Mobile Adjustments for Containers (< 768px) */
@media (max-width: 767.98px) {
    .top-navbar {
        padding: 0.65rem 0.85rem;
    }

    .content-container {
        padding: 0.85rem;
    }

    .top-navbar .btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.825rem;
    }

    .top-navbar .clinic-badge {
        max-width: 160px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
    }
}

/* Modern Nimbo-style Cards */
.card-nimbo {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.card-nimbo:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.card-nimbo .card-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 0.85rem 1.15rem;
    font-weight: 600;
    color: var(--text-main);
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

/* Badges and Tags */
.badge-status {
    padding: 0.35rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.725rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.badge-programada { background-color: #f1f5f9; color: #475569; }
.badge-en_espera { background-color: #fef3c7; color: #d97706; }
.badge-en_consulta { background-color: #e0f2fe; color: #0284c7; }
.badge-finalizada { background-color: #dcfce7; color: #15803d; }
.badge-cancelada { background-color: #fee2e2; color: #b91c1c; }

/* Patient Banner Header in Consultation */
.patient-banner {
    background: linear-gradient(to right, #ffffff, #f0f9ff);
    border: 1px solid #bae6fd;
    border-radius: 0.75rem;
    padding: 1.15rem;
}

@media (max-width: 575.98px) {
    .patient-banner {
        padding: 0.85rem;
    }
}

/* Vitals Bar */
.vital-input-group {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem 0.65rem;
    text-align: center;
}

.vital-input-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vital-input-group input {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    border: none;
    background: transparent;
    width: 100%;
}

.vital-input-group input:focus {
    outline: none;
}

/* Horizontal swipeable tabs for mobile */
.nav-tabs-mobile {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
    scrollbar-width: none; /* Firefox */
}

.nav-tabs-mobile::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.nav-tabs-mobile .nav-item {
    flex: 0 0 auto;
}

/* Smooth Touch Scrolling on all tables */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 1.75rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background-color: #e2e8f0;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-point {
    position: absolute;
    left: -1.75rem;
    top: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 2px #bae6fd;
}

/* Touch targets optimization */
button, a.btn, .form-control, .form-select {
    touch-action: manipulation;
}

/* Sticky Bottom Bar on Mobile */
@media (max-width: 767.98px) {
    .sticky-bottom-mobile {
        position: sticky;
        bottom: 0.5rem;
        z-index: 1020;
    }
}

/* Printable Prescription */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 12pt;
    }
    .no-print {
        display: none !important;
    }
    .prescription-sheet {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}
