/* ==========================================================================
   Bus-Proof Standalone - Stylesheet
   Theme: Business casual — slate grays, steel blue accent
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --color-primary: #4A6FA5;
    --color-primary-hover: #3A5B8C;
    --color-primary-light: rgba(74, 111, 165, 0.08);
    --color-primary-border: rgba(74, 111, 165, 0.25);
    --color-charcoal: #1E293B;
    --color-dark-grey: #334155;
    --color-mid-grey: #64748B;
    --color-light-grey: #F1F5F9;
    --color-border: #CBD5E1;
    --color-white: #ffffff;
    --color-error: #dc2626;
    --color-error-light: rgba(220, 38, 38, 0.08);
    --color-success: #16a34a;
    --color-success-light: rgba(22, 163, 74, 0.08);
    --color-warning: #d97706;
    --color-warning-light: rgba(217, 119, 6, 0.08);

    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(74, 111, 165, 0.12);
}

/* --- Backward-compatible aliases ---
   The frontend HTML references --color-orange* variables.
   These aliases map them to the new primary palette so the
   frontend works without modification. */
:root {
    --color-orange: var(--color-primary);
    --color-orange-hover: var(--color-primary-hover);
    --color-orange-light: var(--color-primary-light);
    --color-orange-border: var(--color-primary-border);
}

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-dark-grey);
    background: var(--color-white);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-charcoal);
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

/* --- Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Page Header --- */
.page-header {
    background: var(--color-white);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header .logo {
    height: 36px;
    width: auto;
}

.page-header .page-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    text-transform: uppercase;
    color: var(--color-charcoal);
    letter-spacing: 0.02em;
}

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

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

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

.back-link:hover {
    color: var(--color-primary);
    text-decoration: none;
}

/* --- Hub Header (landing page) --- */
.hub-header {
    background: var(--color-white);
    padding: 2.5rem 2rem 2rem;
    border-bottom: 2px solid var(--color-border);
    text-align: center;
}

.hub-header .logo {
    height: 48px;
    width: auto;
    margin-bottom: 1rem;
}

.hub-header h1 {
    color: var(--color-charcoal);
    margin-bottom: 0.25rem;
}

.hub-header p {
    color: var(--color-mid-grey);
    font-size: 1rem;
}

/* --- Section Titles --- */
.section-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-mid-grey);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.25rem;
}

/* --- Card Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

/* --- Project Card --- */
.card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-left: 4px solid transparent;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    border-left-color: var(--color-primary);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.card.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.card-icon {
    width: 48px;
    height: 48px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--color-primary);
}

.card h2 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--color-mid-grey);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* --- Status Badges --- */
.badge {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-active {
    background: var(--color-success-light);
    color: var(--color-success);
}

.badge-development {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.badge-planned {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.75rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.btn-primary:disabled {
    background: var(--color-border);
    color: var(--color-mid-grey);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--color-white);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
    background: var(--color-primary-light);
}

/* --- Form Inputs --- */
.form-input,
.form-select {
    font-family: var(--font-body);
    font-size: 0.95rem;
    width: 100%;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    color: var(--color-charcoal);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-border);
}

.form-input::placeholder {
    color: #94a3b8;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-dark-grey);
    margin-bottom: 0.4rem;
}

textarea.form-input {
    resize: none;
    font-family: var(--font-body);
    min-height: 60px;
}

/* --- Panels / Sections --- */
.panel {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* --- Chat Components --- */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

.message.user {
    align-self: flex-end;
    background: var(--color-primary-light);
    border: 1px solid var(--color-primary-border);
    color: var(--color-charcoal);
}

.message.assistant {
    align-self: flex-start;
    background: var(--color-light-grey);
    border: 1px solid var(--color-border);
    color: var(--color-dark-grey);
}

.message.system {
    align-self: center;
    background: transparent;
    color: var(--color-mid-grey);
    font-size: 0.85rem;
    font-style: italic;
}

.message.error {
    align-self: center;
    background: var(--color-error-light);
    color: var(--color-error);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.chat-input-area {
    background: var(--color-light-grey);
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 1rem;
}

/* --- Result Cards --- */
.result-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.result-card.success {
    border-left-color: var(--color-success);
}

.result-card.error {
    border-left-color: var(--color-error);
}

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

.result-equipment {
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    color: var(--color-charcoal);
}

.result-time {
    font-size: 0.8rem;
    color: var(--color-mid-grey);
}

.result-analysis {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--color-dark-grey);
    max-height: 300px;
    overflow-y: auto;
    background: var(--color-light-grey);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

/* JSON syntax highlighting */
.json-key { color: var(--color-primary); }
.json-string { color: var(--color-success); }
.json-number { color: #7c3aed; }
.json-boolean { color: #2563eb; }
.json-null { color: var(--color-mid-grey); }

/* --- Status Indicators --- */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-mid-grey);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-mid-grey);
}

.status-dot.ready { background: var(--color-success); }
.status-dot.polling { background: var(--color-warning); animation: pulse 1s infinite; }
.status-dot.error { background: var(--color-error); }

/* --- Loading / Spinner --- */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-state {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--color-mid-grey);
    padding: 2rem;
    justify-content: center;
}

.loading-inline {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --- Empty States --- */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-mid-grey);
    font-style: italic;
    padding: 3rem;
}

/* --- Footer --- */
.page-footer {
    text-align: center;
    padding: 1.5rem 2rem;
    color: var(--color-mid-grey);
    font-size: 0.8rem;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

.page-footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.page-footer a:hover {
    text-decoration: underline;
}

/* --- Animations --- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .page-header .header-left {
        flex-direction: column;
    }

    .container {
        padding: 1rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    h1 { font-size: 2rem; }

    .message {
        max-width: 95%;
    }
}
