/* CSS Variables - Light Theme (Default) */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-primary: #ea580c;
    --accent-secondary: #f97316;
    --accent-glow: rgba(234, 88, 12, 0.12);
    
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --info: #2563eb;
    
    --status-alert: #dc2626;
    --status-pending: #ca8a04;
    --status-in_warehouse: #16a34a;
    --status-at_repair_center: #2563eb;
    --status-shipped_to_customer: #7c3aed;
    --status-in_transit: #0891b2;
    
    --font-sans: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

/* CSS Variables - Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-card: #1a1a1d;
    --bg-hover: #232326;
    
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --accent-primary: #f97316;
    --accent-secondary: #fb923c;
    --accent-glow: rgba(249, 115, 22, 0.15);
    
    --border-color: #27272a;
    --border-light: #3f3f46;
    
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --status-alert: #ef4444;
    --status-pending: #eab308;
    --status-in_warehouse: #22c55e;
    --status-at_repair_center: #3b82f6;
    --status-shipped_to_customer: #8b5cf6;
    --status-in_transit: #06b6d4;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: 
        radial-gradient(ellipse at top, rgba(249, 115, 22, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(249, 115, 22, 0.05) 0%, transparent 40%),
        var(--bg-primary);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: var(--radius-lg);
    color: white;
}

.logo-icon.small {
    width: auto;
    height: 32px;
    border-radius: 0;
    background: transparent;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.login-header .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--danger);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* App Layout */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--accent-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-form {
    margin-bottom: 1rem;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input-wrapper svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.btn-search {
    padding: 0.625rem 1.25rem;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-search:hover {
    background: var(--accent-secondary);
}

.search-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-info strong {
    color: var(--accent-primary);
}

.clear-search {
    color: var(--accent-primary);
    text-decoration: none;
}

.clear-search:hover {
    text-decoration: underline;
}

/* Error Banner */
.error-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--danger);
    margin-bottom: 1.5rem;
}

.info-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    color: #3b82f6;
    margin-bottom: 1.5rem;
}

/* Table */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table th {
    background: var(--bg-tertiary);
    padding: 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

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

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

.clickable-row:hover {
    background: var(--bg-hover);
}

.cell-id {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.sn-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-primary);
}

.sn-badge.large {
    font-size: 1rem;
    padding: 0.375rem 0.875rem;
}

.type-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--info);
}

.type-badge.empty {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-alert {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-alert);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-pending {
    background: rgba(234, 179, 8, 0.15);
    color: var(--status-pending);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.status-in_warehouse {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-in_warehouse);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-at_repair_center {
    background: rgba(59, 130, 246, 0.15);
    color: var(--status-at_repair_center);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-shipped_to_customer {
    background: rgba(139, 92, 246, 0.15);
    color: var(--status-shipped_to_customer);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.status-in_transit {
    background: rgba(6, 182, 212, 0.15);
    color: var(--status-in_transit);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.status-unknown {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.status-scrapped {
    background: rgba(113, 113, 122, 0.2);
    color: #71717a;
    border: 1px solid rgba(113, 113, 122, 0.4);
    text-decoration: line-through;
}

/* Good/Bad Badges */
.good-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.good-badge.good {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.good-badge.bad {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.good-badge.unknown {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.scrapped-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.scrapped-badge.yes {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.scrapped-badge.no {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.cell-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Empty State */
.empty-row {
    text-align: center;
    padding: 3rem !important;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    opacity: 0.5;
}

/* Table Footer */
.table-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.item-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Detail Page */
.detail-page {
    max-width: 1200px;
}

.detail-header {
    margin-bottom: 2rem;
}

.detail-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.detail-badges {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.detail-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.info-value.uuid {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

/* Logs Timeline */
.logs-section {
    margin-top: 2rem;
}

.logs-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.logs-timeline {
    display: flex;
    flex-direction: column;
}

.log-item {
    display: flex;
    gap: 1rem;
    position: relative;
}

.log-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 24px;
    flex-shrink: 0;
}

.marker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
    z-index: 1;
}

.marker-line {
    flex: 1;
    width: 2px;
    background: var(--border-color);
    margin-top: 4px;
}

.log-item:last-child .marker-line {
    display: none;
}

.log-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    overflow: hidden;
}

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

.operation-badge {
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.op--1 { /* Alert */
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.op-0 { /* Pending */
    background: rgba(234, 179, 8, 0.15);
    color: var(--warning);
}

.op-1 { /* Receive */
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.op-2 { /* Ship */
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.log-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.log-body {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.log-row {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.log-row.full-width {
    grid-column: 1 / -1;
}

.log-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.log-value {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.log-value.tracking {
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.log-value.notes {
    white-space: pre-wrap;
    color: var(--text-secondary);
}

.empty-logs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}

.empty-logs svg {
    opacity: 0.5;
}

/* Error Page */
.error-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.error-card {
    text-align: center;
    max-width: 400px;
}

.error-icon {
    margin-bottom: 1.5rem;
    color: var(--danger);
}

.error-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.error-card .error-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .header-content {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .data-table {
        display: block;
        overflow-x: auto;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .log-body {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card,
.detail-card,
.log-card {
    animation: fadeIn 0.3s ease;
}

.clickable-row {
    animation: fadeIn 0.3s ease;
    animation-fill-mode: both;
}

.clickable-row:nth-child(1) { animation-delay: 0.02s; }
.clickable-row:nth-child(2) { animation-delay: 0.04s; }
.clickable-row:nth-child(3) { animation-delay: 0.06s; }
.clickable-row:nth-child(4) { animation-delay: 0.08s; }
.clickable-row:nth-child(5) { animation-delay: 0.1s; }

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    border-color: var(--border-light);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* Light theme: show moon (to switch to dark) */
:root .theme-toggle .icon-moon {
    display: block;
}

/* Dark theme: show sun (to switch to light) */
[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Login page theme toggle */
.login-theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
}

/* Old System Records Section */
.old-system-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px dashed var(--border-color);
}

.old-system-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    border-radius: var(--radius-lg);
    color: white;
}

.old-system-header svg {
    flex-shrink: 0;
}

.old-system-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.old-system-count {
    font-size: 0.875rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-weight: 500;
}

.old-system-table {
    overflow-x: auto;
}

.old-system-table .data-table {
    font-size: 0.8rem;
}

.old-system-table .data-table th,
.old-system-table .data-table td {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.old-system-table .data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.old-system-table .data-table tr:hover {
    background: var(--bg-hover);
}

