/* ===== CSS Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(24, 34, 56, 0.8);
    --border-color: rgba(99, 102, 241, 0.15);
    --border-glow: rgba(99, 102, 241, 0.3);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Animated Background ===== */
.bg-particles {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.04;
    animation: float-particle 20s infinite ease-in-out;
}
.particle:nth-child(1) { width: 400px; height: 400px; top: -100px; left: -100px; animation-duration: 25s; }
.particle:nth-child(2) { width: 300px; height: 300px; top: 50%; right: -50px; animation-duration: 20s; animation-delay: -5s; }
.particle:nth-child(3) { width: 200px; height: 200px; bottom: 10%; left: 20%; animation-duration: 30s; animation-delay: -10s; }
.particle:nth-child(4) { width: 350px; height: 350px; top: 30%; left: 50%; animation-duration: 22s; animation-delay: -3s; }
.particle:nth-child(5) { width: 150px; height: 150px; top: 70%; right: 20%; animation-duration: 18s; animation-delay: -7s; }
.particle:nth-child(6) { width: 250px; height: 250px; bottom: -50px; right: 30%; animation-duration: 28s; animation-delay: -12s; }

@keyframes float-particle {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 15px) scale(1.02); }
}

/* ===== App Container ===== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ===== Header ===== */
.app-header {
    position: relative;
    text-align: center;
    padding: 40px 20px 36px;
    margin-bottom: 28px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.header-glow {
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    pointer-events: none;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.logo-icon {
    width: 52px;
    height: 52px;
    color: var(--accent-secondary);
    flex-shrink: 0;
}
.logo-icon svg { width: 100%; height: 100%; }

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}
.title-icon { font-size: 1.2rem; }

/* ===== Algorithm Tabs ===== */
.algo-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.algo-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: var(--font-family);
}
.algo-tab:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.06);
    color: var(--text-primary);
    transform: translateY(-2px);
}
.algo-tab.active {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15), inset 0 0 20px rgba(99, 102, 241, 0.05);
}
.algo-tab-name {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.algo-tab.active .algo-tab-name {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.algo-tab-desc {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.7;
    text-align: center;
}

/* ===== Time Quantum ===== */
.time-quantum-section {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius-md);
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    animation: slide-down 0.3s ease;
}
@keyframes slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tq-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tq-input-group {
    display: flex;
    align-items: center;
    gap: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.tq-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-secondary);
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-family);
    transition: background var(--transition-fast);
}
.tq-btn:hover { background: rgba(99, 102, 241, 0.2); }

.tq-input-group input {
    width: 56px;
    height: 36px;
    text-align: center;
    background: rgba(15, 23, 42, 0.6);
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-family);
    outline: none;
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 4px;
}
.section-header .section-title { margin-bottom: 0; }

.process-actions {
    display: flex;
    gap: 8px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition-normal);
}

.btn-add {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.btn-add:hover {
    background: rgba(16, 185, 129, 0.2);
    transform: translateY(-1px);
}

.btn-remove {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}
.btn-remove:hover {
    background: rgba(239, 68, 68, 0.18);
    transform: translateY(-1px);
}

/* ===== Process Table ===== */
.table-container {
    overflow-x: auto;
    margin-top: 14px;
}

.process-table,
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.process-table th,
.results-table th {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
.process-table th:first-child,
.results-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.process-table th:last-child,
.results-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.process-table td,
.results-table td {
    padding: 10px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    font-size: 0.9rem;
    transition: background var(--transition-fast);
}

.process-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

.process-name {
    font-weight: 700;
    color: var(--accent-secondary);
    font-size: 0.95rem;
}

.process-table input {
    width: 80px;
    padding: 8px 10px;
    text-align: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.process-table input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.process-table input::-webkit-inner-spin-button { opacity: 0.3; }

/* ===== Action Bar ===== */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
}

.btn-calculate {
    padding: 14px 40px;
    font-size: 1rem;
    font-weight: 700;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    letter-spacing: 0.3px;
}
.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.45);
}
.btn-calculate:active {
    transform: translateY(0);
}
.btn-calculate svg {
    flex-shrink: 0;
}

.btn-reset {
    padding: 14px 28px;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(241, 245, 249, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.btn-reset:hover {
    background: rgba(241, 245, 249, 0.1);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* ===== Output Section ===== */
.output-section {
    animation: fade-up 0.5s ease;
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Gantt Chart ===== */
.gantt-container {
    overflow-x: auto;
    padding-bottom: 8px;
}

.gantt-chart {
    display: flex;
    min-width: max-content;
    margin-bottom: 4px;
}

.gantt-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.gantt-bar {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    border-radius: 6px;
    margin: 0 1px;
    min-width: 44px;
    position: relative;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.gantt-bar:hover {
    transform: scaleY(1.08);
    z-index: 2;
}

.gantt-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 6px;
    min-width: 44px;
    text-align: left;
    padding-left: 2px;
}
.gantt-block:last-child .gantt-time-end {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    position: absolute;
    right: -4px;
    bottom: -20px;
}

.gantt-idle {
    background: rgba(100, 116, 139, 0.3);
    border: 1px dashed rgba(100, 116, 139, 0.4);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
}

/* Gantt Colors */
.gantt-color-0 { background: linear-gradient(135deg, #6366f1, #818cf8); box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3); }
.gantt-color-1 { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 2px 12px rgba(16, 185, 129, 0.3); }
.gantt-color-2 { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 2px 12px rgba(245, 158, 11, 0.3); }
.gantt-color-3 { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 2px 12px rgba(239, 68, 68, 0.3); }
.gantt-color-4 { background: linear-gradient(135deg, #8b5cf6, #a78bfa); box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3); }
.gantt-color-5 { background: linear-gradient(135deg, #3b82f6, #60a5fa); box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3); }
.gantt-color-6 { background: linear-gradient(135deg, #ec4899, #f472b6); box-shadow: 0 2px 12px rgba(236, 72, 153, 0.3); }
.gantt-color-7 { background: linear-gradient(135deg, #14b8a6, #2dd4bf); box-shadow: 0 2px 12px rgba(20, 184, 166, 0.3); }
.gantt-color-8 { background: linear-gradient(135deg, #f97316, #fb923c); box-shadow: 0 2px 12px rgba(249, 115, 22, 0.3); }
.gantt-color-9 { background: linear-gradient(135deg, #06b6d4, #22d3ee); box-shadow: 0 2px 12px rgba(6, 182, 212, 0.3); }

/* ===== Results Table ===== */
.results-table td { font-weight: 500; }
.results-table tbody tr { transition: background var(--transition-fast); }
.results-table tbody tr:hover td { background: rgba(99, 102, 241, 0.05); }

.results-table tfoot td {
    padding: 12px 16px;
    font-weight: 700;
    color: var(--accent-secondary);
    border-top: 2px solid var(--border-glow);
    background: rgba(99, 102, 241, 0.04);
    font-size: 0.85rem;
}

/* ===== Metrics Grid ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    transition: all var(--transition-normal);
}
.metric-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
    line-height: 1.2;
}

.metric-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.metric-card:nth-child(1) .metric-value { color: var(--accent-secondary); }
.metric-card:nth-child(2) .metric-value { color: #34d399; }
.metric-card:nth-child(3) .metric-value { color: #fbbf24; }
.metric-card:nth-child(4) .metric-value { color: #f87171; }
.metric-card:nth-child(5) .metric-value { color: #60a5fa; }
.metric-card:nth-child(6) .metric-value { color: #a78bfa; }

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.4); }

/* ===== Input number spinners ===== */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .app-container { padding: 12px 10px 40px; }
    .app-header { padding: 28px 16px 24px; }
    .app-header h1 { font-size: 1.35rem; }
    .logo-icon { width: 40px; height: 40px; }
    .algo-tabs { gap: 8px; }
    .algo-tab { padding: 12px 8px; }
    .algo-tab-name { font-size: 1rem; }
    .card { padding: 18px 14px; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .action-bar { flex-direction: column; }
    .btn-calculate, .btn-reset { width: 100%; justify-content: center; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .gantt-bar { min-width: 36px; height: 44px; font-size: 0.75rem; }
    .process-table input { width: 64px; padding: 6px 8px; }
}