/* ============================================================
   Layout — Top bar, sidebar, main content grid
   ============================================================ */

/* ── Top Bar ───────────────────────────────────────────────── */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px 10px 12px;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--topbar-border);
    position: relative;
    z-index: 20;
}

.top-bar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar-logo {
    height: 28px;
    width: 28px;
    object-fit: contain;
    border-radius: 6px;
}

.top-bar h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.top-bar .btn-primary {
    font-size: 12px;
    padding: 5px 14px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-bar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}

.top-bar-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ── Layout Grid ───────────────────────────────────────────── */

.layout {
    display: flex;
    height: calc(100vh - 49px);
}

/* ── Sidebar ───────────────────────────────────────────────── */

.sidebar {
    width: 286px;
    min-width: 140px;
    max-width: 50vw;
    background: var(--bg-secondary);
    border-right: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-resize-handle {
    width: 4px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
    background: var(--accent);
}

.sidebar-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section.collapsed .sidebar-section-body {
    display: none;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 8px 12px;
    cursor: pointer;
    user-select: none;
}

.sidebar-section-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-section-header h2 {
    padding: 0;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.collapse-chevron {
    transition: transform 0.2s ease;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.sidebar-section.collapsed .collapse-chevron {
    transform: rotate(-90deg);
}

.section-count-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0 6px;
    line-height: 16px;
    min-width: 16px;
    text-align: center;
}

/* ── Sidebar Subtabs ───────────────────────────────────────── */

.sidebar-subtabs {
    display: flex;
    gap: 2px;
    padding: 0 12px 8px;
}

.sidebar-subtab {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.sidebar-subtab.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-dim);
    color: var(--text-primary);
}

.sidebar-subtab:hover:not(.active) {
    background: var(--bg-hover);
}

.subtab-count:empty {
    display: none;
}

.subtab-count {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 2px;
}

.sidebar-new-btn {
    margin: 0 !important;
    padding: 2px 8px !important;
    font-size: 11px !important;
}

.sidebar-section h2 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0 16px 8px;
}

.sidebar-section .sidebar-section-header h2 {
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-primary);
    padding: 0;
}

/* ── History Search & Filters ──────────────────────────────── */

.history-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 12px 8px;
}

.history-filters input[type="search"] {
    width: 100%;
    padding: 5px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.history-filters input[type="search"]:focus {
    border-color: var(--accent);
}

/* ── Advanced Filter Panel ─────────────────────────────────── */

.hf-search-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.hf-search-row input[type="search"] {
    flex: 1;
    min-width: 0;
}

.hf-adv-btn {
    flex-shrink: 0;
    position: relative;
    padding: 5px 8px;
}

.hf-active-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: var(--bg-primary);
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    padding: 0 2px;
}

.hf-advanced {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

.hf-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 22px;
}

.hf-label {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 44px;
    flex-shrink: 0;
}

.hf-toggle-group {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.hf-toggle {
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}

.hf-toggle.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: #fff;
}

.hf-toggle:hover:not(.active) {
    background: var(--bg-hover);
}

.hf-tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.hf-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    background: var(--accent-dim);
    color: #fff;
}

.hf-tag-remove {
    cursor: pointer;
    opacity: 0.75;
    font-size: 13px;
    line-height: 1;
}

.hf-tag-remove:hover {
    opacity: 1;
}

.hf-tag-add-select {
    max-width: 90px;
    padding: 2px 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    outline: none;
    cursor: pointer;
}

.hf-tag-add-select:focus {
    border-color: var(--accent);
}

.hf-date {
    flex: 1;
    min-width: 0;
    padding: 3px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    outline: none;
}

.hf-date:focus {
    border-color: var(--accent);
}

.hf-dur-input {
    width: 50px;
    padding: 3px 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    outline: none;
}

.hf-dur-input:focus {
    border-color: var(--accent);
}

.hf-dur-sep,
.hf-dur-unit {
    font-size: 11px;
    color: var(--text-muted);
}

.hf-clear-btn {
    align-self: flex-start;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Main Content ──────────────────────────────────────────── */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Welcome Screen ────────────────────────────────────────── */

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

.welcome-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    margin-bottom: 8px;
    opacity: 0.85;
}

.welcome h2 {
    font-size: 20px;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.welcome-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.welcome-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 28px;
    width: 120px;
    height: 100px;
    text-decoration: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    font-family: inherit;
}

.welcome-action-card .material-icons {
    font-size: 28px;
    color: var(--accent);
}

.welcome-action-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-dim);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ── Resize Handle Grip Pattern ────────────────────────────── */

.task-bar-resize-handle::after,
.sidebar-resize-handle::after {
    content: '';
    display: block;
    width: 4px;
    height: 20px;
    margin: auto;
    background: radial-gradient(circle, var(--text-muted) 1px, transparent 1px);
    background-size: 4px 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.task-bar-resize-handle:hover::after,
.sidebar-resize-handle:hover::after {
    opacity: 0.6;
}
