@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;700&family=Space+Grotesk:wght@700&display=swap');

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

.dark {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: rgba(129, 140, 248, 0.2);
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

.font-outfit {
    font-family: 'Outfit', sans-serif;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* GLOBAL HEADER GRIMONT */
.grimont-global-header {
    width: 100%;
    z-index: 1000;
    position: sticky;
    top: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 0;
    font-family: 'Outfit', 'Inter', sans-serif;
    color: #e2e8f0;
    box-sizing: border-box;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
}
.grimont-global-header * { box-sizing: border-box; }
.grimont-global-header .ggh-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ggh-left { display: flex; align-items: center; gap: 1.5rem; }
.ggh-logo-group {
    display: flex; align-items: center; gap: 0.875rem; text-decoration: none; transition: transform 0.2s ease;
}
.ggh-logo-group:hover { transform: scale(1.02); }
.ggh-logo-box {
    width: 40px; height: 40px; background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    color: white; font-weight: bold; font-size: 1.25rem; border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.25); flex-shrink: 0;
}
.ggh-logo-text {
    font-family: 'Space Grotesk', monospace; font-weight: 800; font-size: 1.2rem;
    color: white; letter-spacing: 0.05em; display: none;
}
.ggh-logo-text span { color: #00f2ff; }
@media (min-width: 640px) { .ggh-logo-text { display: block; } }
.ggh-separator { width: 1px; height: 36px; background-color: rgba(255, 255, 255, 0.1); display: none; }
@media (min-width: 768px) { .ggh-separator { display: block; } }
.ggh-app-info { display: flex; flex-direction: column; justify-content: center; }
.ggh-app-title-group { display: flex; align-items: center; gap: 0.6rem; }
.ggh-app-icon-container {
    width: 32px; height: 32px; border-radius: 8px; background: rgba(30, 41, 59, 1);
    border: 1px solid rgba(255, 255, 255, 0.1); display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #818cf8; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); flex-shrink: 0;
}
.ggh-app-name { font-weight: 700; color: white; font-size: 1.05rem; margin: 0; padding: 0; letter-spacing: 0.02em; }
.ggh-app-desc {
    font-size: 0.8rem; color: #94a3b8; max-width: 600px;  
    display: none; margin: 4px 0 0 0; padding: 0; line-height: 1.4; font-weight: 300;
}
@media (min-width: 1024px) { .ggh-app-desc { display: block; } }
.ggh-right { display: flex; align-items: center; gap: 1rem; }
.ggh-right button {
    background: rgba(30, 41, 59, 0.6) !important; border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #cbd5e1 !important; width: 40px !important; height: 40px !important;
    border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important;
    cursor: pointer !important; transition: all 0.2s ease !important; padding: 0 !important; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}
.ggh-right button:hover {
    background: rgba(30, 41, 59, 1) !important; color: white !important; border-color: rgba(255, 255, 255, 0.2) !important; transform: translateY(-1px) !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Model cards */
.model-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    background: var(--bg-card);
}
.model-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.2);
}

/* Interactive sections editor */
.editable-section {
    position: relative;
    border: 2px dashed transparent;
    transition: all 0.2s;
    border-radius: 0.75rem;
}
.editable-section:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.015);
}
.editable-section:focus-within {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
    outline: none;
}
.editable-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.editable-section:hover .editable-indicator {
    opacity: 0.7;
}

/* Sidebar navigation */
.toc-sidebar {
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Gantt Chart */
.gantt-container {
    width: 100%;
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}
.gantt-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}
.gantt-row:last-child {
    border-bottom: none;
}
.gantt-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-main);
}
.gantt-timeline-wrapper {
    position: relative;
    height: 1.5rem;
    background: rgba(100, 116, 139, 0.05);
    border-radius: 9999px;
    overflow: hidden;
}
.gantt-bar {
    position: absolute;
    height: 100%;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    transition: all 0.5s ease-out;
}

/* Budget Pie Chart */
.budget-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}
@media (min-width: 640px) {
    .budget-chart-container {
        flex-direction: row;
    }
}
.budget-svg {
    transform: rotate(-90deg);
    width: 180px;
    height: 180px;
}
.budget-slice {
    fill: none;
    stroke-width: 32;
    transition: stroke-dasharray 0.5s ease-out;
}
.budget-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

/* Risk Matrix */
.risk-matrix {
    display: grid;
    grid-template-columns: 40px repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr) 40px;
    gap: 6px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}
.risk-cell {
    aspect-ratio: 1;
    border-radius: 0.375rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    position: relative;
    border: 1px solid rgba(0,0,0,0.05);
}
.risk-low {
    background-color: #d1fae5;
    color: #065f46;
}
.dark .risk-low {
    background-color: rgba(6, 95, 70, 0.2);
    color: #34d399;
}
.risk-medium {
    background-color: #fef3c7;
    color: #92400e;
}
.dark .risk-medium {
    background-color: rgba(146, 64, 14, 0.2);
    color: #fbbf24;
}
.risk-high {
    background-color: #fee2e2;
    color: #991b1b;
}
.dark .risk-high {
    background-color: rgba(153, 27, 27, 0.2);
    color: #f87171;
}
.risk-axis-label-vert {
    grid-column: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.risk-axis-label-horiz {
    grid-row: 4;
    grid-column: 2 / span 3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-top: 0.5rem;
}
.risk-dot {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    cursor: help;
    transition: transform 0.2s;
}
.risk-dot:hover {
    transform: scale(1.15);
    z-index: 10;
}

/* Custom visual charts in HTML/SVG */
.cashflow-bar {
    transition: height 0.5s ease-out;
}
.scenario-bar {
    transition: height 0.5s ease-out;
}

/* Printing styles */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    .grimont-global-header,
    .no-print,
    #editor-controls,
    #generator-form-section,
    .toc-sidebar {
        display: none !important;
    }
    main {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .editable-section {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin-bottom: 2rem !important;
        page-break-inside: avoid !important;
    }
    h1, h2, h3 {
        page-break-after: avoid;
    }
}
