/* =========================================
   Web QC Sparepart - Styles
   Mobile-first responsive design
   ========================================= */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --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;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --nav-height: 56px;
    --header-height: 52px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* --- Login Screen --- */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    width: 100%;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-card h1 {
    font-size: 20px;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.login-card p {
    color: var(--gray-500);
    font-size: 13px;
    margin-bottom: 16px;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 12px;
}

.login-card input:focus {
    border-color: var(--primary);
}

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

/* --- Buttons --- */
.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }

.btn-secondary {
    padding: 10px 20px;
    background: var(--gray-200);
    color: var(--gray-700);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover { background: var(--gray-300); }

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    transition: background 0.15s;
}

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

/* --- App Header --- */
#app-header {
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    height: var(--header-height);
}

#page-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.header-right {
    display: flex;
    gap: 4px;
}

/* --- Upload Banner --- */
.upload-banner {
    background: var(--warning-bg);
    padding: 8px 16px;
    font-size: 12px;
    color: var(--gray-700);
    text-align: center;
    border-bottom: 1px solid #fde68a;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.filter-bar select,
.filter-bar input {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    background: white;
    color: var(--gray-700);
    flex: 1 1 140px;
    min-width: 0;
    outline: none;
}

.filter-bar select:focus,
.filter-bar input:focus {
    border-color: var(--primary);
}

/* --- Search Bar --- */
.search-bar {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.search-bar input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
}

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.stats-bar::-webkit-scrollbar { display: none; }

.stat-chip {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.stat-chip.total { background: var(--gray-100); color: var(--gray-600); }
.stat-chip.done { background: var(--success-bg); color: var(--success); }
.stat-chip.pending { background: var(--warning-bg); color: #b45309; }

/* --- Table Container --- */
.table-container {
    padding: 12px 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
}

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

/* --- Table Group (per destinasi) --- */
.table-group {
    margin-bottom: 20px;
}

.table-group-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-group-count {
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

/* --- Data Table --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th {
    background: var(--gray-100);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.data-table td {
    padding: 8px 10px;
    border-top: 1px solid var(--gray-100);
    color: var(--gray-700);
    white-space: nowrap;
}

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

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

/* --- QC Status Indicators --- */
.qc-done { color: var(--success); font-weight: 600; }
.qc-pending { color: var(--gray-400); }

/* --- Buttons in Tables --- */
.btn-sm {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-qc-yes {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.btn-qc-yes:hover { background: #bbf7d0; }

.btn-qc-no {
    background: var(--gray-100);
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
}

.btn-undo {
    background: var(--warning-bg);
    color: #b45309;
    border: 1px solid #fde68a;
    animation: fadeIn 0.3s;
}

/* --- Location Input --- */
.loc-input {
    padding: 5px 8px;
    border: 1.5px solid var(--gray-300);
    border-radius: 4px;
    font-size: 12px;
    width: 130px;
    outline: none;
    transition: border-color 0.2s;
}

.loc-input:focus { border-color: var(--primary); }

.loc-select {
    padding: 5px 8px;
    border: 1.5px solid var(--gray-300);
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    background: white;
    cursor: pointer;
}

/* --- Checkbox --- */
.check-cell {
    width: 36px;
    text-align: center;
}

.check-cell input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* --- Bottom Navigation --- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: white;
    border-top: 1px solid var(--gray-200);
    height: var(--nav-height);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--gray-400);
    transition: color 0.15s;
    padding: 6px 0;
}

.nav-btn.active {
    color: var(--primary);
}

.nav-icon { font-size: 20px; }
.nav-label { font-size: 10px; font-weight: 600; }

/* --- Modal --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
    animation: fadeIn 0.15s;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
}

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

.modal-body {
    padding: 16px;
}

/* --- Drop Zone --- */
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}

.drop-zone p { color: var(--gray-500); font-size: 14px; }
.drop-hint { font-size: 12px; margin-top: 6px; color: var(--gray-400) !important; }

/* --- Progress Bar --- */
.progress-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

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

#upload-msg {
    font-size: 13px;
    color: var(--gray-600);
    text-align: center;
}

#upload-last-info {
    margin-top: 12px;
    font-size: 12px;
    color: var(--gray-400);
    text-align: center;
}

/* --- Confirm Modal --- */
.confirm-question {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 16px;
}

#confirm-details {
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 13px;
}

#confirm-details .detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

#confirm-details .detail-label {
    font-weight: 600;
    color: var(--gray-500);
    min-width: 90px;
}

.confirm-actions {
    display: flex;
    gap: 8px;
}

.confirm-actions .btn-primary,
.confirm-actions .btn-secondary {
    flex: 1;
    width: auto;
}

#bulk-count {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 16px;
    text-align: center;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 300;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* --- Desktop tweaks --- */
@media (min-width: 768px) {
    .table-container {
        max-width: 1200px;
        margin: 0 auto;
    }

    .filter-bar {
        max-width: 1200px;
        margin: 0 auto;
    }

    .search-bar {
        max-width: 600px;
        margin: 0 auto;
        padding-bottom: 0;
    }

    .data-table td, .data-table th {
        padding: 10px 14px;
    }

    #page-qc .search-bar,
    #page-location .search-bar {
        max-width: 600px;
    }
}

@media (min-width: 1024px) {
    .data-table {
        font-size: 13px;
    }

    .data-table td, .data-table th {
        padding: 10px 16px;
    }
}
