﻿/* 
    Smart Picking - Operational Control Center Design System
    Focus: High Density, Reading Speed, Operational Command
*/

:root {
    /* --- Core Identity (Dark Mode Default) --- */
    --color-heading: #f8fafc;
    --color-heading-secondary: #cbd5e1;
    --blue-primary: #3b82f6;
    --blue-soft: rgba(59, 130, 246, 0.15);
    
    /* --- Functional Status Palette --- */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #0ea5e9;
    --info-bg: rgba(14, 165, 233, 0.12);
    --muted: #94a3b8;
    --muted-bg: rgba(148, 163, 184, 0.1);

    /* --- Surfaces & Depth --- */
    --bg-main: #020617;
    --bg-card: #0f172a;
    --bg-sidebar: #0f172a;
    --bg-subtle: rgba(255, 255, 255, 0.03);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #3b82f6;
    
    /* --- Sidebar --- */
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-text-muted: #64748b;
    --sidebar-active-bg: rgba(59, 130, 246, 0.15);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    
    /* --- Typography --- */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-on-dark: #ffffff;
    
    /* --- Layout Constants --- */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
}

/* --- Light Mode Overrides --- */
body.light-mode {
    --color-heading: #0f172a;
    --color-heading-secondary: #334155;
    
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-subtle: rgba(0, 0, 0, 0.02);
    --bg-hover: rgba(0, 0, 0, 0.04);
    --border-color: rgba(15, 23, 42, 0.1);
    
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-text-muted: #64748b;
    --sidebar-active-bg: rgba(59, 130, 246, 0.2);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-border: rgba(255, 255, 255, 0.08);
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-dark: #ffffff;
    
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger-bg: rgba(239, 68, 68, 0.08);
    --info-bg: rgba(14, 165, 233, 0.1);
    --muted-bg: rgba(148, 163, 184, 0.08);
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* --- Base Resets --- */
* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* --- Sidebar (Always Dark) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--sidebar-text);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    transform: translateX(-100%);
    border-right: 1px solid var(--sidebar-border);
}

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

.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1500; display: none; backdrop-filter: blur(4px);
}
body.sidebar-open .sidebar-overlay { display: block; }

.sidebar-logo {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem; margin-bottom: 2rem;
}

.logo-icon {
    width: 36px; height: 36px;
    background: var(--blue-primary);
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
}

.sidebar-nav { flex: 1; }

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

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--blue-primary);
}

.nav-item:hover:not(.active) {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

/* --- Main Container --- */
.main-container {
    flex: 1;
    margin-left: 0;
    padding: 1.25rem;
    max-width: 100%;
}

/* --- Header --- */
.app-header {
    height: var(--header-height);
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem;
    background: var(--bg-card);
    padding: 0 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title h1 {
    font-size: 1.25rem; font-weight: 800;
    color: var(--color-heading); letter-spacing: -0.01em;
}

.menu-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--color-heading);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--blue-primary);
    color: var(--blue-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* --- KPI Cards (High Density) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 4px; height: 100%; background: var(--blue-primary);
}

.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.urgent::before { background: var(--danger); }

.stat-label {
    font-size: 0.75rem; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.025em;
    margin-bottom: 0.25rem; display: block;
}

.stat-value {
    font-size: 1.75rem; font-weight: 800;
    color: var(--color-heading); line-height: 1.2;
}

.stat-footer {
    font-size: 0.75rem; color: var(--text-muted);
    margin-top: 0.5rem; display: flex; align-items: center; gap: 0.25rem;
}

/* --- Data Tables --- */
.data-table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-subtle);
}

.table-header h3 { font-size: 1rem; font-weight: 700; color: var(--color-heading); }

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

.data-table th {
    padding: 0.875rem 1.25rem;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.7rem; font-weight: 800;
    text-transform: uppercase; color: var(--text-muted);
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem; vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg-hover); }

/* --- Badges & Status --- */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.7rem; font-weight: 700;
    display: inline-flex; align-items: center; gap: 0.375rem;
    text-transform: uppercase;
}

.badge-status-awaiting { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }
.badge-status-picking { background: var(--info-bg); color: var(--info); }
.badge-status-done { background: var(--success-bg); color: var(--success); }
.badge-status-urgent { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-status-warning { background: var(--warning-bg); color: var(--warning); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.625rem 1.25rem; border-radius: var(--radius-sm);
    font-weight: 600; cursor: pointer; transition: all 0.2s;
    border: 1px solid transparent; gap: 0.5rem; font-size: 0.875rem;
}

.btn-primary {
    background: var(--blue-primary); color: white;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-outline {
    background: transparent; border-color: var(--border-color); color: var(--text-main);
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--color-heading-secondary); }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
label {
    display: block; font-size: 0.75rem; font-weight: 700;
    margin-bottom: 0.375rem; color: var(--text-muted);
    text-transform: uppercase;
}

input[type="text"], input[type="number"], select {
    width: 100%; padding: 0.75rem 1rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.875rem; transition: all 0.2s;
}

input:focus, select:focus {
    outline: none; border-color: var(--border-focus);
    background: var(--bg-hover);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* --- Picking Execution (Tablet Optimized) --- */
.picking-execution-grid {
    display: grid; gap: 1rem;
    max-width: 1400px; margin: 0 auto;
}

.execution-side-panel {
    background: var(--bg-card); border-radius: var(--radius-md);
    border: 1px solid var(--border-color); overflow: hidden;
    display: flex; flex-direction: column;
}

.picking-header {
    background: #1e293b; color: white;
    padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: center;
}

.current-task-card {
    background: var(--bg-card); border-radius: var(--radius-md);
    padding: 1.5rem; border: 2px solid var(--blue-primary);
    display: flex; justify-content: space-between; align-items: center;
}

.task-address {
    font-size: 2.5rem; font-weight: 900; color: var(--blue-primary);
    line-height: 1; letter-spacing: -0.02em;
}

.quantity-confirmation-card {
    background: var(--bg-subtle); padding: 2rem;
    border-radius: var(--radius-md); text-align: center;
    border: 1px dashed var(--border-color);
}

.qty-input {
    width: 100%; max-width: 200px; padding: 1rem;
    font-size: 2.5rem; font-weight: 900; text-align: center;
    border: 3px solid var(--blue-primary); border-radius: var(--radius-md);
}

/* --- Responsive Utilities --- */
@media (min-width: 1024px) {
    .main-container { padding: 1.5rem 2rem; }
}

@media (min-width: 768px) and (orientation: landscape) {
    body.execution-page .app-header { display: flex; }
    body.execution-page .main-container { 
        height: calc(100vh - 64px); 
        overflow: hidden; 
        padding: 1rem; 
    }
    
    .picking-execution-grid { 
        display: grid;
        grid-template-columns: 1fr 1fr; 
        height: 100%; 
        gap: 1.25rem;
        align-items: stretch;
        max-width: 100%;
        margin: 0;
    }

    .execution-side-panel, .execution-main-panel {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .execution-main-panel {
        gap: 0.875rem;
        justify-content: space-between;
    }
}

/* --- Theme Toggle Button --- */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--color-heading);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--blue-primary);
    color: var(--warning);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.light-mode .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.light-mode .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

/* Smooth body transition for theme change */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-header,
.stat-card,
.data-table-container,
.execution-side-panel,
.btn-outline {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

/* Light mode specific refinements */
body.light-mode .sidebar {
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

body.light-mode .app-header {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body.light-mode .stat-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.light-mode .badge-status-awaiting {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
}

body.light-mode input[type="text"],
body.light-mode input[type="number"],
body.light-mode select {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(15, 23, 42, 0.15);
}

body.light-mode input:focus,
body.light-mode select:focus {
    background: #ffffff;
    border-color: var(--blue-primary);
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade { animation: fadeIn 0.3s ease-out forwards; }