/* Global variables and styles */
:root {
    --bg-dark: #07080d;
    --bg-darker: #040406;
    --panel-bg: rgba(18, 20, 36, 0.5);
    --panel-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(22, 26, 46, 0.55);
    --text-main: #f1f3f9;
    --text-muted: #8e9aa8;
    --accent: #8a2be2;
    --accent-glow: rgba(138, 43, 226, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --success: #10b981;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 15px rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(138, 43, 226, 0.12) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(0, 188, 212, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Glassmorphism utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-main);
    border-radius: 16px;
}

/* Application Layout */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        min-height: 100vh;
    }
}

/* Sidebar styling */
.sidebar {
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 32px);
    margin: 16px;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .sidebar {
        height: auto;
        margin: 16px;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 28px;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
    animation: rotateSlow 20s linear infinite;
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    background: linear-gradient(135deg, #fff 0%, #b388ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Stats Panel */
.stats-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
}

.progress-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent) 0%, #00bcd4 100%);
    border-radius: 4px;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.progress-bar.exceeded {
    background: linear-gradient(90deg, var(--danger) 0%, #ff7979 100%);
}

.stat-footer {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.stat-footer.warning {
    color: var(--danger);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #6200ea 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-glow {
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ff6b6b;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 12px var(--danger-glow);
}

.actions {
    margin-bottom: 24px;
}

/* Tasks list in sidebar */
.tasks-section h3 {
    font-family: var(--font-heading);
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 4px;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.task-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    margin-right: 8px;
}

.task-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.task-item-name {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.task-item-pct {
    font-family: var(--font-heading);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.task-item-actions {
    display: flex;
    gap: 4px;
}

.task-item-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.task-item-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.task-item-btn.btn-del:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ff6b6b;
}

/* Main Content Area */
.main-content {
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 16px;
    height: calc(100vh - 32px);
    margin: 16px 16px 16px 0;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .main-content {
        margin: 16px;
        height: auto;
        grid-template-rows: auto auto;
        overflow: visible;
    }
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    margin-bottom: 16px;
}

.tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-actions .btn {
    padding: 10px;
    width: auto;
}

/* Tab panes styling */
.tab-panes {
    position: relative;
    height: 100%;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .tab-panes {
        height: auto;
        overflow: visible;
    }
}

.tab-pane {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.4s ease;
}

.tab-pane.active {
    display: flex;
}

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

.view-description {
    margin-bottom: 16px;
}

.view-description h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.view-description p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Squares view: Treemap Layout */
.treemap-wrapper {
    flex: 1;
    padding: 20px;
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.treemap-container {
    width: 100%;
    height: 100%;
    max-width: 600px;
    max-height: 600px;
    aspect-ratio: 1 / 1;
    position: relative;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 2px dashed rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

/* Treemap cells */
.treemap-cell {
    position: absolute;
    border-radius: 12px;
    border: 2px solid var(--bg-dark);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.treemap-cell:hover {
    transform: scale(1.015);
    z-index: 10;
    filter: brightness(1.1);
}

.treemap-cell-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.treemap-cell-pct {
    align-self: flex-end;
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    opacity: 0.9;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Free space block */
.treemap-cell-free {
    background: rgba(255, 255, 255, 0.015) !important;
    border: 2px dashed rgba(255, 255, 255, 0.15) !important;
    cursor: default;
    box-shadow: none !important;
}

.treemap-cell-free:hover {
    transform: none;
    z-index: 1;
    filter: none;
}

.treemap-cell-free .treemap-cell-title {
    color: var(--text-muted);
}

.treemap-cell-free .treemap-cell-pct {
    color: var(--text-muted);
}

/* Mind Map Canvas */
.mindmap-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 480px;
    border-radius: 16px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: grab;
}

.mindmap-canvas:active {
    cursor: grabbing;
}

.mindmap-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.mindmap-svg path {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke 0.3s ease;
    filter: drop-shadow(0 0 3px rgba(255,255,255,0.1));
}

/* Mind Map Nodes */
.mindmap-node {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
    cursor: move;
    user-select: none;
}

.center-node {
    z-index: 3;
    cursor: pointer;
}

.center-node .node-content {
    background: radial-gradient(circle at top left, #301b5a 0%, #150a2e 100%);
    border: 2px solid var(--accent);
    color: white;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 0 20px var(--accent-glow);
    font-family: var(--font-heading);
    transition: all 0.3s ease;
}

.center-node:hover .node-content {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.6);
    border-color: #a855f7;
}

.center-node i {
    font-size: 24px;
    color: #b388ff;
}

.center-node span {
    font-weight: 700;
    font-size: 12px;
    text-align: center;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

/* Draggable child nodes */
.child-node {
    transition: box-shadow 0.2s ease;
}

.child-node .node-content {
    background: rgba(26, 29, 50, 0.85);
    border: 1px solid var(--panel-border);
    padding: 12px 18px;
    border-radius: 12px;
    min-width: 130px;
    max-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-main);
    position: relative;
}

.child-node.dragging .node-content {
    background: rgba(35, 39, 68, 0.95);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.child-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.child-node-pct {
    align-self: flex-end;
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 800;
    opacity: 0.9;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 4, 7, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 460px;
    padding: 28px;
    animation: modalScaleUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes modalScaleUp {
    from { transform: scale(0.9) translateY(15px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-close:hover {
    color: white;
}

/* Forms styling */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Range input layout */
.range-input-container {
    display: grid;
    grid-template-columns: 1fr 70px auto;
    align-items: center;
    gap: 12px;
}

.range-input-container input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.range-input-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform 0.1s ease;
}

.range-input-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-input-container input[type="number"] {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-family: var(--font-body);
    font-size: 14px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.range-input-container input[type="number"]::-webkit-outer-spin-button,
.range-input-container input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.range-input-container .unit {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Colors presets & custom color styling */
.color-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.color-preset {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.color-preset:hover {
    transform: scale(1.15);
}

.color-preset.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.custom-color-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-color-label {
    font-size: 12.5px !important;
    margin-bottom: 0 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 12px;
}

.form-actions .right-buttons {
    display: flex;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
}

.form-actions .btn {
    width: auto;
}

.hidden {
    display: none !important;
}

/* Dropdown Select Styling */
.form-group select.form-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.form-group select.form-select option {
    background-color: #12131a;
    color: white;
}

.form-group select.form-select:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Sidebar tasks hierarchy */
.task-item.sub-task {
    margin-left: 20px;
    border-left: 2px dashed rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.015);
    font-size: 12.5px;
    padding: 8px 10px;
}

.task-item.sub-task .task-item-name::before {
    content: "↳ ";
    color: var(--text-muted);
    font-weight: bold;
}

/* Nested Treemap cells */
.treemap-cell-header {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
}

.treemap-nested-container {
    position: relative;
    width: 100%;
    height: calc(100% - 20px);
    overflow: hidden;
    border-radius: 8px;
}

.treemap-subcell {
    position: absolute;
    border-radius: 6px;
    border: 1px solid var(--bg-dark);
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.treemap-subcell:hover {
    transform: scale(1.02);
    z-index: 5;
    filter: brightness(1.1);
}

.treemap-subcell-title {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.treemap-subcell-pct {
    align-self: flex-end;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.treemap-subcell-free {
    background: rgba(255, 255, 255, 0.015) !important;
    border: 1px dashed rgba(255, 255, 255, 0.12) !important;
    cursor: default;
    box-shadow: none !important;
}

.treemap-subcell-free:hover {
    transform: none;
    z-index: 1;
    filter: none;
}

.treemap-subcell-free .treemap-subcell-title,
.treemap-subcell-free .treemap-subcell-pct {
    color: var(--text-muted);
}

