/* ============================================================================
   QuickAI Studio Pro — Configurable AI SaaS Engine Stylesheet
   Architecture: CSS Custom Properties driven by the reusable Theme & Layout Engines
   ============================================================================ */

:root {
    --theme-primary: #4f46e5;
    --theme-secondary: #06b6d4;
    --theme-accent: #8b5cf6;
    --theme-bg: #f8fafc;
    --theme-surface: #ffffff;
    --theme-text: #0f172a;
    --theme-muted: #64748b;
    --theme-border: #e2e8f0;
    --theme-gradient: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    --theme-radius: 12px;
    --theme-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 38px -10px rgba(15, 23, 42, 0.14);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body.theme-dark {
    --theme-bg: #090d16;
    --theme-surface: #111827;
    --theme-text: #f8fafc;
    --theme-muted: #94a3b8;
    --theme-border: #1e293b;
}

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

html, body {
    font-family: var(--theme-font);
    background-color: var(--theme-bg);
    color: var(--theme-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--theme-primary);
    text-decoration: none;
    transition: color 0.18s ease;
}

a:hover {
    opacity: 0.9;
}

/* Layout Containers */
.container {
    width: 100%;
    max-width: 1260px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Top Navigation Bar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--theme-border);
}

body.theme-dark .navbar {
    background: rgba(17, 24, 39, 0.92);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    gap: 1.5rem;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 800;
    font-size: 1.22rem;
    color: var(--theme-text);
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--theme-gradient);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    list-style: none;
}

.nav-links a {
    color: var(--theme-text);
    font-weight: 500;
    font-size: 0.94rem;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--theme-primary);
    background: rgba(79, 70, 229, 0.07);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.62rem 1.2rem;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--theme-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--theme-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
    color: #ffffff;
}

.btn-secondary {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fecaca;
}

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

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-lg {
    padding: 0.85rem 1.65rem;
    font-size: 1rem;
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.68rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-primary { background: rgba(79, 70, 229, 0.12); color: var(--theme-primary); }
.badge-success { background: rgba(16, 185, 129, 0.14); color: #059669; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.badge-danger  { background: rgba(239, 68, 68, 0.14); color: #dc2626; }
.badge-premium { background: linear-gradient(135deg, #f59e0b 0%, #db2777 100%); color: #fff; }

/* Hero Section */
.hero {
    padding: 4.2rem 0 3.2rem;
    text-align: center;
    position: relative;
}

.hero h1 {
    font-size: clamp(2.1rem, 4.2vw, 3.35rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    max-width: 880px;
    margin: 0.85rem auto 1.1rem;
}

.hero p.lead {
    font-size: 1.12rem;
    color: var(--theme-muted);
    max-width: 680px;
    margin: 0 auto 2rem;
}

/* Cards & Grids */
.grid {
    display: grid;
    gap: 1.35rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--theme-primary);
}

.tool-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.tool-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.tool-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: var(--theme-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.tool-card h3 {
    font-size: 1.12rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
    color: var(--theme-text);
}

.tool-card p {
    font-size: 0.9rem;
    color: var(--theme-muted);
    margin-bottom: 1.15rem;
    flex-grow: 1;
}

.tool-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.9rem;
    border-top: 1px solid var(--theme-border);
    font-size: 0.82rem;
    color: var(--theme-muted);
}

/* Forms & Dynamic Inputs */
.form-group {
    margin-bottom: 1.15rem;
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.42rem;
    color: var(--theme-text);
}

.form-help {
    font-size: 0.8rem;
    color: var(--theme-muted);
    margin-top: 0.3rem;
}

.form-control, .form-select, .form-textarea {
    width: 100%;
    padding: 0.68rem 0.9rem;
    font-size: 0.94rem;
    font-family: inherit;
    color: var(--theme-text);
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: calc(var(--theme-radius) - 2px);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.form-control:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.file-dropzone {
    border: 2px dashed var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 1.6rem;
    text-align: center;
    background: rgba(79, 70, 229, 0.03);
    cursor: pointer;
    transition: all 0.18s ease;
}

.file-dropzone:hover, .file-dropzone.dragover {
    border-color: var(--theme-primary);
    background: rgba(79, 70, 229, 0.07);
}

/* ============================================================================
   8 REUSABLE TOOL LAYOUT ENGINES (Section 14)
   ============================================================================ */
.tool-workspace-wrapper {
    padding: 2rem 0 4rem;
}

.tool-header-banner {
    background: var(--theme-gradient);
    color: #fff;
    padding: 1.8rem 2rem;
    border-radius: var(--theme-radius);
    margin-bottom: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: var(--shadow-md);
}

/* 1. Minimal & 2. Centered Layout */
.layout-minimal, .layout-centered {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 3. Split I/O, 4. Document Tool, 6. Content Studio, 7. Upload+Result */
.layout-split_io, .layout-document, .layout-content_studio, .layout-upload_result {
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 1.6rem;
    align-items: start;
}

/* 5. Advanced Form Layout */
.layout-advanced_form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.6rem;
    align-items: start;
}

/* 8. Multi-Step Wizard Layout */
.layout-multi_step {
    max-width: 960px;
    margin: 0 auto;
}

@media (max-width: 980px) {
    .layout-split_io, .layout-document, .layout-content_studio, .layout-upload_result, .layout-advanced_form {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   AI PROCESSING PIPELINE STATUS BAR (Section 76)
   ============================================================================ */
.ai-pipeline-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.9rem 1.1rem;
    background: rgba(79, 70, 229, 0.05);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    margin-bottom: 1.15rem;
    flex-wrap: wrap;
}

.pipeline-step {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--theme-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.pipeline-step.active {
    color: var(--theme-primary);
}

.pipeline-step.done {
    color: var(--success);
}

/* ============================================================================
   DYNAMIC OUTPUT RENDERER COMPONENTS (Section 13)
   ============================================================================ */
.mcq-card {
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: var(--theme-surface);
}

.mcq-option-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.68rem 0.95rem;
    margin-top: 0.5rem;
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    background: var(--theme-bg);
    color: var(--theme-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mcq-option-btn:hover {
    border-color: var(--theme-primary);
}

.mcq-option-btn.correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: #059669;
    color: #065f46;
    font-weight: 600;
}

.mcq-option-btn.wrong {
    background: rgba(239, 68, 68, 0.12);
    border-color: #dc2626;
    color: #991b1b;
}

.mcq-explanation {
    margin-top: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(79, 70, 229, 0.06);
    font-size: 0.86rem;
    display: none;
}

.mcq-explanation.visible {
    display: block;
}

.code-output-pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.15rem;
    border-radius: 10px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    line-height: 1.55;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th, .data-table td {
    padding: 0.78rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--theme-border);
}

.data-table th {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--theme-muted);
    background: rgba(15, 23, 42, 0.02);
}

/* ============================================================================
   ADMINISTRATION CONTROL CENTER SHELL (Section 51 & 111)
   ============================================================================ */
.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.4rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar .nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    margin: 1rem 0.65rem 0.35rem;
    font-weight: 700;
}

.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 0.88rem;
    font-weight: 500;
}

.admin-sidebar a:hover, .admin-sidebar a.active {
    background: rgba(99, 102, 241, 0.22);
    color: #ffffff;
}

.admin-main {
    background: #f1f5f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.9rem 1.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-content {
    padding: 1.8rem;
    max-width: 1420px;
    width: 100%;
}

.kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.2rem 1.35rem;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
}

.kpi-card .kpi-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: #0f172a;
    margin-top: 0.25rem;
}

@media (max-width: 900px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Modal & Toast Notification */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 900;
    padding: 1rem;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: var(--theme-surface);
    border-radius: 14px;
    max-width: 780px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.65rem;
    box-shadow: var(--shadow-lg);
}

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast {
    background: #0f172a;
    color: #fff;
    padding: 0.85rem 1.2rem;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 4px solid var(--theme-primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }

.footer {
    border-top: 1px solid var(--theme-border);
    padding: 2.5rem 0;
    margin-top: 4rem;
    font-size: 0.88rem;
    color: var(--theme-muted);
}
