:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --primary: #1e88e5;
    --primary-light: #1565c0;
    --accent: #00796b;
    --accent-light: #004d40;
    --danger: #d32f2f;
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --hover: #f1f5f9;
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    --radius: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    overflow-x: hidden;
}

/* App Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header styling */
.app-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo i {
    font-size: 2.2rem;
    color: var(--primary);
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    color: var(--text-primary);
}

.logo-text span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Sidebar and Workspace Layout */
.app-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.app-sidebar {
    width: 280px;
    background-color: var(--bg-header);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.pipeline-heading {
    padding: 0 20px 15px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.pipeline-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    flex: 1;
    padding: 0 10px;
}

.nav-step {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-step:hover {
    background-color: var(--hover);
    color: var(--text-primary);
}

.nav-step.active {
    background-color: rgba(30, 136, 229, 0.15);
    color: var(--primary-light);
    font-weight: 600;
    border-left: 3px solid var(--primary);
}

.step-num {
    background-color: var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-right: 12px;
    font-weight: 700;
    transition: var(--transition);
}

.nav-step.active .step-num {
    background-color: var(--primary);
    color: white;
}

.step-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step-tag {
    font-size: 0.7rem;
    background-color: var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 8px;
    text-transform: uppercase;
}

.nav-step.active .step-tag {
    background-color: rgba(33, 150, 243, 0.2);
    color: var(--primary-light);
}

.step-chevron {
    font-size: 0.8rem;
    opacity: 0.5;
}

.sidebar-info-card {
    margin: 20px 15px 0;
    background-color: var(--bg-card);
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.sidebar-info-card .card-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-info-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* App Main Display */
.app-display {
    flex: 1;
    padding: 25px 30px;
    overflow-y: auto;
    background-color: var(--bg-main);
}

.display-section {
    display: none;
}

.display-section.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* General Layout Card Components */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    overflow: hidden;
}

.card-header-highlight {
    background: linear-gradient(90deg, rgba(30,136,229,0.1) 0%, rgba(21,28,44,0.3) 100%);
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
}

.card-header-highlight h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Button & Form Controls styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

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

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

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

.btn-success:hover {
    background-color: var(--accent-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.form-control {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    outline: none;
    transition: var(--transition);
    width: 100%;
    font-family: var(--font-body);
}

.form-control:focus {
    border-color: var(--primary);
}

/* Editing tables styling */
.qfd-edit-table {
    width: 100%;
    border-collapse: collapse;
}

.qfd-edit-table th, .qfd-edit-table td {
    border: 1px solid var(--border);
    padding: 12px;
    text-align: left;
}

.qfd-edit-table th {
    background-color: #e2e8f0;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Grid & Layout Matrices */
.table-scroll-container {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.matrix-grid-table {
    border-collapse: collapse;
    width: 100%;
}

.matrix-grid-table th, .matrix-grid-table td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: center;
    min-width: 100px;
}

.matrix-grid-table th {
    background-color: #e2e8f0;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
}

.matrix-grid-table td.row-header {
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 200px;
}

/* Collapsible Case Guide */
.case-study-guide-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.guide-header {
    padding: 15px 20px;
    background-color: rgba(0, 121, 107, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.guide-header:hover {
    background-color: rgba(0, 121, 107, 0.15);
}

.guide-header h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--accent-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.guide-body {
    padding: 20px;
    border-top: 1px solid var(--border);
    transition: max-height 0.4s ease, padding 0.4s ease;
    overflow: hidden;
    max-height: 1000px;
}

.guide-body.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
}

.step-by-step-guide {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.guide-step {
    background-color: var(--bg-main);
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* QFD Visual Representation (The House) */
.hoq-visual-wrapper {
    margin-top: 25px;
    overflow-x: auto;
    padding: 20px;
    background-color: var(--bg-main);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: inline-block;
    min-width: 100%;
}

.hoq-table {
    border-collapse: collapse;
    margin: 0 auto;
}

/* Correlation Roof styling (Diagonal borders inside a cell) */
.roof-cell {
    border: 1px solid var(--border);
    position: relative;
    width: 60px;
    height: 60px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    background-color: rgba(30, 136, 229, 0.03);
    transition: var(--transition);
}

.roof-cell:hover {
    background-color: rgba(30, 136, 229, 0.15);
}

/* RAG Advisor Output Styling */
.advisor-output-box {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: rgba(30, 136, 229, 0.03);
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

.advisor-section {
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.advisor-section:last-child {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.advisor-section h4 {
    font-family: var(--font-heading);
    color: var(--primary-light);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.advice-block {
    background-color: var(--bg-main);
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.checklist-ul {
    list-style-type: none;
}

.checklist-ul li {
    padding: 6px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.checklist-ul li i {
    color: var(--accent-light);
    margin-top: 4px;
}

.hidden {
    display: none !important;
}

/* Math Container styling */
.math-container {
    background-color: var(--bg-main);
    padding: 15px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.9rem;
}

/* Modal dialog styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 600px;
    width: 90%;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.modal-header {
    background-color: var(--bg-header);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: var(--font-heading);
    color: var(--primary-light);
}

.close-modal-btn {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.close-modal-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Grid helper utilities */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2col {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
    .app-workspace {
        flex-direction: column;
    }
    .app-sidebar {
        width: 100%;
        height: auto;
    }
    .grid-2col {
        grid-template-columns: 1fr;
    }
}
