/* ================================================================
 * DATEI: css/layout.css
 * ZWECK: Top-Bar, Main-Layout, Content-Views, Tabs, Suche, Group Selector
 * Aesthetic: Refined Brass Studio
 * ================================================================ */

/* ========== TOP BAR ========== */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    gap: var(--space-4);
}

.top-bar-left {
    display: flex;
    align-items: center;
    min-width: 140px;
}

.view-title {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.top-bar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 420px;
}

.global-search {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.global-search i {
    position: absolute;
    left: var(--space-3);
    color: var(--text-muted);
    font-size: var(--font-sm);
    pointer-events: none;
}

.global-search input {
    width: 100%;
    padding: 6px var(--space-10) 6px 34px;
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    transition: all var(--transition-normal);
}

.global-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-input);
    box-shadow: 0 0 0 3px var(--accent-primary-transparent);
}

.global-search input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    position: absolute;
    right: var(--space-3);
    padding: 1px 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    font-family: var(--font-family);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    line-height: 1.4;
}

/* ========== GLOBAL SEARCH RESULTS ========== */
.global-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 400px;
    overflow-y: auto;
    z-index: 3000;
    display: none;
    padding: var(--space-2) 0;
}

.global-search-results.active {
    display: block;
}

.global-search-group {
    padding: var(--space-1) 0;
}

.global-search-group-label {
    padding: var(--space-1) var(--space-4);
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.global-search-item {
    padding: var(--space-2) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    font-size: var(--font-sm);
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.global-search-item:hover {
    background: var(--bg-hover);
}

.global-search-item i {
    color: var(--text-muted);
    width: 16px;
    text-align: center;
    font-size: var(--font-sm);
}

.global-search-empty {
    padding: var(--space-4);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-sm);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 140px;
    justify-content: flex-end;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    cursor: default;
    transition: background var(--transition-fast);
}

.user-pill:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 26px;
    height: 26px;
    background: linear-gradient(145deg, var(--brass), var(--brass-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.65rem;
    color: var(--text-on-accent);
    flex-shrink: 0;
}

.user-name {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--font-xs);
    white-space: nowrap;
}

.btn-icon-sm {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    transition: all var(--transition-fast);
}

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

/* ========== MAIN AREA ========== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ========== MAIN LAYOUT ========== */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-app);
    min-width: 0;
}

/* ========== CONTEXT BAR ========== */
.context-bar {
    padding: var(--space-2) var(--space-5);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-sm);
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: var(--font-xs);
}

.context-stats {
    display: flex;
    gap: var(--space-4);
}

.context-stat {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.context-stat i {
    color: var(--accent-primary);
}

/* ========== CONTENT VIEWS ========== */
.content-views {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* ========== CONTENT TABS (Sub-Tabs) ========== */
.content-tabs {
    display: flex;
    gap: 0;
    padding: 0 var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    background: var(--bg-surface);
}

.content-tab {
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: -1px;
    position: relative;
    letter-spacing: -0.01em;
}

.content-tab:hover {
    color: var(--text-secondary);
}

.content-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.content-tab i {
    font-size: var(--font-xs);
    opacity: 0.7;
}

.content-tab.active i {
    opacity: 1;
}

/* ========== TAB CONTENT ========== */
.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

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

.tab-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    flex-shrink: 0;
    background: var(--bg-app);
}

.tab-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-5) var(--space-5);
}

/* ========== SEARCH & FILTERS ========== */
.search-box {
    position: relative;
    flex: 1;
    max-width: 280px;
}

.search-box i {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: var(--font-xs);
}

.search-box input {
    width: 100%;
    padding: 6px var(--space-3) 6px 32px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    transition: all var(--transition-normal);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-transparent);
    background: var(--bg-input);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    padding: 6px var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: border-color var(--transition-normal);
    appearance: none;
    -webkit-appearance: none;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235e5e64'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ========== GROUP SELECTOR DROPDOWN (Inhalte-View) ========== */
.content-group-selector {
    position: relative;
    padding: var(--space-3) var(--space-5);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.group-selector-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-normal);
    max-width: 350px;
}

.group-selector-button:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.group-selector-button i:first-child {
    color: var(--accent-warning);
    font-size: var(--font-xs);
}

.group-selector-button .gs-chevron {
    color: var(--text-muted);
    font-size: 0.6rem;
    margin-left: var(--space-1);
    transition: transform var(--transition-normal);
}

.content-group-selector:has(.group-selector-dropdown.open) .gs-chevron {
    transform: rotate(180deg);
}

.group-selector-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: var(--space-5);
    width: 320px;
    max-height: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    flex-direction: column;
}

.group-selector-dropdown.open {
    display: flex;
}

.group-selector-search {
    padding: var(--space-3);
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
}

.group-selector-search i {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: var(--font-xs);
}

.group-selector-search input {
    width: 100%;
    padding: 6px var(--space-3) 6px 30px;
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
}

.group-selector-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.group-selector-tree {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-1);
}

/* Group Selector Items */
.gs-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 5px var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-sm);
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.gs-item:hover {
    background: var(--bg-hover);
}

.gs-item.selected {
    background: var(--accent-primary-transparent);
    color: var(--accent-primary);
}

.gs-icon {
    color: var(--accent-warning);
    font-size: var(--font-xs);
    flex-shrink: 0;
}

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

.gs-count {
    font-size: var(--font-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
    font-variant-numeric: tabular-nums;
}

.gs-count i {
    font-size: 0.5rem;
}

/* ========== LEGACY TOP-NAV (hidden, backward compat for JS) ========== */
.top-nav {
    display: none;
}

.main-tabs {
    display: none;
}

.main-tab {
    display: none;
}
