/* ═══════════════════════════════════════════
   Quantum Lighting — RFQ Web App Styles
   Colors: Navy #1E2761, Teal #00B894, Charcoal #2D3436
   ═══════════════════════════════════════════ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #2D3436;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Navbar ── */
.navbar {
    background: #1E2761;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-brand {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}
.nav-icon { margin-right: 0.4rem; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover { color: #fff; }

/* ── Container ── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    color: #2D3436;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover { background: #f5f5f5; }
.btn-primary { background: #00B894; color: #fff; border-color: #00B894; }
.btn-primary:hover { background: #00a381; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 2rem; font-size: 1rem; }
.btn-danger { color: #e74c3c; border-color: #e74c3c; background: #fff; }
.btn-danger:hover { background: #ffeaea; }

/* ── Alerts ── */
.alert {
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.alert-error { background: #ffeaea; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-info { background: #e8f4fd; color: #2471a3; border: 1px solid #bee5eb; }

/* ── Dashboard ── */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.dashboard-header h1 { font-size: 1.6rem; }

.status-bar {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 0.8rem 1.2rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 0.85rem;
}
.status-item { display: flex; align-items: center; gap: 0.4rem; }
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.green { background: #00B894; }
.status-dot.red { background: #e74c3c; }
.status-dot.yellow { background: #f39c12; }
.status-dot.blue { background: #2B6CB0; }

/* ── Project Cards ── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.2rem;
}
.project-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.card-error { border-left: 4px solid #e74c3c; }

.card-header {
    padding: 1rem 1.2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.card-header h3 { font-size: 1rem; color: #1E2761; }

.card-body { padding: 0.6rem 1.2rem; }
.card-meta { font-size: 0.78rem; color: #888; margin-bottom: 0.4rem; }
.card-summary { font-size: 0.85rem; color: #555; }

.card-actions {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 0.5rem;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-analyzed { background: #e8f8f5; color: #00B894; }
.badge-error { background: #ffeaea; color: #e74c3c; }
.badge-green { background: #e8f8f5; color: #00B894; }
.badge-orange { background: #fef5e7; color: #e67e22; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #888;
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h2 { color: #555; margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* ── Upload Form ── */
.upload-form { max-width: 700px; }
.form-section { margin-bottom: 1.5rem; }
.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.form-hint { font-weight: 400; color: #888; font-size: 0.8rem; }

textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.85rem;
    resize: vertical;
    line-height: 1.5;
}
textarea:focus { outline: none; border-color: #00B894; box-shadow: 0 0 0 3px rgba(0,184,148,0.15); }

/* ── Toggle Group ── */
.toggle-group { display: flex; gap: 0.8rem; }
.toggle-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.9rem;
}
.toggle-option:has(input:checked) {
    border-color: #00B894;
    background: #e8f8f5;
}
.toggle-option:has(input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}
.toggle-option input { margin: 0; }
.tag {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
}
.tag-red { background: #ffeaea; color: #e74c3c; }
.tag-yellow { background: #fef5e7; color: #e67e22; }

/* ── Select Dropdown ── */
.form-select {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    color: #2D3436;
    cursor: pointer;
    appearance: auto;
}
.form-select:focus {
    outline: none;
    border-color: #00B894;
    box-shadow: 0 0 0 3px rgba(0,184,148,0.15);
}

/* ── Processing Overlay ── */
.processing-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 39, 97, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.processing-overlay.visible { display: flex; }

.processing-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 3rem;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.processing-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #00B894;
    border-radius: 50%;
    margin: 0 auto 1.2rem;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.processing-card h2 {
    font-size: 1.3rem;
    color: #1E2761;
    margin-bottom: 0.3rem;
}
.processing-sub {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1.5rem;
}

.processing-steps {
    text-align: left;
    margin-bottom: 1.5rem;
}
.step {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: #ccc;
    transition: color 0.3s;
}
.step.active { color: #1E2761; font-weight: 500; }
.step.done { color: #00B894; }

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e0e0e0;
    flex-shrink: 0;
    transition: background 0.3s;
}
.step.active .step-dot { background: #1E2761; animation: pulse 1.5s ease-in-out infinite; }
.step.done .step-dot { background: #00B894; }
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.processing-bar-track {
    height: 6px;
    background: #e8e8e8;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.6rem;
}
.processing-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00B894, #1E2761);
    border-radius: 3px;
    transition: width 0.3s ease-out;
}

.processing-elapsed {
    font-size: 0.75rem;
    color: #aaa;
}

/* ── Drop Zone ── */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    color: #888;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: #00B894;
    background: #f0fdf9;
}
.drop-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.drop-zone input[type="file"] { display: none; }
.file-name { color: #00B894; font-weight: 600; margin-top: 0.5rem; }

/* ── Results ── */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}
.results-header h1 { font-size: 1.5rem; color: #1E2761; }
.results-meta { font-size: 0.82rem; color: #888; margin-top: 0.3rem; }

.summary-box {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #1E2761;
    border-radius: 6px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
}
.summary-box h3 { font-size: 0.9rem; color: #1E2761; margin-bottom: 0.4rem; }
.summary-box p { font-size: 0.9rem; }
.token-info { font-size: 0.75rem; color: #aaa; margin-top: 0.5rem; }

/* ── Fixture Table ── */
.table-wrapper { overflow-x: auto; margin-bottom: 1.5rem; }
.fixture-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.82rem;
    border: 1px solid #e0e0e0;
}
.fixture-table th {
    background: #1E2761;
    color: #fff;
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.fixture-table td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}
.fixture-table tr:hover { background: #f8f9fa; }
.row-ours { }
.row-equal { background: #fffdf0; }
.td-type { font-weight: 700; color: #1E2761; }
.td-mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 0.78rem; }
.td-center { text-align: center; }
.td-notes { font-size: 0.78rem; color: #888; max-width: 200px; }

/* ── Stats Row ── */
.stats-row {
    display: flex;
    gap: 1.2rem;
    margin-bottom: 2rem;
}
.stat-card {
    flex: 1;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.2rem;
    text-align: center;
}
.stat-number { font-size: 2rem; font-weight: 700; }
.stat-number.green { color: #00B894; }
.stat-number.orange { color: #e67e22; }
.stat-number.blue { color: #2B6CB0; }
.stat-label { font-size: 0.8rem; color: #888; margin-top: 0.2rem; }

.results-actions { margin-top: 1rem; }

/* ── Login Page ── */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}
.login-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-icon { font-size: 2.5rem; }
.login-header h1 { font-size: 1.4rem; color: #1E2761; margin-top: 0.5rem; }
.login-header p { font-size: 0.85rem; color: #888; }

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}
.login-form input:focus {
    outline: none;
    border-color: #00B894;
    box-shadow: 0 0 0 3px rgba(0,184,148,0.15);
}
.login-btn { width: 100%; margin-top: 0.5rem; }

/* ── Nav user/logout ── */
.nav-user { color: rgba(255,255,255,0.6); font-size: 0.82rem; }
.nav-logout { color: rgba(255,255,255,0.5); font-size: 0.8rem; text-decoration: none; }
.nav-logout:hover { color: #fff; }

/* ── Line Card Management ── */
.card-link { text-decoration: none; color: inherit; }
.card-link:hover .project-card { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.add-mfg-bar {
    margin-bottom: 1.2rem;
    padding: 0.8rem 1rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}
.add-mfg-form {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.add-mfg-input {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}
.add-mfg-input:focus {
    outline: none;
    border-color: #00B894;
    box-shadow: 0 0 0 3px rgba(0,184,148,0.15);
}

.mfg-search-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.mfg-count { font-size: 0.8rem; color: #888; white-space: nowrap; }

.mfg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.4rem;
}
.mfg-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.8rem;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    font-size: 0.85rem;
}
.mfg-item:hover { background: #f8f9fa; }
.mfg-name { color: #2D3436; }
.mfg-remove-form { margin: 0; }
.mfg-remove-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}
.mfg-remove-btn:hover { color: #e74c3c; }

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.75rem;
    color: #aaa;
    border-top: 1px solid #e8e8e8;
    margin-top: auto;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .dashboard-header { flex-direction: column; gap: 0.8rem; }
    .status-bar { flex-direction: column; gap: 0.5rem; }
    .project-grid { grid-template-columns: 1fr; }
    .stats-row { flex-direction: column; }
    .toggle-group { flex-direction: column; }
    .results-header { flex-direction: column; gap: 0.8rem; }
}
