/* SSR Platform - Main Stylesheet
   Sustainable & Smart Restaurant Design System
   Organic Green Theme with Natural Textures
*/

/* ======================================
   CSS Variables & Design Tokens
====================================== */
:root {
    /* Primary Greens */
    --green-50: #ecfdf5;
    --green-100: #d1fae5;
    --green-200: #a7f3d0;
    --green-300: #6ee7b7;
    --green-400: #34d399;
    --green-500: #10b981;
    --green-600: #059669;
    --green-700: #047857;
    --green-800: #065f46;
    --green-900: #064e3b;
    --green-950: #022c22;
    
    /* Forest Greens (Darker) */
    --forest-900: #0a3d2e;
    --forest-800: #0d5240;
    --forest-700: #127a5b;
    
    /* Neutrals */
    --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;
    
    /* Semantic Colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    
    /* Accent Colors */
    --accent-mint: #7df3b5;
    --accent-teal: #14b8a6;
    --accent-emerald: #34d399;
    
    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --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);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Layout */
    --nav-width: 260px;
    --header-height: 70px;
}

/* ======================================
   Reset & Base Styles
====================================== */
*, *::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-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

a {
    color: var(--green-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--green-700);
}

img {
    max-width: 100%;
    height: auto;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* ======================================
   Navigation
====================================== */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--nav-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--forest-900) 0%, var(--forest-800) 100%);
    display: flex;
    flex-direction: column;
    padding: var(--space-6);
    z-index: 100;
    overflow-y: auto;
}

.nav-brand {
    margin-bottom: var(--space-8);
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: white;
    text-decoration: none;
}

.nav-logo {
    font-size: 2rem;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.nav-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link i {
    font-size: 1.25rem;
    width: 24px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3px;
    height: 24px;
    background: var(--accent-mint);
    border-radius: 0 3px 3px 0;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: var(--space-4) 0;
}

.nav-admin {
    background: rgba(255, 255, 255, 0.05);
}

.nav-user {
    padding-top: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.nav-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.nav-user-name {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-user-role {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
}

.nav-user-actions {
    display: flex;
    gap: var(--space-2);
}

.nav-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.7);
    transition: all var(--transition-fast);
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ======================================
   Main Content Area
====================================== */
.main {
    min-height: 100vh;
    padding: var(--space-6);
}

.main.with-nav {
    margin-left: var(--nav-width);
}

/* ======================================
   Flash Messages
====================================== */
.flash-messages {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
}

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-success {
    border-left: 4px solid var(--color-success);
}

.flash-error {
    border-left: 4px solid var(--color-danger);
}

.flash-warning {
    border-left: 4px solid var(--color-warning);
}

.flash-info {
    border-left: 4px solid var(--color-info);
}

.flash-close {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.flash-close:hover {
    color: var(--gray-600);
}

/* ======================================
   Page Header
====================================== */
.page-header {
    margin-bottom: var(--space-8);
}

.page-title {
    font-size: 2rem;
    color: var(--forest-900);
    margin-bottom: var(--space-2);
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 1.1rem;
}

.page-header-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

/* ======================================
   Cards
====================================== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    overflow: hidden;
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-title i {
    color: var(--green-600);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* ======================================
   Stats Cards
====================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--green-500), var(--green-400));
}

.stat-card.warning::before {
    background: linear-gradient(90deg, var(--color-warning), #fbbf24);
}

.stat-card.danger::before {
    background: linear-gradient(90deg, var(--color-danger), #f87171);
}

.stat-card.info::before {
    background: linear-gradient(90deg, var(--color-info), #60a5fa);
}

.stat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-50);
    border-radius: var(--radius-md);
    color: var(--green-600);
    font-size: 1.5rem;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-trend.up {
    color: var(--color-success);
}

.stat-trend.down {
    color: var(--color-danger);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-1);
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.stat-comparison {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: var(--space-2);
}

/* ======================================
   Status Badges
====================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: var(--green-100);
    color: var(--green-700);
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-neutral {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ======================================
   Buttons
====================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--forest-800) 0%, var(--green-600) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
}

.btn-secondary:hover {
    border-color: var(--green-500);
    color: var(--green-600);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: 0.85rem;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: 1.1rem;
}

/* ======================================
   Forms
====================================== */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-fast);
    background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-help {
    margin-top: var(--space-2);
    font-size: 0.85rem;
    color: var(--gray-500);
}

.form-error {
    margin-top: var(--space-2);
    font-size: 0.85rem;
    color: var(--color-danger);
}

/* ======================================
   Tables
====================================== */
.table-container {
    overflow-x: auto;
}

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

.table th {
    text-align: left;
    padding: var(--space-4);
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-200);
}

.table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

/* ======================================
   Charts Container
====================================== */
.chart-container {
    position: relative;
    height: 300px;
}

.chart-container.tall {
    height: 400px;
}

/* ======================================
   Grid Layouts
====================================== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
}

@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ======================================
   Alerts List
====================================== */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--gray-300);
}

.alert-item.critical {
    border-left-color: var(--color-danger);
    background: #fef2f2;
}

.alert-item.warning {
    border-left-color: var(--color-warning);
    background: #fffbeb;
}

.alert-item.info {
    border-left-color: var(--color-info);
    background: #eff6ff;
}

.alert-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.alert-item.critical .alert-icon {
    background: #fee2e2;
    color: var(--color-danger);
}

.alert-item.warning .alert-icon {
    background: #fef3c7;
    color: var(--color-warning);
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-1);
}

.alert-message {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.alert-time {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: var(--space-2);
}

/* ======================================
   AI Chat Interface
====================================== */
.ai-chat {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ai-message {
    max-width: 80%;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
}

.ai-message.user {
    align-self: flex-end;
    background: var(--green-600);
    color: white;
    border-bottom-right-radius: var(--space-1);
}

.ai-message.assistant {
    align-self: flex-start;
    background: var(--gray-100);
    color: var(--gray-800);
    border-bottom-left-radius: var(--space-1);
}

.ai-input-container {
    padding: var(--space-4);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-3);
}

.ai-input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-full);
    font-size: 1rem;
}

.ai-input:focus {
    outline: none;
    border-color: var(--green-500);
}

.ai-send-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-600);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ai-send-btn:hover {
    background: var(--green-700);
    transform: scale(1.05);
}

/* ======================================
   Loading States
====================================== */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--green-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ======================================
   Empty States
====================================== */
.empty-state {
    text-align: center;
    padding: var(--space-12);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    color: var(--gray-500);
    margin-bottom: var(--space-6);
}

/* ======================================
   Progress Bars
====================================== */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--green-500), var(--green-400));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar.warning {
    background: linear-gradient(90deg, var(--color-warning), #fbbf24);
}

.progress-bar.danger {
    background: linear-gradient(90deg, var(--color-danger), #f87171);
}

/* ======================================
   Responsive Navigation
====================================== */
@media (max-width: 1024px) {
    .nav {
        width: 100%;
        height: auto;
        position: relative;
        padding: var(--space-4);
    }
    
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-2);
    }
    
    .nav-link span {
        display: none;
    }
    
    .nav-link {
        padding: var(--space-2);
    }
    
    .nav-user {
        display: none;
    }
    
    .main.with-nav {
        margin-left: 0;
    }
}

/* ======================================
   Utilities
====================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--gray-500); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
