:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    
    --font-main: 'Outfit', sans-serif;
    --border-radius: 16px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(80px + var(--safe-area-bottom, 0px)); /* Space for bottom nav + safe area */
}

/* Typography */
h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: 1.2rem; font-weight: 500; margin-bottom: 0.8rem; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.875rem; }
.gradient-text {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout utilities */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.w-100 { width: 100%; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.text-center { text-align: center; }

/* Views */
.view {
    display: none;
    padding: 20px;
    animation: fadeIn 0.4s ease forwards;
}
.view.active {
    display: block;
}

/* Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding-top: 12px;
    padding-bottom: calc(12px + var(--safe-area-bottom, 0px)); /* Dynamic padding for system nav bar */
    z-index: 1000;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 6px;
    font-family: inherit;
    font-size: 0.7rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item.active {
    color: var(--primary);
    transform: translateY(-2px);
}

/* Cards & Elements */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glassmorphism {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}
.form-row {
    display: flex;
    gap: 15px;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-modern {
    width: 100%;
    padding: 12px 16px;
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.input-modern:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}
.btn-large {
    padding: 14px 24px;
    font-size: 1.1rem;
}

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

.btn-secondary { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background-color: #334155; }

.btn-success { background-color: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background-color: var(--success-hover); }

.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background-color: var(--danger-hover); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-icon {
    background: #334155;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Specialized UI Components */
.stations-counter {
    display: flex;
    align-items: center;
    gap: 10px;
}
.stations-counter input { width: 80px; }

.station-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    animation: fadeIn 0.3s;
}
.station-number {
    background: var(--primary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Run Dashboard */
.dashboard-header { text-align: center; }
.timer-display {
    font-size: 3.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin: 10px 0 20px;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}
.timer-display.small { font-size: 2rem; margin: 10px 0; }
.run-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.error-card {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}
.breakdown-header { text-align: center; color: var(--danger); }

/* Grid items */
.stations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}
.station-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}
.station-card .name { font-weight: 600; font-size: 1rem; }
.station-card .scrap-count {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Lists */
.list-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.list-item-content h4 { margin-bottom: 5px; }
.list-item-actions { display: flex; gap: 8px; }

/* History specific */
.history-card {
    border-left: 4px solid var(--primary);
}
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 15px;
    background: #0f172a;
    padding: 12px;
    border-radius: 8px;
}
.metric-item {
    text-align: center;
}
.metric-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
}
.metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.metric-value.excellent { color: var(--success); }
.metric-value.good { color: var(--warning); }
.metric-value.poor { color: var(--danger); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}
.modal-content {
    width: 100%;
    max-width: 400px;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Utilities */
.hidden { display: none !important; }

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

/* Stats grid */
.stats-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
}
.stat-box {
    flex: 1;
    background: #0f172a;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
}
.stat-box .label { display: block; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 5px; }
.stat-box .value { display: block; font-size: 1.4rem; font-weight: bold; }

/* Chart */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

/* Custom Dropdown */
.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.custom-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.custom-dropdown-item:last-child {
    border-bottom: none;
}
.custom-dropdown-item:hover {
    background: var(--primary);
    color: white;
}

/* Centrare verticala ergonomica pentru pagina Run & Rate */
#view-run {
    padding-top: 20vh; 
}

/* Spațiu suplimentar între titlul Run & Rate și chenarul de selecție */
#run-setup {
    margin-top: 40px; 
}

/* --- TWEAKS PAGINA MANAGEMENT LINII --- */
#view-lines {
    padding-top: 10vh; /* Coboară textul 'Management Linii' mai jos */
}
.add-line-card {
    margin-top: 30px; /* Spațiu după textul 'Configurați liniile...' */
}

/* --- TWEAKS PAGINA ISTORIC --- */
#view-history .view-header {
    padding-top: 15px;
    margin-bottom: 30px; /* Spațiu după butoanele Trimite / Excel */
}

#view-compare .view-header {
    padding-top: 15px;
    margin-bottom: 25px;
}

/* Pareto Modal Styles */
.photo-slot {
    flex: 1;
    height: 90px;
    background: rgba(255,255,255,0.05);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}
.photo-slot i {
    font-size: 1.4rem;
    color: var(--text-secondary);
}
.photo-slot .preview-img {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
}
.photo-slot.active {
    border: 2px solid var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* --- AMOLED DARK MODE (Industrial) --- */
body.amoled-theme {
    filter: invert(1) hue-rotate(180deg);
    background-color: #000;
}
body.amoled-theme img,
body.amoled-theme canvas {
    filter: invert(1) hue-rotate(180deg);
}
body.amoled-theme .card {
    border-color: #444;
}

/* Pareto Modal Styles */
.pareto-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}
.pareto-list li {
    padding: 10px 14px;
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pareto-list li strong {
    color: var(--primary);
    white-space: nowrap;
    margin-left: 10px;
}

/* Shift Selector */
.shift-selector {
    display: flex;
    gap: 15px;
    margin-top: 5px;
}
.shift-btn {
    flex: 1;
    cursor: pointer;
}
.shift-btn input {
    display: none;
}
.shift-btn span {
    display: block;
    text-align: center;
    padding: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-weight: bold;
    transition: all 0.3s ease;
}
.shift-btn input:checked + span {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

/* KPI Cards in History */
.kpi-card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.kpi-card .kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 5px;
    display: block;
}
.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-color);
}
.kpi-card.highlight-excellent {
    border-bottom: 4px solid #10b981;
}
.kpi-card.highlight-good {
    border-bottom: 4px solid #f59e0b;
}
.kpi-card.highlight-poor {
    border-bottom: 4px solid #ef4444;
}

/* Mini Gantt in History */
.mini-gantt-container {
    margin: 15px 0 10px 0;
}
.mini-gantt-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}
.mini-gantt {
    height: 12px;
    background: #10b981; 
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.gantt-breakdown {
    position: absolute;
    top: 0;
    height: 100%;
    background: #ef4444;
    border-left: 1px solid rgba(0,0,0,0.1);
    border-right: 1px solid rgba(0,0,0,0.1);
}
.gantt-pause {
    position: absolute;
    top: 0;
    height: 100%;
    background: #eab308;
    border-left: 1px solid rgba(0,0,0,0.1);
    border-right: 1px solid rgba(0,0,0,0.1);
}

