/* Medicine Man v2 - Theme System + Sidebar Layout */

/* ========== THEME VARIABLES ========== */
:root {
    /* Light Theme - soft grey (like old neutral) */
    --bg-primary: #f0f0f0;
    --bg-secondary: #e5e5e5;
    --bg-card: #f8f8f8;
    --bg-sidebar: #e8e8e8;
    --text-primary: #2a2a2a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --border-color: #d0d0d0;
    --accent: #2d8a4e;
    --accent-hover: #236b3d;
    --danger: #dc3545;
    --warning: #ffc107;
    --success: #28a745;
    --shadow: rgba(0,0,0,0.1);
    --shadow-lg: rgba(0,0,0,0.15);
}

[data-theme="neutral"] {
    /* Neutral - between light and slate */
    --bg-primary: #c8c8c8;
    --bg-secondary: #b8b8b8;
    --bg-card: #d0d0d0;
    --bg-sidebar: #ababab;
    --text-primary: #1a1a1a;
    --text-secondary: #3a3a3a;
    --text-muted: #5a5a5a;
    --border-color: #9a9a9a;
    --shadow: rgba(0,0,0,0.12);
    --shadow-lg: rgba(0,0,0,0.2);
}

[data-theme="lighter-dark"] {
    --bg-primary: #2a2d35;
    --bg-secondary: #23262d;
    --bg-card: #32363f;
    --bg-sidebar: #1e2128;
    --text-primary: #e4e4e4;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    --border-color: #3d4150;
    --shadow: rgba(0,0,0,0.25);
    --shadow-lg: rgba(0,0,0,0.35);
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2541;
    --bg-sidebar: #0f0f1a;
    --text-primary: #e4e4e4;
    --text-secondary: #a0a0a0;
    --text-muted: #606060;
    --border-color: #2a2a4a;
    --accent: #4ade80;
    --accent-hover: #22c55e;
    --shadow: rgba(0,0,0,0.3);
    --shadow-lg: rgba(0,0,0,0.45);
}

[data-theme="forest"] {
    /* Dark Green Theme */
    --bg-primary: #0d1f12;
    --bg-secondary: #142318;
    --bg-card: #1a2e1f;
    --bg-sidebar: #081210;
    --text-primary: #d4e6d4;
    --text-secondary: #8fb08f;
    --text-muted: #5a7a5a;
    --border-color: #2a4a2a;
    --accent: #4ade80;
    --accent-hover: #22c55e;
    --danger: #ef4444;
    --shadow: rgba(0,0,0,0.35);
    --shadow-lg: rgba(0,0,0,0.5);
}

[data-theme="crimson"] {
    /* Dark Red Theme */
    --bg-primary: #1a0f0f;
    --bg-secondary: #241414;
    --bg-card: #2e1a1a;
    --bg-sidebar: #120a0a;
    --text-primary: #e6d4d4;
    --text-secondary: #b08f8f;
    --text-muted: #7a5a5a;
    --border-color: #4a2a2a;
    --accent: #f87171;
    --accent-hover: #ef4444;
    --danger: #ef4444;
    --shadow: rgba(0,0,0,0.35);
    --shadow-lg: rgba(0,0,0,0.5);
}

[data-theme="slate"] {
    /* Mid-Dark Grey Theme */
    --bg-primary: #3a3f47;
    --bg-secondary: #32363d;
    --bg-card: #444951;
    --bg-sidebar: #2a2e35;
    --text-primary: #e8e8e8;
    --text-secondary: #a8a8a8;
    --text-muted: #787878;
    --border-color: #555a62;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --shadow: rgba(0,0,0,0.25);
    --shadow-lg: rgba(0,0,0,0.4);
}

[data-theme="charcoal"] {
    /* Darker Grey Theme */
    --bg-primary: #1e1e1e;
    --bg-secondary: #171717;
    --bg-card: #262626;
    --bg-sidebar: #121212;
    --text-primary: #e0e0e0;
    --text-secondary: #9a9a9a;
    --text-muted: #666666;
    --border-color: #383838;
    --accent: #a78bfa;
    --accent-hover: #8b5cf6;
    --shadow: rgba(0,0,0,0.35);
    --shadow-lg: rgba(0,0,0,0.5);
}

/* ========== RESET & BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ========== APP LAYOUT ========== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 250px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1000;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-footer span,
.sidebar.collapsed .theme-label {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h1 {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: var(--bg-secondary);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 15px 10px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 10px;
    margin-bottom: 8px;
}

.sidebar.collapsed .nav-section-title {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.nav-label {
    white-space: nowrap;
    flex: 1;
}

.nav-badge {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* Theme Selector in Sidebar */
.theme-selector {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.theme-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: block;
}

.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 140px;
}

.sidebar.collapsed .theme-options {
    flex-direction: column;
    max-width: none;
}

.theme-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.theme-btn:hover {
    transform: scale(1.15);
}

.theme-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

/* 8 Theme Button Colors */
.theme-btn[data-theme="light"] { background: linear-gradient(135deg, #f0f0f0 50%, #e5e5e5 50%); }
.theme-btn[data-theme="neutral"] { background: linear-gradient(135deg, #c8c8c8 50%, #b8b8b8 50%); }
.theme-btn[data-theme="slate"] { background: linear-gradient(135deg, #3a3f47 50%, #444951 50%); }
.theme-btn[data-theme="lighter-dark"] { background: linear-gradient(135deg, #2a2d35 50%, #32363f 50%); }
.theme-btn[data-theme="charcoal"] { background: linear-gradient(135deg, #1e1e1e 50%, #262626 50%); }
.theme-btn[data-theme="dark"] { background: linear-gradient(135deg, #1a1a2e 50%, #16213e 50%); }
.theme-btn[data-theme="forest"] { background: linear-gradient(135deg, #0d1f12 50%, #1a2e1f 50%); }
.theme-btn[data-theme="crimson"] { background: linear-gradient(135deg, #1a0f0f 50%, #2e1a1a 50%); }

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-footer span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 25px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 60px;
}

/* Mobile Header (hidden on desktop) */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 0 15px;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
}

.mobile-header h1 {
    font-size: 1rem;
    color: var(--accent);
}

.hamburger {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

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

    .sidebar.collapsed {
        width: 280px;
    }

    .main-content {
        margin-left: 0;
        padding: 70px 15px 15px;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
    }

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

/* ========== COMPONENTS ========== */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45, 138, 78, 0.15);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

tr:hover {
    background: var(--bg-secondary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 25px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 40px var(--shadow-lg);
}

/* Utility Classes */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
