:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-light: #eff6ff;
    --primary-dark: #1d4ed8;
    
    --success-color: #10b981;
    --success-light: #ecfdf5;
    
    --warning-color: #f59e0b;
    --warning-light: #fffbeb;
    
    --danger-color: #ef4444;
    --danger-light: #fef2f2;
    
    --background-app: #f8fafc;
    --background-paper: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-inactive: #94a3b8;
    
    --border-color: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--background-app);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* -------------------
   Sidebar
--------------------*/
.dashboard-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--background-paper);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 16px;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 40px;
    padding-left: 12px;
}
.sidebar-header span {
    color: var(--primary-color);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.nav-item i {
    font-size: 1.1rem;
    color: var(--text-inactive);
    transition: all 0.3s ease;
}

.nav-item:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.nav-item:hover i {
    color: var(--primary-color);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
}
.nav-item.active i {
    color: white;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), #dbeafe);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.user-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* -------------------
   Main Content 
--------------------*/
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.top-header {
    height: 72px;
    padding: 0 40px;
    display: flex;
    background-color: var(--background-paper);
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    align-items: center;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--background-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 16px;
    width: 350px;
    transition: all 0.3s;
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-bar i {
    color: var(--text-inactive);
    margin-right: 12px;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.search-bar input::placeholder {
    color: var(--text-inactive);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* -------------------
   Buttons
--------------------*/
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-light);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s, transform 0.1s;
    font-size: 0.95rem;
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}
.btn-secondary:hover {
    background-color: var(--background-app);
    border-color: var(--text-inactive);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-text:hover {
    text-decoration: underline;
}

/* -------------------
   Content Body
--------------------*/
.content-body {
    padding: 40px;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Forzar scrollbar siempre visible (MacOS Auto-hide bypass) */
.content-body::-webkit-scrollbar {
    width: 12px;
}
.content-body::-webkit-scrollbar-track {
    background: #f8fafc; 
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.content-body::-webkit-scrollbar-thumb {
    background: #94a3b8; 
    border-radius: 8px;
    border: 3px solid #f8fafc;
}
.content-body::-webkit-scrollbar-thumb:hover {
    background: #64748b; 
}

.page-header {
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}
.subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--background-paper);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s, box-shadow 0.3s;
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.pulse-blue { background: var(--primary-light); color: var(--primary-color); }
.pulse-green { background: var(--success-light); color: var(--success-color); }
.pulse-purple { background: #f3e8ff; color: #9333ea; }

.stat-details h3 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.stat-details p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Consultations */
.consultation-section {
    background: var(--background-paper);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.section-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.appointment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.appointment-card {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: border-color 0.3s;
}

.appointment-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.appointment-time {
    display: flex;
    flex-direction: column;
}
.appointment-time strong {
    font-size: 1.05rem;
    color: var(--text-primary);
}
.appointment-time span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.appointment-patient h4 {
    font-size: 1.05rem;
    font-weight: 600;
}
.appointment-patient p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}


/* -------------------
   Modal Components
--------------------*/
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--background-paper);
    border-radius: var(--radius-md);
    width: 650px;
    max-width: 90%;
    position: relative;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 24px;
    right: 32px;
    font-size: 1.8rem;
    color: var(--text-inactive);
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    font-size: 1.4rem;
    margin-bottom: 24px;
}

/* Forms */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group.half { width: 50%; }
.form-group.full { width: 100%; margin-bottom: 20px; }

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input, 
.form-group textarea {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all 0.3s;
    background: var(--background-app);
}

.form-group input:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: white;
}

.textarea-wrapper {
    position: relative;
}
.textarea-wrapper textarea {
    width: 100%;
    resize: vertical;
    padding-right: 48px;
}

.mic-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-inactive);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
}
.mic-btn:hover {
    color: var(--primary-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 32px;
}

/* -------------------
   Responsive Design
--------------------*/
@media (max-width: 1024px) {
    /* Collapse sidebar on very small screens, or at least compress it */
    .sidebar {
        width: 80px;
        padding: 20px 8px;
    }
    
    .sidebar-header h2 {
        font-size: 1rem;
        padding-left: 0;
        text-align: center;
    }
    
    .sidebar-header h2 span {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .nav-item i {
        font-size: 1.3rem;
        margin-right: 0;
    }
    
    /* Hide text inside nav items */
    .nav-item {
        font-size: 0;
    }
    
    .user-profile {
        padding: 16px 0;
        justify-content: center;
    }
    
    .user-info {
        display: none;
    }
    
    .top-header {
        padding: 0 16px;
    }
    
    .search-bar {
        width: 200px;
    }
    
    .content-body {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
