/* ======================================
   QFD House of Quality – Stylesheet
   ====================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --green: #16a34a;
    --green-light: #dcfce7;
    --green-bg: #bbf7d0;
    --blue-light: #bfdbfe;
    --pink: #ec4899;
    --pink-light: #fce7f3;
    --orange: #ea580c;
    --orange-light: #fff7ed;
    --purple: #7c3aed;
    --red: #dc2626;
    --yellow: #eab308;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --radius: 8px;
    --radius-lg: 12px;

    /* Roof correlation colors */
    --corr-strong-pos: #166534;
    --corr-pos: #22c55e;
    --corr-neg: #f97316;
    --corr-strong-neg: #dc2626;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    overflow-x: auto;
}

/* ===== HEADER ===== */
.top-header {
    background: var(--gray-900);
    color: white;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    color: white;
}
.logo i { font-size: 22px; color: var(--primary); }
.logo strong { color: #93c5fd; }

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .2s;
    font-family: inherit;
}
.btn-outline {
    background: transparent;
    color: var(--gray-300);
    border: 1px solid var(--gray-600);
}
.btn-outline:hover { background: var(--gray-700); color: white; }
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

/* ===== GUIDE PANEL ===== */
.guide-panel {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    overflow: hidden;
    transition: max-height .4s ease, opacity .3s;
    max-height: 800px;
    opacity: 1;
}
.guide-panel.hidden { max-height: 0; opacity: 0; pointer-events: none; }
.guide-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 24px;
    position: relative;
}
.guide-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px 8px;
    border-radius: 4px;
}
.guide-close:hover { background: var(--gray-100); color: var(--gray-700); }
.guide-content h2 {
    font-size: 22px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.guide-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    gap: 12px;
}
.guide-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.guide-card h3 { font-size: 14px; margin-bottom: 4px; }
.guide-card p { font-size: 12.5px; color: var(--gray-500); line-height: 1.5; }
.guide-tip {
    margin-top: 18px;
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.guide-tip i { color: #ca8a04; margin-top: 2px; }

/* ===== CONFIG BAR ===== */
.config-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 24px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
}
.config-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.config-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.stepper {
    display: flex;
    align-items: center;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    overflow: hidden;
}
.stepper button {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--gray-100);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    transition: background .15s;
}
.stepper button:hover { background: var(--gray-200); }
.stepper span {
    width: 36px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}
.live-summary { margin-left: auto; }
.summary-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    min-height: calc(100vh - 56px);
}

.hoq-wrapper {
    padding: 24px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

.hoq-container {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
}

/* ===== ROOF (Correlation Matrix) ===== */
.roof-container {
    position: relative;
    margin-bottom: -2px;
}
.roof-svg {
    display: block;
}
.roof-cell {
    cursor: pointer;
    transition: opacity .15s;
}
.roof-cell:hover { opacity: .7; }
.roof-cell-text {
    font-size: 11px;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

/* ===== MAIN GRID ===== */
.hoq-grid {
    display: grid;
    border: 2px solid var(--gray-700);
    background: var(--gray-700);
    gap: 1px;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

.hoq-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 4px;
    font-size: 13px;
    position: relative;
    transition: background .15s;
}

/* Section backgrounds */
.cell-header-how {
    background: #93c5fd;
    font-weight: 600;
    font-size: 11px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    min-height: 130px;
    padding: 8px 2px;
    color: var(--gray-800);
    letter-spacing: .3px;
}
.cell-header-what {
    background: #93c5fd;
    font-weight: 600;
    font-size: 12px;
    padding: 6px 10px;
    text-align: left;
    justify-content: flex-start;
    color: var(--gray-800);
}
.cell-importance {
    background: var(--pink-light);
    font-weight: 600;
    cursor: pointer;
}
.cell-importance:hover { background: #fbcfe8; }
.cell-relationship {
    background: #bbf7d0;
    cursor: pointer;
    font-size: 20px;
    min-width: 44px;
}
.cell-relationship:hover { background: #86efac; }
.cell-relationship.has-value { font-weight: 700; }

.cell-competitor {
    background: var(--pink-light);
    cursor: pointer;
    font-weight: 500;
}
.cell-competitor:hover { background: #fbcfe8; }

.cell-comp-header {
    background: #f9a8d4;
    font-weight: 600;
    font-size: 11px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    min-height: 130px;
    padding: 8px 2px;
    color: var(--gray-800);
}

.cell-direction {
    background: #bfdbfe;
    font-size: 18px;
    cursor: pointer;
}
.cell-direction:hover { background: #93c5fd; }

.cell-target {
    background: #e0e7ff;
    font-size: 12px;
    cursor: pointer;
}
.cell-target:hover { background: #c7d2fe; }

.cell-weight {
    background: #fecdd3;
    font-weight: 600;
    font-size: 12px;
}
.cell-weight-pct {
    background: #fda4af;
    font-weight: 700;
    font-size: 12px;
    color: var(--gray-800);
}

.cell-label {
    background: var(--gray-200);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-600);
    padding: 6px 10px;
    justify-content: flex-start;
    text-align: left;
}
.cell-label-right {
    background: #f9a8d4;
    font-weight: 600;
    font-size: 11px;
    color: var(--gray-700);
    padding: 4px;
}

.cell-corner {
    background: var(--gray-300);
}

.cell-empty {
    background: var(--gray-100);
}

/* Editable inputs within cells */
.cell-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    padding: 4px;
    outline: none;
}
.cell-input:focus {
    background: rgba(255,255,255,.6);
    box-shadow: inset 0 0 0 2px var(--primary);
    border-radius: 2px;
}
.cell-input-name {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
}

/* Relationship symbols */
.rel-strong { color: #166534; }
.rel-medium { color: #2563eb; }
.rel-weak { color: #9333ea; }

/* Direction arrows */
.dir-up { color: var(--green); }
.dir-down { color: var(--red); }
.dir-target { color: var(--gray-600); }

/* Weight bar inside cell */
.weight-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary);
    transition: width .4s ease;
    border-radius: 0 2px 0 0;
}

/* Highlight animation */
@keyframes cellPulse {
    0% { box-shadow: inset 0 0 0 0 rgba(37,99,235,.4); }
    50% { box-shadow: inset 0 0 0 3px rgba(37,99,235,.4); }
    100% { box-shadow: inset 0 0 0 0 rgba(37,99,235,.4); }
}
.cell-pulse { animation: cellPulse .6s ease; }

/* ===== INSIGHT PANEL ===== */
.insight-panel {
    padding: 20px 24px 40px;
    max-width: 1400px;
    margin: 0 auto;
}
.insight-panel h3 {
    font-size: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-700);
}
.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}
.insight-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow .2s;
}
.insight-card:hover { box-shadow: var(--shadow-md); }
.insight-card h4 {
    font-size: 13px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.insight-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 6px;
}
.insight-detail {
    font-size: 12.5px;
    color: var(--gray-500);
    line-height: 1.5;
}
.insight-bar-container {
    margin-top: 12px;
}
.insight-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}
.insight-bar-label {
    width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--gray-600);
    font-weight: 500;
    flex-shrink: 0;
}
.insight-bar-track {
    flex: 1;
    height: 18px;
    background: var(--gray-100);
    border-radius: 9px;
    overflow: hidden;
    position: relative;
}
.insight-bar-fill {
    height: 100%;
    border-radius: 9px;
    transition: width .5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    min-width: 30px;
}
.insight-placeholder {
    text-align: center;
    color: var(--gray-400);
    padding: 40px 20px;
    grid-column: 1 / -1;
}
.insight-placeholder i { font-size: 32px; margin-bottom: 10px; }
.insight-placeholder p { font-size: 14px; }

/* ===== TOOLTIP ===== */
.tooltip {
    position: fixed;
    z-index: 200;
    background: var(--gray-800);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    max-width: 250px;
    box-shadow: var(--shadow-lg);
    transition: opacity .15s;
}
.tooltip.hidden { opacity: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; gap: 8px; }
    .header-actions { flex-wrap: wrap; }
    .config-bar { padding: 10px 12px; gap: 10px; }
    .live-summary { margin-left: 0; }
    .hoq-wrapper { padding: 12px; justify-content: flex-start; }
    .guide-grid { grid-template-columns: 1fr; }
}

/* ===== RATING STARS ===== */
.rating-display {
    display: flex;
    gap: 1px;
    align-items: center;
}
.rating-display .star {
    font-size: 10px;
    color: var(--yellow);
}
.rating-display .star.empty { color: var(--gray-300); }

/* ===== Print styles ===== */
@media print {
    .top-header, .config-bar, .guide-panel, .header-actions { display: none; }
    .hoq-wrapper { padding: 0; }
    body { background: white; }
}
