/* ============================================
   Logistics SaaS — Design System
   Dark theme, glassmorphism, Inter font
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* CSS Variables */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.05);

    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 260px;
    --header-height: 64px;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-primary-hover); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== GLASS CARD ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: var(--transition);
}
.card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: 24px; }

/* ===== STAT CARDS ===== */
.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 16px;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.stat-card .stat-change {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px;
    border: none; border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}
.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { border-color: var(--border-color-hover); background: var(--bg-card-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-input::placeholder { color: var(--text-muted); }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
tbody tr {
    transition: var(--transition);
}
tbody tr:hover { background: var(--bg-glass); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-default { background: var(--bg-input); color: var(--text-secondary); }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}
.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-logo .logo-icon {
    width: 40px; height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    color: white;
    font-weight: 800;
}
.sidebar-logo .logo-text {
    font-size: 1.1rem;
    font-weight: 700;
}
.sidebar-logo .logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500; font-size: 0.9rem;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}
.sidebar-user {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}
.sidebar-user .user-avatar {
    width: 36px; height: 36px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; color: white;
}
.sidebar-user .user-name { font-weight: 600; font-size: 0.85rem; }
.sidebar-user .user-role { font-size: 0.75rem; color: var(--text-muted); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.page-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 50;
}
.page-title {
    font-size: 1.4rem;
    font-weight: 700;
}
.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.page-body { padding: 32px; }

/* ===== GRID ===== */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== KANBAN ===== */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    min-height: 500px;
}
.kanban-column {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
}
.kanban-column-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
}
.kanban-column-title { font-weight: 700; font-size: 0.9rem; }
.kanban-column-count {
    background: var(--bg-input);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.kanban-column-body {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
}
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    transition: var(--transition);
    cursor: pointer;
}
.kanban-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.kanban-card .card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.kanban-card .order-id {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent-primary);
}
.kanban-card .customer-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.kanban-card .card-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.kanban-card .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%; max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-size: 1.2rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; border: none; cursor: pointer;
    background: var(--bg-input); color: var(--text-secondary);
    transition: var(--transition);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex; gap: 12px; justify-content: flex-end;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed; top: 24px; right: 24px; z-index: 2000;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    display: flex; align-items: center; gap: 12px;
    min-width: 300px; max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    font-size: 0.9rem;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== LOADING ===== */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: absolute; inset: 0;
    background: rgba(10, 14, 26, 0.7);
    display: flex; align-items: center; justify-content: center;
    border-radius: inherit;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        var(--bg-primary);
}
.login-card {
    width: 100%; max-width: 420px;
    padding: 40px;
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-icon {
    width: 64px; height: 64px;
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: white; font-weight: 800;
    box-shadow: var(--shadow-glow);
    margin-bottom: 16px;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 700; }
.login-logo p { color: var(--text-secondary); font-size: 0.9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .kanban-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .kanban-board { grid-template-columns: 1fr; }
    .page-body { padding: 16px; }
}
