/* ======================================
   NutritionPro - نظام إدارة عيادات التغذية
   Fresh Green Theme
   ====================================== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --primary: #2E7D32;
    --primary-dark: #1B5E20;
    --primary-light: #66BB6A;
    --primary-gradient: linear-gradient(135deg, #2E7D32, #66BB6A);
    --sidebar-bg: #E8F5E9;
    --sidebar-hover: #C8E6C9;
    --sidebar-active: #2E7D32;
    --body-bg: #f0f2f5;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #6c757d;
    --text-light: #ffffff;
    --border-color: #e9ecef;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-dark);
    direction: rtl;
    min-height: 100vh;
    font-size: 14px;
    overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* ======= LOGIN PAGE ======= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 30%, #A5D6A7 60%, #66BB6A 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(46,125,50,0.15) 0%, transparent 70%);
    top: -100px; right: -100px;
    border-radius: 50%;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(46,125,50,0.1) 0%, transparent 70%);
    bottom: -50px; left: -50px;
    border-radius: 50%;
}
.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 45px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.15);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(46,125,50,0.2);
}
.login-title { color: var(--primary-dark); font-weight: 800; font-size: 1.7rem; margin-bottom: 5px; }
.login-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 30px; }
.login-card .form-label { font-weight: 600; color: var(--text-dark); font-size: 0.9rem; margin-bottom: 6px; }
.login-card .input-group {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}
.login-card .input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.15);
}
.login-card .input-group-text { background: transparent; border: none; color: var(--primary); font-size: 1.1rem; padding: 12px 15px; }
.login-card .form-control { border: none; padding: 12px 10px; font-size: 0.95rem; background: transparent; }
.login-card .form-control:focus { box-shadow: none; }
.btn-login {
    background: var(--primary-gradient);
    border: none; border-radius: var(--radius);
    padding: 13px; font-size: 1.1rem; font-weight: 700;
    color: #fff; width: 100%;
    transition: var(--transition);
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(46,125,50,0.4);
    color: #fff;
}
.login-footer {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    text-align: center; padding: 12px;
    font-size: 0.85rem; color: var(--text-muted);
}
.login-footer a { color: var(--primary-dark); font-weight: 700; text-decoration: none; }

/* ======= SIDEBAR ======= */
.sidebar {
    position: fixed; top: 0; right: 0;
    width: 260px; height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    box-shadow: -5px 0 20px rgba(0,0,0,0.08);
    border-left: 1px solid #C8E6C9;
}
.sidebar-brand {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid #C8E6C9;
}
.sidebar-brand img { max-width: 60px; max-height: 60px; border-radius: 12px; margin-bottom: 8px; object-fit: contain; }
.sidebar-brand h5 { color: var(--primary); font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.sidebar-brand small { color: #558B2F; font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase; }
.brand-icon {
    width: 50px; height: 50px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
    color: #fff; font-size: 1.3rem;
}
.sidebar-section {
    padding: 15px 15px 5px;
    color: #558B2F;
    font-size: 0.7rem; font-weight: 700;
    letter-spacing: 1.5px; text-transform: uppercase;
}
.sidebar-menu { list-style: none; padding: 0 10px; margin: 0; }
.sidebar-menu li { margin-bottom: 3px; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 15px;
    color: #33691E; text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.9rem; font-weight: 500;
}
.sidebar-menu a:hover { background: var(--sidebar-hover); color: var(--primary-dark); }
.sidebar-menu a.active {
    background: linear-gradient(135deg, rgba(46,125,50,0.25), rgba(46,125,50,0.1));
    color: var(--primary-dark); font-weight: 700;
    border-right: 3px solid var(--primary);
}
.sidebar-menu a i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-menu .badge { margin-right: auto; font-size: 0.7rem; padding: 3px 8px; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ======= TOP NAVBAR ======= */
.top-navbar {
    position: fixed; top: 0; left: 0; right: 260px;
    height: 65px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 25px; z-index: 998;
}
.sidebar-toggle {
    background: none; border: none; font-size: 1.3rem;
    color: var(--text-dark); cursor: pointer; display: none;
}
.navbar-search { position: relative; width: 350px; }
.navbar-search input {
    width: 100%;
    border: 2px solid var(--border-color); border-radius: 25px;
    padding: 8px 20px;
    font-family: 'Tajawal'; font-size: 0.9rem;
    transition: var(--transition); background: var(--body-bg);
}
.navbar-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46,125,50,0.1); }
.search-results-dropdown {
    position: absolute; top: 100%; right: 0; left: 0;
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 400px; overflow-y: auto; z-index: 1000; margin-top: 5px;
}
.search-results-dropdown .search-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 15px; cursor: pointer; border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}
.search-results-dropdown .search-item:hover { background: #f8f9fa; }
.navbar-actions { display: flex; align-items: center; gap: 15px; }
.nav-icon {
    background: none; border: none; font-size: 1.2rem;
    color: var(--text-muted); cursor: pointer; position: relative;
    transition: var(--transition); text-decoration: none;
}
.nav-icon:hover { color: var(--primary); }
.nav-icon .badge {
    position: absolute; top: -8px; right: -8px; font-size: 0.6rem; padding: 2px 5px;
}
.user-avatar {
    width: 38px; height: 38px;
    background: var(--primary-gradient);
    color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem;
}

/* Notification Dropdown */
.notification-dropdown {
    display: none; position: absolute; top: 100%; left: 0;
    width: 360px; background: #fff;
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    z-index: 1000; margin-top: 10px;
    max-height: 400px; overflow-y: auto;
}
.notification-dropdown.show { display: block; }
.n-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 15px; border-bottom: 1px solid var(--border-color);
}
.n-item {
    padding: 10px 15px; border-bottom: 1px solid #f8f9fa;
    cursor: pointer; transition: var(--transition);
}
.n-item:hover { background: #f8f9fa; }
.n-item.unread { background: #E8F5E9; border-right: 3px solid var(--primary); }
.n-footer {
    text-align: center; padding: 10px;
    border-top: 1px solid var(--border-color);
}
.n-footer a { color: var(--primary); text-decoration: none; font-size: 0.85rem; font-weight: 600; }

/* ======= MAIN CONTENT ======= */
.main-content {
    margin-right: 260px; margin-top: 65px;
    padding: 25px; min-height: calc(100vh - 65px);
}
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ======= PAGE HEADER ======= */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; flex-wrap: wrap; gap: 15px;
}
.page-header h4 { font-weight: 700; color: var(--text-dark); margin: 0; }
.page-header .breadcrumb { margin: 0; font-size: 0.85rem; }
.page-header .breadcrumb a { color: var(--primary); text-decoration: none; }

/* ======= STAT CARDS ======= */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius); padding: 22px;
    box-shadow: var(--shadow); transition: var(--transition);
    border-right: 4px solid var(--primary);
    position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px; display: flex;
    align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff;
}
.stat-card h3 { font-weight: 800; font-size: 1.8rem; margin: 8px 0 3px; }
.stat-card p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

.stat-green .stat-icon { background: linear-gradient(135deg, #2E7D32, #66BB6A); }
.stat-blue .stat-icon { background: linear-gradient(135deg, #1565C0, #42A5F5); }
.stat-orange .stat-icon { background: linear-gradient(135deg, #E65100, #FF9800); }
.stat-purple .stat-icon { background: linear-gradient(135deg, #6A1B9A, #AB47BC); }
.stat-red .stat-icon { background: linear-gradient(135deg, #B71C1C, #EF5350); }
.stat-teal .stat-icon { background: linear-gradient(135deg, #00695C, #4DB6AC); }

.stat-green { border-right-color: #2E7D32; }
.stat-blue { border-right-color: #1565C0; }
.stat-orange { border-right-color: #E65100; }
.stat-purple { border-right-color: #6A1B9A; }
.stat-red { border-right-color: #B71C1C; }
.stat-teal { border-right-color: #00695C; }

/* ======= CARDS ======= */
.card { border: none; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header {
    background: var(--card-bg); border-bottom: 1px solid var(--border-color);
    padding: 18px 22px; font-weight: 700; font-size: 1rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-body { padding: 22px; }

/* ======= TABLES ======= */
.table { margin-bottom: 0; }
.table thead th {
    background: #E8F5E9; color: var(--primary-dark);
    font-weight: 700; font-size: 0.85rem;
    padding: 14px 15px; border-bottom: 2px solid #C8E6C9;
    white-space: nowrap;
}
.table tbody td { padding: 12px 15px; vertical-align: middle; font-size: 0.9rem; }
.table tbody tr { transition: var(--transition); border-bottom: 1px solid #f5f5f5; }
.table tbody tr:hover { background: #F1F8E9; }

/* ======= BUTTONS ======= */
.btn-primary {
    background: var(--primary-gradient); border: none;
    font-weight: 600; transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(46,125,50,0.4); }
.btn-success { background: #2E7D32; border-color: #2E7D32; }
.btn-success:hover { background: #1B5E20; border-color: #1B5E20; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-sm { font-size: 0.8rem; padding: 5px 12px; border-radius: 6px; }

/* ======= BADGES ======= */
.badge-status { padding: 5px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.badge-active { background: #E8F5E9; color: #2E7D32; }
.badge-inactive { background: #FFEBEE; color: #C62828; }
.badge-pending { background: #FFF3E0; color: #E65100; }
.badge-completed { background: #E8F5E9; color: #2E7D32; }
.badge-cancelled { background: #FFEBEE; color: #C62828; }

/* BMI Categories */
.bmi-underweight { color: #1976D2; font-weight: 700; }
.bmi-normal { color: #2E7D32; font-weight: 700; }
.bmi-overweight { color: #F57F17; font-weight: 700; }
.bmi-obese1 { color: #E65100; font-weight: 700; }
.bmi-obese2 { color: #BF360C; font-weight: 700; }
.bmi-obese3 { color: #B71C1C; font-weight: 700; }

/* ======= FORMS ======= */
.form-control, .form-select {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 15px; font-size: 0.9rem;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.1);
}
.form-label { font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }

/* ======= MODALS ======= */
.modal-content { border: none; border-radius: var(--radius); }
.modal-header {
    background: var(--primary-gradient); color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 18px 22px;
}
.modal-header .btn-close { filter: invert(1); }
.modal-header .modal-title { font-weight: 700; }

/* ======= LOADING OVERLAY ======= */
.loading-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(255,255,255,0.8);
    z-index: 99999;
    justify-content: center; align-items: center;
}
.loading-overlay.show, .loading-overlay[style*="block"] {
    display: flex !important;
}
.spinner-green {
    width: 45px; height: 45px;
    border: 4px solid #E8F5E9;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======= SETTINGS TABS ======= */
.settings-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 20px; }
.settings-tabs .tab-btn {
    padding: 8px 18px; border-radius: 20px;
    border: 2px solid var(--border-color);
    background: #fff; color: var(--text-muted);
    font-weight: 600; font-size: 0.85rem;
    cursor: pointer; transition: var(--transition);
}
.settings-tabs .tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.settings-tabs .tab-btn.active {
    background: var(--primary-gradient); color: #fff;
    border-color: transparent;
}
.tab-content-section { display: none; }
.tab-content-section.active { display: block; animation: fadeIn 0.3s ease; }

/* ======= POS ======= */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; min-height: calc(100vh - 130px); }
.pos-cart {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.pos-cart-header {
    background: var(--primary-gradient); color: #fff;
    padding: 15px 20px; border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 700; font-size: 1.1rem;
}
.pos-cart-items { flex: 1; overflow-y: auto; padding: 10px; }
.pos-cart-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-bottom: 1px solid var(--border-color);
}
.pos-cart-footer { padding: 15px 20px; border-top: 2px solid var(--border-color); }
.pos-total { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.pos-products-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.pos-product-card {
    background: var(--card-bg); border-radius: var(--radius-sm);
    padding: 15px; text-align: center; cursor: pointer;
    transition: var(--transition); border: 2px solid transparent;
    box-shadow: var(--shadow);
}
.pos-product-card:hover { border-color: var(--primary); transform: translateY(-2px); }

/* ======= WAITING SCREEN ======= */
.waiting-screen {
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%);
    min-height: 100vh; color: #fff;
    padding: 30px; display: flex; flex-direction: column;
}
.waiting-header {
    text-align: center; padding: 20px; margin-bottom: 30px;
}
.waiting-header h1 { font-size: 2.5rem; font-weight: 800; }
.waiting-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px; flex: 1;
}
.waiting-card {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: var(--radius); padding: 25px;
    text-align: center; border: 1px solid rgba(255,255,255,0.2);
    transition: var(--transition);
}
.waiting-card.active {
    background: rgba(255,255,255,0.95); color: var(--primary-dark);
    animation: pulse 2s infinite;
}
.waiting-number {
    font-size: 3rem; font-weight: 900;
    line-height: 1;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }

/* ======= QUEUE STATUS COLORS ======= */
.queue-waiting { background: #FFF3E0; color: #E65100; }
.queue-in-session { background: #E3F2FD; color: #1565C0; }
.queue-completed { background: #E8F5E9; color: #2E7D32; }

/* ======= CHARTS ======= */
.chart-container { position: relative; max-height: 300px; }

/* ======= EMPTY STATE ======= */
.empty-state {
    text-align: center; padding: 50px 20px;
}
.empty-state i { font-size: 4rem; color: #C8E6C9; margin-bottom: 15px; }
.empty-state h5 { color: var(--text-muted); font-weight: 600; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* ======= FILTER BAR ======= */
.filter-bar {
    display: flex; gap: 10px; align-items: center;
    flex-wrap: wrap; margin-bottom: 15px;
}
.filter-bar .form-control, .filter-bar .form-select {
    max-width: 200px; padding: 8px 12px; font-size: 0.85rem;
}

/* ======= PATIENT VIEW TABS ======= */
.nav-tabs .nav-link {
    color: var(--text-muted); font-weight: 600;
    border: none; padding: 10px 20px;
}
.nav-tabs .nav-link.active { color: var(--primary); border-bottom: 3px solid var(--primary); background: transparent; }
.nav-tabs .nav-link:hover { color: var(--primary); }

/* ======= MEAL PLAN GRID ======= */
.meal-plan-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day-column {
    background: var(--card-bg); border-radius: var(--radius-sm);
    padding: 12px; box-shadow: var(--shadow); min-height: 200px;
}
.day-column .day-name {
    text-align: center; font-weight: 700; color: var(--primary);
    padding-bottom: 8px; border-bottom: 2px solid #E8F5E9; margin-bottom: 10px;
}
.meal-item {
    background: #F1F8E9; border-radius: 6px; padding: 8px;
    margin-bottom: 6px; font-size: 0.82rem;
    border-right: 3px solid var(--primary-light);
}
.meal-item .meal-calories { color: var(--primary); font-weight: 700; font-size: 0.75rem; }

/* ======= PRINT ======= */
@media print {
    .sidebar, .top-navbar, .sidebar-overlay, .no-print, .btn { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; font-size: 12pt !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .stat-card { border: 1px solid #ddd !important; box-shadow: none !important; }
    @page { margin: 1cm; }
}

/* ======= RESPONSIVE ======= */
@media (max-width: 991px) {
    .sidebar { right: -260px; }
    .sidebar.show { right: 0; }
    .sidebar-toggle { display: block; }
    .top-navbar { right: 0; }
    .main-content { margin-right: 0; }
    .pos-layout { grid-template-columns: 1fr; }
    .meal-plan-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .navbar-search { width: 200px; }
    .stat-card h3 { font-size: 1.4rem; }
    .meal-plan-grid { grid-template-columns: repeat(2, 1fr); }
    .notification-dropdown { width: 300px; }
}
@media (max-width: 576px) {
    .main-content { padding: 15px; }
    .navbar-search { display: none; }
    .meal-plan-grid { grid-template-columns: 1fr; }
}
