:root {
    --bg-dark: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    font-size: 15px;
    /* Default size */
    transition: font-size 0.2s ease;
}

/* UI Density / Font Size Modifiers */
body.density-xs {
    font-size: 12px;
}

body.density-xs .data-table th {
    padding: 6px 10px;
}

body.density-xs .data-table td {
    padding: 6px 10px;
}

body.density-xs .sidebar-nav li {
    padding: 6px 10px;
    margin-bottom: 2px;
}

body.density-xs .section-header {
    margin-bottom: 8px;
}

body.density-xs .tree-item {
    padding: 4px 8px;
    font-size: 0.85em;
}

body.density-xs .tree-dir {
    margin-top: 5px;
    font-size: 0.9em;
}

body.density-compact {
    font-size: 13px;
}

body.density-compact .data-table th {
    padding: 8px 12px;
}

body.density-compact .data-table td {
    padding: 8px 12px;
}

body.density-compact .sidebar-nav li {
    padding: 8px 12px;
    margin-bottom: 4px;
}

body.density-compact .section-header {
    margin-bottom: 12px;
}

body.density-comfortable {
    font-size: 16px;
}

body.density-comfortable .data-table th {
    padding: 16px 20px;
}

body.density-comfortable .data-table td {
    padding: 18px 20px;
}

body.density-comfortable .sidebar-nav li {
    padding: 14px 18px;
    margin-bottom: 10px;
}

/* Tree Toggle CSS */
.tree-dir {
    cursor: pointer;
    user-select: none;
}

.tree-chevron {
    transition: transform 0.2s ease;
}

.tree-dir.collapsed .tree-chevron {
    transform: rotate(-90deg);
}

.tree-children.collapsed {
    display: none;
}

/* Background Animated Blobs */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #3b82f644, transparent);
    top: -200px;
    left: -200px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #8b5cf644, transparent);
    bottom: -100px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(100px, 50px);
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Login Screen */
.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    text-align: center;
}

.centered h2 {
    margin-bottom: 8px;
    font-weight: 600;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 12px;
}

.search-highlight {
    background: rgba(234, 179, 8, 0.4);
    /* Yellow tint */
    color: white;
    border-radius: 4px;
    padding: 0 2px;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 250px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

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

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sidebar-nav li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar-nav li.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.view-section {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.btn-refresh {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Table */
.table-container {
    flex: 1;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    z-index: 1;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.hash-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
}

/* Commit Badges */
.badge-feat {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 6px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-fix {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 6px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-docs {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 6px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-chore {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 6px;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.badge-refactor {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 6px;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-default {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
    margin-right: 6px;
}

/* Split Layout (Workplans) */
.split-layout {
    flex-direction: row;
    padding: 0;
}

.tree-sidebar {
    width: 300px;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.tree-sidebar .section-header {
    padding: 20px 20px 0;
}

.file-tree {
    list-style: none;
    overflow-y: auto;
    padding: 10px 20px 20px;
    flex: 1;
}

.tree-item {
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: 0.2s;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.tree-item.selected {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

.tree-dir {
    font-weight: 600;
    margin-top: 10px;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-children {
    margin-left: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 10px;
    list-style: none;
}

.document-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: rgba(0, 0, 0, 0.2);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 16px;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Markdown Styles */
.markdown-body {
    color: #e2e8f0;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
}

.markdown-body h1 {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.markdown-body h2 {
    margin-top: 30px;
    margin-bottom: 15px;
}

.markdown-body p {
    margin-bottom: 16px;
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 16px;
    padding-left: 20px;
}

.markdown-body code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--glass-border);
}

.markdown-body blockquote {
    border-left: 4px solid var(--accent);
    margin: 0 0 16px 0;
    padding-left: 16px;
    color: var(--text-secondary);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 0 8px 8px 0;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* Responsive Design / Mobile Optimization */
.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {

    /* Base Layout */
    .dashboard-layout {
        flex-direction: column;
        padding: 0;
    }

    /* Mobile Header Banner */
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        background: var(--glass-bg);
        border-bottom: 1px solid var(--glass-border);
        backdrop-filter: blur(10px);
        z-index: 50;
    }

    .mobile-header h2 {
        margin: 0;
        font-size: 1.2rem;
    }

    /* Side navigation as an off-canvas drawer */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-radius: 0;
        border-left: 1px solid var(--glass-border);
        border-right: none;
        background: rgba(15, 23, 42, 0.95);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Backdrop Overlay when drawer is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 90;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Table adjustments */
    .view-section {
        padding: 15px;
        border-radius: 0;
        border: none;
        background: transparent;
        box-shadow: none;
    }

    .table-container {
        overflow-x: auto;
        border: 1px solid var(--glass-border);
        border-radius: 8px;
    }

    .data-table th,
    .data-table td {
        white-space: nowrap;
    }

    /* Git Log Card View */
    #git-log-view .table-container {
        overflow-x: hidden;
        border: none;
        background: transparent;
    }

    #git-log-view .data-table thead {
        display: none;
    }

    #git-log-view .data-table,
    #git-log-view .data-table tbody {
        display: block;
        width: 100%;
        border: none;
    }

    #git-log-view .git-log-row {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 8px 10px;
        margin-bottom: 12px;
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        padding: 16px;
        background: rgba(255, 255, 255, 0.02);
    }

    #git-log-view .data-table td {
        padding: 0 !important;
        border: none !important;
        white-space: normal !important;
        display: flex;
        align-items: center;
    }

    #git-log-view .git-col-date {
        grid-column: 1 / span 2;
        grid-row: 1;
    }

    #git-log-view .date-badge {
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 6px;
        padding: 4px 10px;
        font-size: 0.85em;
        color: var(--text-secondary);
    }

    #git-log-view .git-col-hash {
        grid-column: 1;
        grid-row: 2;
    }

    #git-log-view .git-col-hash .mobile-icon {
        display: inline-block !important;
    }

    #git-log-view .git-col-author {
        grid-column: 2;
        grid-row: 2;
    }

    #git-log-view .git-col-action {
        grid-column: 3;
        grid-row: 1;
        justify-content: flex-end;
        align-items: flex-start;
    }

    #git-log-view .git-col-msg {
        grid-column: 1 / span 3;
        grid-row: 3;
        margin-top: 6px;
        line-height: 1.5;
    }

    /* Split layout (Workplans) */
    .split-layout {
        flex-direction: column;
    }

    .tree-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        max-height: 40vh;
    }

    .document-viewer {
        padding: 20px 15px;
    }

    /* Flex Views (DDNS Status) stacking */
    #ddns-status-view {
        flex-direction: column !important;
        overflow-y: auto;
    }

    #ddns-status-view>div {
        max-width: 100% !important;
        margin-bottom: 20px;
    }
}