/* --- Global Variables --- */
:root {
    --bg-gradient: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    --panel-bg: rgba(255, 255, 255, 0.03);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-sec: #94a3b8;
    --accent-color: #6366f1; /* Indigo */
    --accent-hover: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --modal-overlay: rgba(0, 0, 0, 0.8);
}

/* --- Base Reset --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }
body { background: var(--bg-gradient); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }

/* --- Glassmorphism --- */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* --- Layout --- */
.layout { display: flex; height: 100vh; padding: 1.25rem; gap: 1.25rem; }
.sidebar { width: 260px; display: flex; flex-direction: column; padding: 1.5rem; z-index: 10; }
.logo { display: flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; font-weight: 700; margin-bottom: 2.5rem; color: var(--text-primary); }
.logo i { font-size: 1.8rem; color: var(--accent-color); }
.nav-links { display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.nav-item {
    text-decoration: none; color: var(--text-sec); padding: 0.85rem 1rem; border-radius: 10px; display: flex; align-items: center; gap: 0.75rem; 
    font-weight: 500; font-size: 0.95rem; transition: all 0.3s;
}
.nav-item:hover, .nav-item.active { background: rgba(99, 102, 241, 0.12); color: var(--text-primary); transform: translateX(4px); }
.nav-item.active { border-left: 3px solid var(--accent-color); border-radius: 4px 12px 12px 4px; }

.restaurant-status { padding: 0.85rem; display: flex; align-items: center; gap: 0.85rem; margin-top: auto; }
.status-indicator { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-indicator.closed { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.status-texts { display: flex; flex-direction: column; }
.status-texts span { font-weight: 500; font-size: 0.85rem; }
.status-texts small { color: var(--text-sec); font-size: 0.7rem; }

/* --- Main Content --- */
.main-content { flex: 1; display: flex; flex-direction: column; gap: 1.25rem; overflow-y: hidden; }
.topbar { padding: 1.25rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.page-title h1 { font-size: 1.3rem; font-weight: 600; }
.page-title p { color: var(--text-sec); font-size: 0.85rem; }
.user-profile { display: flex; align-items: center; gap: 0.75rem; }
.avatar { width: 36px; height: 36px; background: rgba(255,255,255,0.05); border-radius: 50%; display: flex; align-items: center; justify-content: center; }

.content-wrapper { flex: 1; overflow-y: auto; padding-right: 5px; }
.content-wrapper::-webkit-scrollbar { width: 4px; }
.content-wrapper::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 10px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Cards & Tables --- */
.data-card { padding: 1.5rem; margin-bottom: 1.5rem; }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 1rem 0.75rem; text-align: left; border-bottom: 1px solid var(--panel-border); }
.data-table th { color: var(--text-sec); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; }
.data-table tbody tr { transition: 0.2s; cursor: pointer; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* --- Category Management --- */
.category-pills { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }
.pill {
    background: rgba(255,255,255,0.05); padding: 0.5rem 1rem; border-radius: 30px; font-size: 0.85rem; 
    display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--panel-border); transition: 0.2s;
}
.pill:hover { border-color: var(--accent-color); }
.pill i { cursor: pointer; color: var(--text-sec); font-size: 0.9rem; }
.pill i:hover { color: var(--danger); }

/* --- Chat Container --- */
.chat-container { display: flex; gap: 1.25rem; height: calc(100vh - 160px); }
.chat-sidebar { width: 300px; display: flex; flex-direction: column; overflow: hidden; }
.search-box { padding: 1rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid var(--panel-border); }
.search-box input { background: transparent; border: none; color: white; outline: none; width: 100%; font-size: 0.9rem; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-user-item { padding: 1rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.02); transition: 0.2s; }
.chat-user-item:hover, .chat-user-item.active { background: rgba(255,255,255,0.04); }
.chat-user-item.active { border-right: 3px solid var(--accent-color); }

.avatar-sm { width: 36px; height: 36px; background: rgba(99, 102, 241, 0.2); color: var(--accent-color); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.user-meta h5 { font-size: 0.85rem; }
.user-meta p { font-size: 0.7rem; color: var(--text-sec); }

.chat-window { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--panel-border); }
.chat-messages { flex: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; background: rgba(0,0,0,0.1); }
.message { max-width: 80%; padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.85rem; position: relative; }
.msg-user { align-self: flex-start; background: rgba(255,255,255,0.08); }
.msg-assistant { align-self: flex-end; background: var(--accent-color); }
.msg-time { display: block; font-size: 0.6rem; margin-top: 4px; opacity: 0.6; text-align: right; }

/* --- Modals --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--modal-overlay); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-content { width: 450px; padding: 2rem; position: relative; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-sec); margin-bottom: 0.5rem; text-transform: uppercase; }
.row-group-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* --- Buttons & Inputs --- */
.btn { padding: 0.6rem 1.2rem; border-radius: 8px; border: none; cursor: pointer; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 0.5rem; transition: 0.2s; }
.btn-primary { background: var(--accent-color); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { background: transparent; border: none; font-size: 1.5rem; color: var(--text-sec); cursor: pointer; }

.input-glass { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); padding: 0.75rem; border-radius: 8px; color: white; outline: none; }
.input-glass:focus { border-color: var(--accent-color); }
.input-glass-sm { background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); padding: 0.4rem 0.8rem; border-radius: 6px; color: white; outline: none; font-size: 0.85rem; }

.select-glass { background: rgba(255,255,255,0.05); color: white; border: 1px solid var(--panel-border); padding: 0.4rem; border-radius: 6px; outline: none; }
select.input-glass option, .select-glass option { color: #000; background: #fff; }

.action-icon { cursor: pointer; font-size: 1.2rem; transition: 0.2s; margin-right: 0.5rem; }
.action-icon:hover { color: var(--accent-color); }

.badge { padding: 0.25rem 0.6rem; border-radius: 20px; font-size: 0.7rem; font-weight: 600; }
.badge-hazirlaniyor { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-teslim { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-iptal { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* --- Animations --- */
.animate-in { animation: slideUp 0.5s ease-out forwards; }
.animate-scale { animation: scaleIn 0.3s ease-out forwards; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.loading-state { text-align: center; color: var(--text-sec); padding: 2rem; font-size: 0.9rem; }

/* === Login UI Fixes === */
.login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-gradient); z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 400px; padding: 2.5rem; text-align: center; }
.login-header i { font-size: 3rem; color: var(--accent-color); margin-bottom: 1rem; }
.login-header h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.login-header p { color: var(--text-sec); font-size: 0.9rem; margin-bottom: 2rem; }

/* Date Filter Styling */
#order-date-filter {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}
#order-date-filter::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.5;
    cursor: pointer;
}
#order-date-filter::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.stat-info h3 {
    font-size: 1.4rem;
    font-weight: 700;
}
.stat-info p {
    font-size: 0.8rem;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    
    /* Layout & Sidebar to Bottom Nav */
    .layout { flex-direction: column; padding: 0.5rem; gap: 0.5rem; padding-bottom: 70px; }
    .sidebar { position: fixed; bottom: 0; left: 0; width: 100%; flex-direction: row; padding: 0.5rem; z-index: 100; border-radius: 20px 20px 0 0; background: rgba(15, 23, 42, 0.95); justify-content: space-around; border: none; border-top: 1px solid var(--panel-border); height: 60px; }
    .logo, .restaurant-status, .nav-divider { display: none; }
    .nav-links { flex-direction: row; justify-content: space-around; width: 100%; gap: 0; }
    .nav-item { flex-direction: column; padding: 0.5rem; font-size: 0.65rem; gap: 0.2rem; border: none !important; border-radius: 8px; justify-content: center; }
    .nav-item i { font-size: 1.2rem; margin: 0; }
    .nav-item.active { background: transparent; color: var(--accent-color); transform: none; }
    
    /* Main Content */
    .topbar { padding: 0.75rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .page-title h1 { font-size: 1.1rem; }
    .user-profile { position: absolute; top: 0.75rem; right: 0.75rem; }
    .user-profile span { display: none; }
    
    .data-card { padding: 1rem; }
    .table-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .header-actions { width: 100%; flex-wrap: wrap; justify-content: space-between; }
    
    /* Table scroll */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
    .data-table th, .data-table td { padding: 0.75rem 0.5rem; font-size: 0.85rem; white-space: nowrap; }
    
    /* Modals */
    .modal-content, .report-content { width: 95%; max-width: none; padding: 1.25rem; max-height: 90vh; }
    .row-group-2 { grid-template-columns: 1fr; gap: 0.5rem; }
    
    /* Chat Mobile View */
    .chat-container { flex-direction: column; height: calc(100vh - 180px); }
    .chat-sidebar { width: 100%; flex: 1; border-radius: 12px; }
    .chat-window-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-gradient); z-index: 200; display: none; flex-direction: column; padding: 0.5rem; }
    .chat-window-wrapper.mobile-active { display: flex; }
    .chat-window { height: 100%; border-radius: 12px; }
    .mobile-back-btn { display: block !important; margin-right: 10px; color: var(--text-primary); }
    .chat-header { padding: 0.75rem; }
    
    /* Zones Map */
    #map { height: 300px !important; }
}

/* Hide mobile back btn on desktop */
.mobile-back-btn { display: none; }

/* Modal Overlay Animation for Reports */
.modal-overlay.reports { background: rgba(0,0,0,0.9); }
.report-content { width: 600px; max-height: 80vh; overflow-y: auto; }
.report-row { display: flex; justify-content: space-between; padding: 0.75rem 0; border-bottom: 1px solid var(--panel-border); }
.report-row.total { border-top: 2px solid var(--accent-color); font-weight: 700; margin-top: 1rem; color: var(--accent-color); }
