/* ============================================
   NutriCare Pro - Healthcare Nutrition App
   Modern, Clean, Professional Design
   ============================================ */

/* CSS Variables */
:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    --secondary: #3b82f6;
    --accent: #f59e0b;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --sidebar-width: 260px;
    --header-height: 70px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
#login-screen {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-container {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-logo {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 3rem 2rem;
    text-align: center;
    color: white;
}

.login-logo i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-logo p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.login-form {
    padding: 2rem;
}

.role-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--gray-100);
    padding: 0.25rem;
    border-radius: var(--radius);
}

.role-btn {
    flex: 1;
    padding: 0.625rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.role-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.role-btn:hover:not(.active) {
    color: var(--gray-800);
}

.login-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.login-demo {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */
#main-app {
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-header i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-header span {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item i {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

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

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--gray-100);
    color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Content Header */
.content-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: var(--gray-50);
    border-radius: var(--radius);
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-icon .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 1.25rem;
    height: 1.25rem;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   VIEWS
   ============================================ */
.view {
    display: none;
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-bar {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-bar.wide {
    max-width: 600px;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.view-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.select-filter {
    padding: 0.625rem 2rem 0.625rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: white;
    font-size: 0.9rem;
    color: var(--gray-700);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em;
}

.btn-secondary {
    padding: 0.625rem 1rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

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

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.85rem;
}

/* ============================================
   DASHBOARD
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.stat-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.clients { background: #dbeafe; color: #2563eb; }
.stat-icon.meals { background: #d1fae5; color: #059669; }
.stat-icon.progress { background: #fef3c7; color: #d97706; }
.stat-icon.alerts { background: #fee2e2; color: #dc2626; }

.stat-info {
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.stat-change {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.stat-change.positive {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.stat-change.negative {
    background: #fee2e2;
    color: var(--danger);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dashboard-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.dashboard-card.full-width {
    grid-column: 1 / -1;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.select-sm {
    padding: 0.375rem 1.5rem 0.375rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.375rem center;
    background-repeat: no-repeat;
    background-size: 1.25em;
}

.link-sm {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.link-sm:hover {
    text-decoration: underline;
}

.chart-container {
    padding: 1.5rem;
    height: 300px;
}

.activity-list {
    padding: 0.5rem 0;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-50);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
    min-width: 0;
}

.activity-text {
    display: block;
    font-size: 0.9rem;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-text strong {
    color: var(--gray-800);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

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

.data-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

.client-cell {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.client-avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.client-info {
    display: flex;
    flex-direction: column;
}

.client-name {
    font-weight: 600;
    color: var(--gray-800);
}

.client-plan {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.badge-success {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.badge-warning {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: #fef3c7;
    color: #d97706;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.progress-bar {
    width: 100px;
    height: 0.5rem;
    background: var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-left: 0.5rem;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.btn-action {
    padding: 0.375rem 0.875rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

/* ============================================
   CLIENTS VIEW
   ============================================ */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.client-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
}

.client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.client-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.client-card-avatar {
    width: 3.5rem;
    height: 3.5rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
}

.client-card-info h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.client-card-info span {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.client-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}

.client-stat {
    text-align: center;
}

.client-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
}

.client-stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   MEAL PLANNER
   ============================================ */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calendar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    min-width: 200px;
    text-align: center;
}

.meal-planner-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    height: calc(100vh - 200px);
}

.meal-calendar {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.calendar-day-header {
    padding: 1rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-day-header .day-number {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-top: 0.25rem;
}

.calendar-day-header.today {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.calendar-day-header.today .day-number {
    color: var(--primary-dark);
}

.calendar-body {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 1px;
    background: var(--gray-200);
}

.calendar-cell {
    background: white;
    padding: 0.75rem;
    min-height: 120px;
    position: relative;
}

.calendar-cell:hover {
    background: var(--gray-50);
}

.meal-slot {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.meal-slot:hover {
    background: #a7f3d0;
}

.meal-slot .meal-name {
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meal-slot .meal-calories {
    color: var(--gray-500);
    font-size: 0.7rem;
}

.meal-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.meal-filters {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.meal-filters h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.75rem;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    padding: 0.375rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tag.active, .filter-tag:hover {
    background: var(--primary);
    color: white;
}

.food-search-box {
    position: relative;
}

.food-search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.food-search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.food-suggestions {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.food-suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.food-suggestion-item:hover {
    background: var(--gray-50);
}

.food-suggestion-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1rem;
}

.food-suggestion-info {
    flex: 1;
}

.food-suggestion-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-800);
}

.food-suggestion-cal {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ============================================
   FOOD DATABASE
   ============================================ */
.database-container {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 200px);
}

.database-filters {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.filter-section {
    margin-bottom: 1.5rem;
}

.filter-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--gray-600);
    cursor: pointer;
}

.filter-checkbox input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.database-results {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-y: auto;
    padding: 1rem;
}

.food-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: all 0.2s;
}

.food-item:hover {
    background: var(--gray-50);
}

.food-item-icon {
    width: 3rem;
    height: 3rem;
    background: var(--primary-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.food-item-info {
    flex: 1;
}

.food-item-name {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.food-item-category {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.food-item-nutrition {
    text-align: right;
}

.food-item-calories {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}

.food-item-serving {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ============================================
   BARCODE SCANNER
   ============================================ */
.scanner-container {
    max-width: 600px;
    margin: 0 auto;
}

.scanner-viewport {
    position: relative;
    background: var(--gray-900);
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 4/3;
    margin-bottom: 1.5rem;
}

#scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-frame {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.scanner-corners {
    position: absolute;
    width: 250px;
    height: 150px;
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 0;
}

.corner.tl {
    top: 0;
    left: 0;
    border-top-width: 4px;
    border-left-width: 4px;
}

.corner.tr {
    top: 0;
    right: 0;
    border-top-width: 4px;
    border-right-width: 4px;
}

.corner.bl {
    bottom: 0;
    left: 0;
    border-bottom-width: 4px;
    border-left-width: 4px;
}

.corner.br {
    bottom: 0;
    right: 0;
    border-bottom-width: 4px;
    border-right-width: 4px;
}

.scanner-line {
    position: absolute;
    width: 250px;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0%, 100% { top: calc(50% - 75px); opacity: 1; }
    50% { top: calc(50% + 75px); opacity: 0.5; }
}

.scanner-text {
    position: absolute;
    bottom: 2rem;
    color: white;
    font-size: 0.9rem;
    opacity: 0.8;
}

.scanner-controls {
    text-align: center;
    margin-bottom: 2rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.scanner-hint {
    margin: 1rem 0 0.5rem;
    color: var(--gray-500);
    font-size: 0.9rem;
}

.manual-entry {
    display: flex;
    gap: 0.75rem;
    max-width: 400px;
    margin: 0 auto;
}

.manual-entry input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.scanner-history {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.scanner-history h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

.scan-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.scan-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.scan-item i {
    color: var(--success);
    font-size: 1.1rem;
}

.scan-name {
    flex: 1;
    font-weight: 500;
    color: var(--gray-800);
}

.scan-cal {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.scan-time {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ============================================
   REPORTS
   ============================================ */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.report-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

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

.report-icon {
    width: 4rem;
    height: 4rem;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: var(--primary);
}

.report-card h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.report-card p {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.report-preview {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.preview-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.preview-actions {
    display: flex;
    gap: 0.75rem;
}

.preview-content {
    padding: 3rem;
    min-height: 400px;
}

.preview-placeholder {
    text-align: center;
    color: var(--gray-400);
    font-size: 1rem;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    backdrop-filter: blur(4px);
}

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

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 201;
    opacity: 0;
    transition: all 0.2s;
}

.modal.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.btn-close {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Nutrition Summary in Modal */
.nutrition-summary {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.nutrition-main {
    text-align: center;
    margin-bottom: 1rem;
}

.nutrition-main .calories {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.nutrition-main .label {
    display: block;
    font-size: 0.9rem;
    color: var(--gray-500);
}

.nutrition-macros {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.macro {
    text-align: center;
}

.macro-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.macro-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.serving-selector {
    margin-bottom: 1.5rem;
}

.serving-selector label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.serving-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.serving-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.serving-btn.active, .serving-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .meal-planner-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .meal-sidebar {
        order: -1;
    }
    
    .database-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .database-filters {
        display: flex;
        gap: 1rem;
        overflow-x: auto;
    }
    
    .filter-section {
        flex-shrink: 0;
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .clients-grid {
        grid-template-columns: 1fr;
    }
    
    .reports-grid {
        grid-template-columns: 1fr;
    }
    
    .view-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-bar {
        max-width: none;
    }
    
    .calendar-nav {
        justify-content: center;
    }
    
    .calendar-title {
        font-size: 0.9rem;
        min-width: auto;
    }
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    box-shadow: var(--shadow-lg);
    z-index: 150;
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view.active {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}