/*
 * Gan't Do it software is free to use and copy as needed.
 * Purpose: Main stylesheet for layout, theme, and component styles.
 */

:root {
    --bg-color: #1a1c1e;
    --sidebar-color: #242629;
    --accent-color: #f4902c;
    --button-color: #3e444a;
    --header-bg: #242629;
    --text-color: #e1e2e5;
    --border-color: #33363a;
    --chart-row-height: 24px;
    --chart-col-width: 60px;
    --task-bar-color: #f4902c;
    --summary-bar-color: #ffb86c;
    
    --root-w: 24px;
    --parent-w: 20px;
    --child-w: 20px;
    --sibling-w: 20px;
    --color-w: 30px;
    --dep-w: 80px;
    --name-w: 280px;
    --prog-w: 50px;
    --start-w: 90px;
    --end-w: 90px;
    --dur-w: 50px;

    --sticky-width: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w) + var(--dep-w) + var(--name-w) + var(--prog-w) + var(--start-w) + var(--end-w) + var(--dur-w));
}

#workspace.hide-root { --root-w: 0px; }
#workspace.hide-parent { --parent-w: 0px; }
#workspace.hide-child { --child-w: 0px; }
#workspace.hide-sibling { --sibling-w: 0px; }
#workspace.hide-color { --color-w: 0px; }
#workspace.hide-dep { --dep-w: 0px; }
#workspace.hide-prog { --prog-w: 0px; }
#workspace.hide-start { --start-w: 0px; }
#workspace.hide-end { --end-w: 0px; }
#workspace.hide-dur { --dur-w: 0px; }

body { font-family: 'Segoe UI', sans-serif; margin: 0; display: flex; height: 100vh; background: var(--bg-color); color: var(--text-color); overflow: hidden; }

#workspace { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }

.hide-root .c-root, .hide-parent .c-parent, .hide-child .c-child, .hide-sibling .c-sibling,
.hide-color .c-color, .hide-dep .c-dep, .hide-prog .c-prog, .hide-start .c-start, .hide-end .c-end, .hide-dur .c-dur { display: none !important; }

.header { 
    padding: 5px 20px; 
    background: var(--header-bg); 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    gap: 20px;
    height: 35px;
}
.header h2 { margin: 0; font-size: 1.1em; flex-grow: 1; }

/* Menu System */
.menu-bar { display: flex; gap: 10px; }
.menu-group { position: relative; display: inline-block; }
.menu-label { padding: 5px 10px; cursor: pointer; font-weight: bold; font-size: 0.85em; border-radius: 4px; }
.menu-label:hover { background: #3e444a; }

.menu-content { 
    display: none; position: absolute; top: 100%; left: 0; 
    background: #242629; border: 1px solid var(--border-color); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); z-index: 1000;
    min-width: 180px; border-radius: 4px; padding: 5px 0;
}
.menu-group:hover .menu-content { display: block; }

.menu-content button, .menu-content label { 
    display: flex; align-items: center; width: 100%; padding: 8px 15px; 
    background: none; border: none; text-align: left; color: #ccc; 
    font-size: 0.85em; cursor: pointer; gap: 10px; box-sizing: border-box;
    border-radius: 0; font-family: inherit; font-weight: normal;
}
.menu-content button:hover, .menu-content label:hover { background: #3e444a; color: #fff; }
.menu-content input[type="checkbox"] { margin: 0; cursor: pointer; }

.zoom-controls { display: flex; align-items: center; gap: 5px; font-size: 0.8em; color: #888; }
.zoom-controls button { padding: 2px 8px; }

#editor-container { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.view-content { flex-grow: 1; display: none; overflow: auto; }
.view-content.active { display: flex; flex-direction: column; }

/* ReactFlow Selected Node Glow */
.react-flow__node.selected {
    box-shadow: 0 0 15px 5px var(--accent-color) !important;
    border-color: var(--accent-color) !important;
    transition: box-shadow 0.2s ease-in-out;
}

textarea { flex-grow: 1; width: 100%; font-family: monospace; padding: 15px; border: none; outline: none; background: #1a1c1e; color: #89ddff; font-size: 12px; }

#gantt-container { flex-grow: 1; overflow: auto; position: relative; background: #1a1c1e; }
#gantt-chart { display: inline-block; min-width: 100%; background: #1a1c1e; user-select: none; position: relative; }

.gantt-header { display: flex; position: sticky; top: 0; z-index: 100; background: #242629; border-bottom: 2px solid var(--border-color); height: 108px; }
.h-cell { flex-shrink: 0; border-right: 1px solid var(--border-color); padding: 0 5px; font-weight: bold; font-size: 0.75em; background: #242629; position: sticky; left: 0; z-index: 101; text-align: center; display: flex; align-items: center; justify-content: center; height: 100%; box-sizing: border-box; }
.col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 102;
}
.col-resizer:hover {
    background: var(--accent-color);
}

.h-cell.c-root, .h-cell.c-parent, .h-cell.c-child, .h-cell.c-sibling { 
    writing-mode: vertical-rl; 
    transform: rotate(180deg); 
    white-space: nowrap; 
    font-size: 10px !important;
    padding: 0 !important;
}

.d-cell.c-root, .d-cell.c-parent, .d-cell.c-child, .d-cell.c-sibling {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 10px;
    padding: 0 2px;
}

.c-root { left: 0; width: var(--root-w); }
.c-parent { left: calc(var(--root-w)); width: var(--parent-w); }
.c-child { left: calc(var(--root-w) + var(--parent-w)); width: var(--child-w); }
.c-sibling { left: calc(var(--root-w) + var(--parent-w) + var(--child-w)); width: var(--sibling-w); }
.c-color { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w)); width: var(--color-w); }
.c-dep { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w)); width: var(--dep-w); }
.c-name { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w) + var(--dep-w)); width: var(--name-w); text-align: left; padding-left: 10px; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis; }
.c-prog { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w) + var(--dep-w) + var(--name-w)); width: var(--prog-w); }
.c-start { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w) + var(--dep-w) + var(--name-w) + var(--prog-w)); width: var(--start-w); }
.c-end { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w) + var(--dep-w) + var(--name-w) + var(--prog-w) + var(--start-w)); width: var(--end-w); }
.c-dur { left: calc(var(--root-w) + var(--parent-w) + var(--child-w) + var(--sibling-w) + var(--color-w) + var(--dep-w) + var(--name-w) + var(--prog-w) + var(--start-w) + var(--end-w)); width: var(--dur-w); }

.gantt-timeline { display: flex; flex-direction: column; height: 100%; }
.timeline-seasons { height: 24px; border-bottom: 1px solid var(--border-color); display: flex; }
.timeline-quarters, .timeline-months, .timeline-weeks { display: flex; height: 20px; border-bottom: 1px solid var(--border-color); }
.timeline-days { display: flex; height: 24px; }
.season-band, .quarter-band, .month-band, .week-band { flex-shrink: 0; height: 100%; text-align: center; font-size: 0.65em; line-height: 20px; border-right: 1px solid var(--border-color); }
.week-band:nth-child(even) { background: #2a2d31; }
.week-band:nth-child(odd) { background: #1e2124; }

.day-col { width: var(--chart-col-width); text-align: center; border-right: 1px solid #2d3035; font-size: 0.7em; padding: 5px 0; flex-shrink: 0; color: #666; }

.gantt-row { display: flex; height: var(--chart-row-height); border-bottom: 1px solid #2d3035; align-items: center; contain: content; }
.gantt-row:hover .d-cell { background: #25282c; }
.gantt-row.drag-over { background: #2d3136; border-top: 2px solid var(--accent-color); }
.gantt-row.dragging { opacity: 0.3; }
.gantt-row.selected-row .d-cell { background: #2a3a4a; }

.gantt-rows-container {
    background-image: 
        linear-gradient(to right, rgba(45, 48, 53, 1) 1px, transparent 1px),
        linear-gradient(to right, rgba(45, 48, 53, 0.3) 1px, transparent 1px);
    background-size: var(--chart-col-width) 100%, calc(var(--chart-col-width) / 4) 100%;
}

.d-cell { flex-shrink: 0; padding: 0 5px; border-right: 1px solid var(--border-color); font-size: 0.8em; display: flex; align-items: center; height: 100%; position: sticky; z-index: 90; justify-content: center; box-sizing: border-box; }

.d-cell input { 
    background: transparent; 
    border: none; 
    color: inherit; 
    font-family: inherit; 
    font-size: inherit; 
    width: 100%; 
    height: 100%; 
    text-align: center; 
    outline: none; 
    cursor: pointer;
    padding: 0;
}
.d-cell input::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }
.d-cell input[type="number"] { -moz-appearance: textfield; }
.d-cell input[type="number"]::-webkit-inner-spin-button, 
.d-cell input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Hierarchical row colors */
.row-depth-0 .d-cell { background: #000000; color: #fff; font-weight: bold; }
.row-depth-1 .d-cell { background: #1a1a1a; }
.row-depth-2 .d-cell { background: #2d2d2d; }
.row-depth-leaf .d-cell { background: #1a1c1e; }

.d-cell.c-name { justify-content: flex-start; cursor: pointer; }
.d-cell.c-name:hover { background: #2c3e50 !important; }

.task-bars-cell { 
    position: relative; 
    flex-grow: 1; 
    height: 100%; 
}
.bar { 
    position: absolute; 
    height: 14px; 
    top: 3px; 
    background: var(--task-bar-color); 
    border-radius: 2px; 
    color: white; 
    font-size: 9px; 
    display: flex; 
    align-items: center; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.5); 
    z-index: 10; 
    border: 1px solid rgba(255,255,255,0.1);
    user-select: none;
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
}
.selected-bar {
    box-shadow: 0 0 10px 2px var(--accent-color), 0 0 5px rgba(255,255,255,0.5);
    z-index: 100 !important;
    border: 1px solid white !important;
}
.bar-handle { 
    position: absolute; 
    width: 12px; 
    height: 100%; 
    top: 0; 
    cursor: ew-resize; 
    z-index: 20; 
    background: transparent;
}
.bar:hover .bar-handle { background: rgba(255, 255, 255, 0.3); }

/* Dependency Handle Visibility */
.dependency-handle {
    opacity: 0;
    transition: opacity 0.2s ease;
}
.bar:hover .dependency-handle,
.dependency-handle.has-dependency {
    opacity: 1;
}

.bar-handle-left { left: 0; }
.bar-handle-right { right: 0; }
.bar-content { flex-grow: 1; padding: 0 4px; pointer-events: none; overflow: hidden; opacity: 0.9; display: flex; align-items: center; justify-content: center; height: 100%; }
.overlay-text { font-size: 8px; font-weight: bold; white-space: nowrap; }

.bar-label-left, .bar-label-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: #ccc;
    white-space: nowrap;
    pointer-events: none;
}
.bar-label-left { padding-right: 8px; text-align: right; }
.bar-label-right { padding-left: 8px; text-align: left; }

/* Resistor Colors */
.res-0 { background: #000000 !important; color: #fff; }
.res-1 { background: #5d4037 !important; color: #fff; }
.res-2 { background: #ff0000 !important; color: #fff; }
.res-3 { background: #ff9800 !important; color: #fff; }
.res-4 { background: #ffff00 !important; color: #000; }
.res-5 { background: #00ff00 !important; color: #fff; }
.res-6 { background: #2196f3 !important; color: #fff; }
.res-7 { background: #9c27b0 !important; color: #fff; }
.res-8 { background: #9e9e9e !important; color: #fff; }
.res-9 { background: #ffffff !important; color: #000; }
.res-none { background: #242629; color: #888; border: none !important; }
.res-cell { border: 1px solid rgba(255,255,255,0.1) !important; }
.progress-overlay { position: absolute; left: 0; top: 0; height: 100%; background: rgba(255,255,255,0.1); pointer-events: none; }

.fold-toggle { 
    cursor: pointer; 
    margin-right: 2px; 
    font-size: 14px; 
    width: 14px; 
    text-align: center; 
    display: inline-block; 
    color: var(--accent-color); 
    transition: transform 0.2s ease;
    user-select: none;
}
.fold-toggle.folded { transform: rotate(-90deg); color: #888; }

.btn-add { background: #2d7a4b; color: white; border: none; padding: 2px 5px; border-radius: 3px; cursor: pointer; font-size: 9px; margin-left: 5px; opacity: 0.3; }
.btn-del { background: #7a2d2d; color: white; border: none; padding: 2px 5px; border-radius: 3px; cursor: pointer; font-size: 9px; margin-left: 2px; opacity: 0.3; }
.btn-add:hover, .btn-del:hover { opacity: 1; }

button { background-color: var(--button-color); color: var(--text-color); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 0.85em; }
button:hover { background: #4a5057; }

.gantt-row:hover .d-cell { background: #4a5057 !important; }
.gantt-row.selected-row .d-cell { background: #2a3a4a !important; border-top: 1px solid var(--accent-color); border-bottom: 1px solid var(--accent-color); }
.gantt-row.selected-row .d-cell.c-name { background: #324a62 !important; }
.indent { width: 8px; flex-shrink: 0; border-left: 1px dotted #444; height: 100%; margin-right: 2px; }

#status { padding: 0 20px; font-size: 0.85em; color: #888; background: #242629; border-top: 1px solid var(--border-color); height: 30px; display: flex; align-items: center; justify-content: space-between; }
#status.error { color: #ff4a4a; background: #3a1c1c; }

#gantt-navigator {
    position: fixed;
    bottom: 40px;
    right: 20px;
    width: 150px;
    height: 250px;
    background: rgba(36, 38, 41, 0.9);
    border: 2px solid #444;
    border-radius: 4px;
    z-index: 2000;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    pointer-events: auto;
}

#nav-canvas {
    width: 100%;
    height: 100%;
}

#nav-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 15px;
    height: 15px;
    background: #555;
    cursor: nwse-resize;
    z-index: 2001;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

#nav-resize-handle:hover {
    background: var(--accent-color);
}

#nav-viewport {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(128, 128, 128, 0.3);
    pointer-events: none;
    box-sizing: border-box;
}

.confirm-group { display: none; gap: 10px; align-items: center; }
.confirm-group button { padding: 2px 10px; font-size: 0.9em; }

#palette-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 5px; }
.palette-color { width: 25px; height: 25px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.palette-color:hover { transform: scale(1.1); border-color: #fff; }
.palette-color.active { border-color: #fff; box-shadow: 0 0 5px #fff; }

#overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: none; justify-content: center; align-items: center; z-index: 1000; }
.overlay-content { background: var(--sidebar-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 15px; min-width: 300px; }
.overlay-content input[type="text"] { background: #1a1c1e; border: 1px solid var(--border-color); color: var(--text-color); padding: 8px; border-radius: 4px; outline: none; }

.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff4a4a; z-index: 150; pointer-events: none; }
.hover-line { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dotted #888; z-index: 151; pointer-events: none; display: none; }
.milestone-container { position: absolute; top: 0; bottom: 0; width: 0; z-index: 140; pointer-events: none; }
.milestone-line { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #ff4a4a; opacity: 0.8; }
.milestone-diamond { position: absolute; left: -6px; width: 12px; height: 12px; background: #ff4a4a; transform: rotate(45deg); cursor: ew-resize; box-shadow: 0 0 8px rgba(255,74,74,0.7); pointer-events: auto; z-index: 10; border: 1px solid white; }
.milestone-name { position: absolute; top: 120px; left: 12px; font-size: 11px; font-weight: bold; color: #ff4a4a; white-space: nowrap; background: rgba(26, 28, 30, 0.9); padding: 2px 6px; border-radius: 4px; pointer-events: auto; cursor: default; border: 1px solid #ff4a4a; }

.col-toggles { 
    padding: 5px 20px; 
    background: #242629; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    gap: 15px; 
    font-size: 0.75em; 
    color: #888;
    align-items: center;
    flex-wrap: wrap;
}
.col-toggles .toggle-item { display: flex; align-items: center; gap: 5px; }
.col-toggles .fold-btn { background: #3e444a; color: #ccc; border: none; padding: 2px 8px; border-radius: 3px; cursor: pointer; font-size: 10px; font-weight: bold; }
.col-toggles .fold-btn:hover { background: #f4902c; color: #fff; }
.col-toggles input { cursor: pointer; }

/* Printer View Styles */
#view-printer {
    background: #fff;
}
.printer-view-content {
    padding: 40px;
    background: white;
    color: black;
    min-height: 100%;
    overflow-y: auto;
    font-family: serif;
}
.p-root {
    font-size: 24pt;
    font-weight: bold;
    text-decoration: underline;
    margin-top: 30px;
    border-bottom: 2px solid black;
}
.p-parent {
    font-size: 18pt;
    font-weight: bold;
    margin-left: 20px;
    margin-top: 20px;
}
.p-child {
    font-size: 14pt;
    font-weight: bold;
    margin-left: 40px;
    margin-top: 10px;
}
.p-sibling {
    font-size: 12pt;
    font-weight: normal;
    margin-left: 60px;
    margin-top: 5px;
}

@media print {
    .header, .col-toggles, #status, .no-print, #gantt-navigator { display: none !important; }
    #editor-container { position: absolute; top: 0; left: 0; width: 100%; height: auto; overflow: visible !important; }
    .view-content { display: none !important; overflow: visible !important; }
    .view-content.active { display: block !important; overflow: visible !important; }
    
    /* Force white background for all printed views */
    body, #editor-container, .view-content.active, #view-spreadsheet, #view-mindmap { 
        background: white !important; 
        color: black !important; 
        overflow: visible !important;
    }

    /* Spreadsheet specific print overrides */
    #view-spreadsheet table { color: black !important; border-color: #ccc !important; }
    #view-spreadsheet th { background: #eee !important; color: black !important; border-color: #ccc !important; }
    #view-spreadsheet td { border-color: #ccc !important; }
    #view-spreadsheet tr { background: transparent !important; color: black !important; border-bottom: 1px solid #eee !important; }

    .printer-view-content { padding: 0; border: none !important; overflow: visible !important; }
    #view-printer { border: none !important; overflow: visible !important; }
    body { overflow: visible !important; }
}
