/* CSS variables for a premium, Delphi/Windows-inspired compact yet modern look */
:root {
    --win-bg: #f3f5f8;
    --win-sidebar: #f8fafc;
    --win-border: #d2d7df;
    --win-accent: #0078d4; /* Standard Windows Blue */
    --win-accent-hover: #106ebe;
    --win-accent-soft: #e1f1ff;
    --win-text: #24292f;
    --win-text-muted: #57606a;
    --win-white: #ffffff;
    --win-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --win-header-height: 48px;
    --transition-speed: 0.2s;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--win-text);
    background-color: var(--win-bg);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

/* Layout container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar navigation */
.sidebar {
    width: 290px;
    min-width: 290px;
    background-color: var(--win-sidebar);
    border-right: 1px solid var(--win-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    transition: transform var(--transition-speed) ease;
}

/* Sidebar Header - Brand Info */
.sidebar-header {
    padding: 16px 14px;
    border-bottom: 1px solid var(--win-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 24px;
    color: var(--win-accent);
}

.brand-text h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--win-text);
    line-height: 1.2;
}

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

.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--win-text-muted);
    cursor: pointer;
    padding: 5px;
}

.mobile-close-btn:hover {
    color: var(--win-text);
}

/* Search bar inside sidebar */
.search-container {
    padding: 10px 14px;
    border-bottom: 1px solid var(--win-border);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--win-text-muted);
    font-size: 13px;
}

#searchInput {
    width: 100%;
    height: 28px;
    padding: 4px 28px 4px 28px;
    font-size: 13px;
    border: 1px solid var(--win-border);
    border-radius: 4px;
    background-color: var(--win-white);
    color: var(--win-text);
    outline: none;
    transition: border-color var(--transition-speed);
}

#searchInput:focus {
    border-color: var(--win-accent);
    box-shadow: 0 0 0 2px var(--win-accent-soft);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--win-text-muted);
    cursor: pointer;
    font-size: 14px;
}

.clear-search-btn:hover {
    color: var(--win-text);
}

/* Section Group Label */
.sections-title {
    padding: 12px 14px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--win-text-muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

/* Navigation Menu */
.navigation-menu {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 16px;
}

/* Collapsible Menu Group */
.menu-group {
    margin-bottom: 6px;
}

.menu-group-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--win-text);
    user-select: none;
    transition: background-color var(--transition-speed);
}

.menu-group-header:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.group-arrow {
    font-size: 10px;
    margin-right: 8px;
    transition: transform var(--transition-speed);
    color: var(--win-text-muted);
}

.group-icon {
    font-size: 14px;
    margin-right: 8px;
    color: var(--win-accent);
}

.group-title {
    flex: 1;
}

/* Sub-items list */
.menu-subitems {
    list-style: none;
    padding-left: 18px;
    margin-top: 2px;
    display: block; /* Toggled by JS */
}

/* State when closed */
.menu-group:not(.open) .menu-subitems {
    display: none;
}

.menu-group:not(.open) .group-arrow {
    transform: rotate(0deg);
}

.menu-group.open .group-arrow {
    transform: rotate(90deg);
}

.menu-subitems li {
    margin-bottom: 2px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    text-decoration: none;
    font-size: 13px;
    color: var(--win-text);
    border-radius: 4px;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.menu-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.menu-item.active {
    background-color: var(--win-accent-soft);
    color: var(--win-accent);
    font-weight: 600;
}

.doc-icon {
    font-size: 14px;
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

/* Icon specific colors for Delphi help appearance */
.word-color { color: #2b579a; }
.html-color { color: #e34c26; }
.excel-color { color: #217346; }
.wizard-color { color: #7b1fa2; }

.item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--win-border);
    font-size: 11px;
    color: var(--win-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(0, 0, 0, 0.01);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background-color: var(--win-white);
}

/* Top Toolbar Bar */
.top-bar {
    height: var(--win-header-height);
    min-height: var(--win-header-height);
    border-bottom: 1px solid var(--win-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background-color: var(--win-white);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle-btn {
    background: none;
    border: 1px solid var(--win-border);
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--win-text);
    transition: background-color var(--transition-speed);
}

.menu-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.current-section-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-icon {
    font-size: 16px;
    color: var(--win-text-muted);
}

#currentSectionTitle {
    font-size: 14px;
    font-weight: 600;
    color: var(--win-text);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Toolbar Buttons */
.action-btn {
    background: var(--win-white);
    border: 1px solid var(--win-border);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--win-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.action-btn:hover {
    background-color: var(--win-bg);
    border-color: #b0b8c3;
}

.action-btn i {
    font-size: 12px;
}

.action-btn#btnToggleFullscreen {
    padding: 0;
    width: 28px;
    justify-content: center;
}

/* Document View Container */
.document-viewer-container {
    flex: 1;
    position: relative;
    background-color: #f0f0f0;
    overflow: hidden;
    padding: 12px;
    display: flex;
    justify-content: center;
}

/* The actual IFrame */
#docViewer {
    width: 100%;
    height: 100%;
    border: 1px solid var(--win-border);
    border-radius: 4px;
    background-color: var(--win-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background-color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 4px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

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

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0, 120, 212, 0.1);
    border-top-color: var(--win-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Fullscreen Mode styling for viewer container */
.app-container.fullscreen .sidebar {
    display: none;
}

.app-container.fullscreen .top-bar {
    display: none;
}

.app-container.fullscreen .document-viewer-container {
    padding: 0;
}

.app-container.fullscreen #docViewer {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Highlight search matches style (concept) */
.hidden-by-search {
    display: none !important;
}

/* Responsive Rules */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .mobile-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-label {
        display: none; /* Hide labels on mobile to save space */
    }
    
    .action-btn {
        padding: 0;
        width: 32px;
        height: 32px;
        justify-content: center;
    }
    
    .action-btn i {
        font-size: 14px;
    }
}
