/* ============================================================
   Venba WMS — Main Stylesheet
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --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;
    --sidebar-width: 250px;
    --header-height: 60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
}

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

/* ── Layout ────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span {
    color: var(--primary);
}

.sidebar-nav { padding: 12px 0; }

.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin-top: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-300);
    font-size: 13.5px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--gray-800);
    color: white;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

/* ── Header ────────────────────────────────────────────── */
.top-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 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.header-user .role-badge {
    font-size: 11px;
}

.header-switcher {
    display: inline-flex;
    align-items: center;
}

.header-switcher select.form-control-sm {
    padding: 4px 8px;
    font-size: 12px;
    height: auto;
    min-width: 100px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
    background: #fff;
    cursor: pointer;
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.bulk-action-bar {
    padding: 12px 16px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

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

/* ── Page Content ──────────────────────────────────────── */
.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* ── Stat Cards ────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    font-size: 12.5px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ── Tables ────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
}

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

table th, table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

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

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; opacity: 0.9; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }

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

.btn-outline {
    background: white;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); color: var(--gray-900); }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}
.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.2;
    border-radius: 4px;
}
.shelf-product-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 13px;
}
.shelf-product-row + .shelf-product-row {
    border-top: 1px solid var(--gray-200);
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* ── Badges ────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-pending   { background: var(--warning-light); color: var(--warning); }
.badge-preparing { background: var(--primary-light); color: var(--primary); }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-in_progress { background: var(--primary-light); color: var(--primary); }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }

.badge-admin { background: var(--danger-light); color: var(--danger); }
.badge-picker { background: var(--primary-light); color: var(--primary); }
.badge-manager { background: var(--info-light); color: var(--info); }
.badge-stocker { background: #f0fdf4; color: #15803d; }
.badge-received { background: var(--primary-light); color: var(--primary); }
.badge-shelved { background: var(--success-light); color: var(--success); }

.role-badge { padding: 2px 8px; font-size: 10px; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: var(--font);
    transition: border-color 0.15s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* ── Bare form elements (no .form-control class) inherit the same look ── */
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="url"], input[type="date"],
input[type="datetime-local"], input[type="time"], input[type="month"], input:not([type]),
select, textarea {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: var(--font);
    background: white;
    color: var(--gray-800, inherit);
    transition: border-color 0.15s;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="search"]:focus, input[type="tel"]:focus,
input[type="url"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus,
input[type="time"]:focus, input[type="month"]:focus, input:not([type]):focus,
select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Custom dropdown arrow for every select */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-inline {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-inline .form-group { margin-bottom: 0; }

/* ── Flash Messages ────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid #a5f3fc; }

/* ── Progress Bar ──────────────────────────────────────── */
.progress {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-bar.green { background: var(--success); }
.progress-bar.yellow { background: var(--warning); }

.progress-text {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ── Shelf Grid ────────────────────────────────────────── */
.shelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.shelf-cell {
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.shelf-cell:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.shelf-cell.empty {
    background: white;
    border-color: var(--gray-300);
    color: var(--gray-400);
}

.shelf-cell.partial {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.shelf-cell.full {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.shelf-cell .shelf-code {
    font-size: 10px;
    display: block;
}

.shelf-cell .shelf-qty {
    font-size: 14px;
    display: block;
    margin-top: 2px;
}

.shelf-cell.shelf-storage { border-left: 3px solid var(--primary); }
.shelf-cell.shelf-preparation { border-left: 3px solid var(--success); }

/* Barcode display */
.barcode-text {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Item row actions */
.item-actions { display: flex; gap: 4px; align-items: center; }
.item-actions select { min-width: 140px; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
}

.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Context Menu ──────────────────────────────────────── */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 300;
    padding: 4px;
    display: none;
}

.context-menu.active { display: block; }

.context-menu-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: var(--gray-100);
}

.context-menu-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* ── Tracking Board ────────────────────────────────────── */
.board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    overflow-x: auto;
}

.board-column {
    min-width: 200px;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 12px;
}

.board-column-header {
    font-weight: 600;
    font-size: 13px;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.board-column-count {
    background: var(--gray-300);
    color: var(--gray-700);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 50px;
}

.board-card {
    background: white;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.board-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.board-card .order-no {
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-900);
}

.board-card .picker-name {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.board-card .card-progress {
    margin-top: 8px;
}

.board-card .card-elapsed {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 6px;
}

/* ── Slide Panel ───────────────────────────────────────── */
.slide-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.slide-panel-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-lg);
    z-index: 201;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.slide-panel.active {
    right: 0;
}

.slide-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.slide-panel-body {
    padding: 20px;
}

/* ── Timeline ──────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 16px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item .timeline-time {
    font-size: 11px;
    color: var(--gray-400);
}

.timeline-item .timeline-action {
    font-size: 13px;
    font-weight: 500;
}

.timeline-item .timeline-user {
    font-size: 12px;
    color: var(--gray-500);
}

.timeline-item .timeline-note {
    font-size: 12px;
    color: var(--gray-600);
    background: var(--gray-50);
    padding: 6px 10px;
    border-radius: 4px;
    margin-top: 4px;
}

/* ── Filter Bar ────────────────────────────────────────── */
.filter-bar {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

/* ── Login Page ────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
}

.login-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--gray-900);
}

.login-box .subtitle {
    color: var(--gray-500);
    margin-bottom: 28px;
    font-size: 14px;
}

.login-box .form-group { margin-bottom: 20px; }

.login-box .btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    justify-content: center;
}

/* ── Utilities ─────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: 12px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mr-8 { margin-right: 8px; }
.fw-bold { font-weight: 600; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .board { grid-template-columns: repeat(3, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
