/* ═══════════════════════════════════════════════════════════════════
   ScanMaster Farm Portal · Styles
   Dark theme, premium feel, responsive
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0F1117;
    --bg-secondary: #1A1D27;
    --bg-tertiary: #252836;
    --text-primary: #E8E8ED;
    --text-secondary: #9CA3AF;
    --text-tertiary: #6B7280;
    --accent-cyan: #22D3EE;
    --accent-orange: #FB923C;
    --green: #4ADE80;
    --red: #F87171;
    --blue: #60A5FA;
    --border: rgba(255,255,255,0.06);
    --radius: 14px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── Screens ──────────────────────────────────────────────────── */

.screen { display: none; }
.screen.active { display: flex; }

/* ─── Login ────────────────────────────────────────────────────── */

#login-screen {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F1117 0%, #1a1040 50%, #0F1117 100%);
}

.login-container {
    text-align: center;
    width: 100%;
    max-width: 380px;
    padding: 40px 24px;
}

.login-logo {
    font-size: 56px;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 20px rgba(34, 211, 238, 0.3));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-tertiary);
    font-size: 13px;
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.input-group input::placeholder { color: var(--text-tertiary); }

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent-cyan), #06b6d4);
    border: none;
    border-radius: 10px;
    color: #000;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(34, 211, 238, 0.3);
}

.btn-primary:active { transform: translateY(0); }

.error-text {
    color: var(--red);
    font-size: 13px;
    text-align: center;
}

.login-footer {
    color: var(--text-tertiary);
    font-size: 11px;
    margin-top: 24px;
}

/* ─── Spinner ──────────────────────────────────────────────────── */

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner.large {
    width: 36px;
    height: 36px;
    border-width: 3px;
    color: var(--accent-cyan);
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ─── Portal ───────────────────────────────────────────────────── */

#portal-screen {
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon { font-size: 28px; }

.header-left h2 {
    font-size: 17px;
    font-weight: 700;
}

.week-badge {
    display: inline-block;
    background: var(--accent-cyan);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}

.btn-logout {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover { background: rgba(248,113,113,0.15); color: var(--red); }

/* ─── Summary Card ─────────────────────────────────────────────── */

.summary-card {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 16px 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    position: relative;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

.stat-value.confirmed { color: var(--green); }
.stat-value.deviation { color: var(--red); }
.stat-value.extra { color: var(--blue); }

.stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--green));
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ─── Batch Actions ────────────────────────────────────────────── */

.batch-actions {
    display: flex;
    gap: 12px;
    margin: 0 24px 12px;
}

.btn-confirm-all, .btn-submit {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-confirm-all {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.btn-confirm-all:hover {
    background: rgba(34, 211, 238, 0.2);
    transform: translateY(-1px);
}

.btn-submit {
    background: linear-gradient(135deg, var(--green), #22c55e);
    color: #000;
}

.btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.3);
}

/* ─── Search ───────────────────────────────────────────────────── */

.search-container {
    margin: 0 24px 12px;
}

.search-container input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-container input:focus {
    border-color: var(--accent-cyan);
}

/* ─── Orders Table ─────────────────────────────────────────────── */

.table-container {
    margin: 0 24px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th.num { text-align: right; }

td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

td.num { text-align: right; font-variant-numeric: tabular-nums; }

tr:hover { background: rgba(34, 211, 238, 0.03); }

tr.status-confirmed { border-left: 3px solid var(--green); }
tr.status-deviation { border-left: 3px solid var(--red); }
tr.status-extra { border-left: 3px solid var(--blue); }
tr.status-pending { border-left: 3px solid var(--text-tertiary); }

/* ─── Action Chips ─────────────────────────────────────────────── */

.action-chips {
    display: flex;
    gap: 4px;
}

.chip {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
}

.chip:hover { background: rgba(255,255,255,0.05); }

.chip.active-confirm {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--green);
    color: var(--green);
}

.chip.active-less {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--red);
    color: var(--red);
}

.chip.active-extra {
    background: rgba(96, 165, 250, 0.15);
    border-color: var(--blue);
    color: var(--blue);
}

/* ─── Inline Inputs ────────────────────────────────────────────── */

.inline-input {
    width: 70px;
    padding: 5px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    text-align: right;
}

.inline-input:focus { border-color: var(--accent-cyan); }

.inline-input.remarks {
    width: 120px;
    text-align: left;
}

/* ─── Loading Overlay ──────────────────────────────────────────── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 100;
    color: var(--text-secondary);
}

/* ─── Toast ────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    transition: transform 0.3s ease;
    white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* ─── Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
    .portal-header { padding: 12px 16px; }
    .summary-card { margin: 12px 16px; padding: 16px; }
    .batch-actions { margin: 0 16px 8px; flex-direction: column; }
    .search-container { margin: 0 16px 8px; }
    .table-container { margin: 0 16px 16px; }
    th, td { padding: 8px 10px; }
    .inline-input { width: 60px; }
    .inline-input.remarks { width: 90px; }
}

@media (max-width: 480px) {
    .summary-card { gap: 8px; }
    .stat-value { font-size: 18px; }
    .header-left h2 { font-size: 14px; }
}
