/* === Box Culvert — cloned from the RAR Cloudflare app stylesheet,
   re-themed to an engineering steel-blue palette. Class names that auth.js
   depends on are preserved: .btn, .btn-primary, .param-row, .form-control,
   var(--primary). === */

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

:root {
    --primary: #2c5f8a;
    --primary-light: #3f7cad;
    --primary-dark: #1d425f;
    --accent-steel: #4a8fc7;
    --accent-slate: #7a93a8;
    --gradient-brand: linear-gradient(135deg, #1d425f, #4a8fc7);
    --success: #2e9e5b;
    --danger: #e74c3c;
    --warning: #f0b429;
    --yellow-cell: #fffbe8;
    --yellow-cell-border: #e6d98c;
    --bg: #eef2f6;
    --card-bg: #ffffff;
    --text: #1d2733;
    --text-light: #5a6b7d;
    --border: #ccd7e0;
    --shadow: 0 2px 8px rgba(29,66,95,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* === Header === */
.app-header {
    background: linear-gradient(135deg, #16324a 0%, #2c5f8a 55%, #4a8fc7 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 3px 8px rgba(22,50,74,0.30);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left { display: flex; flex-direction: column; gap: 0; line-height: 1.2; }
.brand-logo { display: flex; align-items: baseline; gap: 0; }
.brand-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.header-subtitle { font-size: 0.75rem; opacity: 0.85; font-weight: 400; }
.header-right { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
#user-display { font-size: 0.75rem; color: rgba(255,255,255,0.85); margin-right: 0.5rem; }

.header-right .btn {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.35);
}
.header-right .btn:hover { background: rgba(255,255,255,0.22); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    background: #dde6ee;
    color: var(--text);
}
.btn:hover { background: #cfdae5; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #37b96b; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: var(--accent-slate); color: white; }
.btn-secondary:hover { background: #67808f; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-lg { padding: 0.65rem 1.5rem; font-size: 1rem; }

/* === Container === */
.app-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* === Cards === */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f5f8fa;
}

.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.card-body { padding: 1.25rem; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.15s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-steel);
    box-shadow: 0 0 0 3px rgba(74,143,199,0.15);
}

/* === Tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th, .data-table td {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    text-align: center;
}

.data-table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.data-table td { background: white; }

.rf-pass { background: #d9efe1 !important; color: #14603a; font-weight: 600; }
.rf-fail { background: #f8d7da !important; color: #721c24; font-weight: 600; }

/* === Parameter Sections (form) === */
.param-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.param-section h4 {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.param-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0;
    gap: 0.5rem;
}

.param-row label {
    font-size: 0.82rem;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
}

.param-row input,
.param-row select {
    width: 130px;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--yellow-cell-border);
    border-radius: 4px;
    background: var(--yellow-cell);
    font-size: 0.85rem;
    text-align: right;
    font-family: inherit;
}

.param-row input:focus,
.param-row select:focus {
    outline: none;
    border-color: var(--accent-steel);
    box-shadow: 0 0 0 2px rgba(74,143,199,0.15);
}

.param-row input.ro-input,
.param-row input[readonly] {
    background: #eef2f6;
    border-color: var(--border);
    color: var(--text-light);
    cursor: default;
}

.param-section details.adv summary,
details.adv-section summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    padding: 0.3rem 0;
    user-select: none;
}

details.adv-section { padding: 1rem; }
details.adv-section summary h4 { border-bottom: none; margin-bottom: 0; }

.hint { font-size: 0.75rem; color: var(--text-light); margin: 0.25rem 0 0.5rem; }

/* === Read-only chips === */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.chip {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: #e2ebf3;
    color: var(--primary-dark);
    border: 1px solid #c4d4e2;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* === Toolbar === */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.design-select { width: 220px; display: inline-block; }

/* === Engine status / errors === */
.engine-status {
    background: #e2ebf3;
    border: 1px solid #c4d4e2;
    color: var(--primary-dark);
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.run-error {
    background: #f8d7da;
    border: 1px solid #f1b5bb;
    color: #721c24;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    white-space: pre-wrap;
}

/* === Main layout: form left, results right === */
.main-grid {
    display: grid;
    grid-template-columns: minmax(340px, 420px) 1fr;
    gap: 1.25rem;
    align-items: start;
}

.results-panel { display: flex; flex-direction: column; gap: 1rem; }
.result-block { margin: 0; }
.card-body { overflow-x: auto; }

/* === Hero rating card === */
.hero-rating {
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    color: white;
    box-shadow: var(--shadow);
    text-align: center;
}
.hero-pass { background: linear-gradient(135deg, #1e7a46, #2e9e5b); }
.hero-fail { background: linear-gradient(135deg, #a83226, #d9534f); }

.hero-values { display: flex; justify-content: center; gap: 2.5rem; }
.hero-box { text-align: center; }
.hero-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
}
.hero-number { font-size: 2.4rem; font-weight: 800; line-height: 1.15; }
.hero-sub { margin-top: 0.4rem; font-size: 0.9rem; opacity: 0.95; }
.hero-mode {
    font-weight: 800;
    letter-spacing: 0.06em;
    background: rgba(255,255,255,0.18);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
}

/* === Governing badges === */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: #e2e8f0;
    color: #475569;
}
.badge-flexure { background: #dbeafe; color: #1e40af; }
.badge-min_steel { background: #fef3c7; color: #92400e; }
.badge-crack_control { background: #fde2e2; color: #991b1b; }

/* === Diagrams === */
.diagram-controls { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.diagram-select { width: auto; min-width: 130px; display: inline-block; }
.diagram-svg-wrap { width: 100%; }
.diagram-svg { width: 100%; height: auto; background: #fbfcfe; border: 1px solid var(--border); border-radius: 6px; }
.diag-frame { fill: none; stroke: var(--border); stroke-width: 1; }
.diag-zero { stroke: #99a9b8; stroke-width: 1; stroke-dasharray: 4 3; }
.diag-line { fill: none; stroke: var(--primary); stroke-width: 2; }
.diag-axis { font-size: 12px; fill: var(--text-light); font-family: inherit; }
.diag-tick { font-size: 10px; fill: var(--text-light); font-family: inherit; }

/* === Warnings === */
.warnings-list { margin: 0; padding-left: 1.25rem; }
.warnings-list li { font-size: 0.85rem; color: #8a5a00; padding: 0.15rem 0; }

.result-actions { display: flex; justify-content: flex-end; }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: 10px;
}
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }
.empty-state p { font-size: 0.9rem; margin-bottom: 0.5rem; }

/* === Utilities === */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* === Responsive === */
@media (max-width: 980px) {
    .main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .app-container { padding: 1rem; }
    .hero-values { gap: 1.25rem; }
    .hero-number { font-size: 1.8rem; }
}

/* === Print === */
@media print {
    body { background: white; }
    .app-header, .toolbar, .result-actions, .no-print { display: none !important; }
    .app-container { max-width: 100%; padding: 0; margin: 0; }
    .main-grid { grid-template-columns: 1fr; }
    .data-table th {
        background: #2c5f8a !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .rf-pass, .rf-fail, .hero-pass, .hero-fail {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
