/* layout.css - Main Layout Structure */

/* ========== HEADER ========== */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-sm) var(--space-lg);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.header-content {
    width: 100%;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-lg);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-brand h1 {
    font-size: var(--text-xl);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--success-light);
    color: var(--success);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
}

.sync-status.offline {
    background: var(--warning-light);
    color: #b45309;
}

.sync-status svg {
    width: 14px;
    height: 14px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    width: 100%;
    margin: 0;
    padding: var(--space-md) var(--space-lg);
    flex: 1;
}

/* ========== VIEW CONTAINER ========== */
.view {
    display: none;
    animation: fadeIn var(--transition-base);
}

.view.active {
    display: block;
}

/* ========== NAVIGATION ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-sm);
    z-index: var(--z-fixed);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.nav-container {
    width: 100%;
    margin: 0;
    display: flex;
    justify-content: space-around;
    gap: var(--space-sm);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-sm);
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    flex: 1;
    max-width: 120px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-item span {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.nav-item:hover {
    background: var(--border-light);
    color: var(--primary);
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    background: rgba(78, 52, 46, 0.1);
    font-weight: var(--font-semibold);
}

/* ========== FILTERS SECTION ========== */
.filters-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border);
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.filters-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--primary);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-lighter);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-md);
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-light);
    margin-bottom: var(--space-sm);
}

.empty-state p {
    font-size: var(--text-sm);
}

/* ========== LIST CONTAINER ========== */
.list-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.list-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--primary);
}

.list-count {
    background: var(--primary-light);
    color: white;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    min-width: 24px;
    text-align: center;
}

/* ========== STATS CARDS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: var(--text-sm);
    opacity: 0.9;
    margin-bottom: var(--space-sm);
    font-weight: var(--font-medium);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
}

.stat-change {
    font-size: var(--text-xs);
    margin-top: var(--space-sm);
    opacity: 0.8;
}

/* ========== VIEW HEADER MERGED ========== */
.view-header-merged {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.view-header-merged .view-title {
    margin: 0;
    white-space: nowrap;
}

.view-header-merged .view-tabs {
    display: flex;
    justify-content: center;
}

.view-header-merged .view-actions {
    display: flex;
    justify-content: flex-end;
}

/* ========== ACTION BAR ========== */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    gap: var(--space-md);
    flex-wrap: wrap;
}

.action-bar-left,
.action-bar-right {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

/* ========== HIERARCHICAL LIST ========== */
.hierarchy-item {
    border-bottom: 1px solid var(--border-light);
}

.hierarchy-item:last-child {
    border-bottom: none;
}

.hierarchy-header {
    padding: var(--space-md) var(--space-lg);
    background: #f9fafb;
    font-weight: var(--font-semibold);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-fast);
}

.hierarchy-header:hover {
    background: #f3f4f6;
}

.hierarchy-content {
    padding: var(--space-sm) var(--space-lg);
    display: none;
}

.hierarchy-item.expanded .hierarchy-content {
    display: block;
}

.hierarchy-item.expanded .hierarchy-header {
    background: white;
}

.sub-item {
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid var(--primary-light);
    margin: var(--space-sm) 0;
    background: white;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.sub-item:hover {
    background: var(--border-light);
    border-color: var(--primary);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .main-content {
        padding: var(--space-md);
    }

    .header-content {
        flex-direction: column;
        gap: var(--space-md);
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .action-bar-left,
    .action-bar-right {
        justify-content: center;
    }
}