/* ========================================
   LAYOUT
   ======================================== */

/* Header */
.header {
    padding: var(--space-lg);
    background: var(--card-bg);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.header-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-action {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-action:hover {
    background: var(--border);
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-lg) var(--space-md);
}

.section-title {
    font-size: 18px;
    font-weight: 700;
}

.section-link {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

.section-link:hover {
    text-decoration: underline;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    padding: 12px 0 24px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: var(--z-sticky);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: var(--space-sm) var(--space-md);
    transition: all var(--transition-fast);
    text-decoration: none;
    min-width: 60px;
}

.nav-item .icon {
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    width: 28px;
    height: 28px;
}

.nav-item:hover .icon {
    color: var(--text-primary);
}

.nav-item.active .icon {
    color: var(--primary);
    fill: currentColor;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 100px;
    right: var(--space-lg);
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(26, 26, 46, 0.3);
    cursor: pointer;
    transition: all var(--transition);
    z-index: var(--z-sticky);
    text-decoration: none;
}

.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(26, 26, 46, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

.fab .icon {
    color: white;
}

/* Page Header (for sub-pages) */
.page-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.page-header .back-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-header .back-btn:hover {
    background: var(--border);
}

.page-header h1 {
    font-size: 20px;
    flex: 1;
}

.page-header .actions {
    display: flex;
    gap: var(--space-sm);
}

/* Content Container */
.content {
    padding: var(--space-md);
}

.content-sm {
    padding: var(--space-sm);
}

.content-lg {
    padding: var(--space-lg);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

/* List Layout */
.list {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.list-item {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: var(--card-bg-hover);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.list-item-action {
    margin-left: var(--space-md);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    padding: 0 var(--space-md);
    margin-bottom: var(--space-md);
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
    font-size: 22px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.stat-sub {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-sub.positive {
    color: var(--success);
}

.stat-sub.negative {
    color: var(--danger);
}

/* Transaction Item */
.transaction-item {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.transaction-item:hover {
    background: var(--card-bg-hover);
}

.transaction-item:active {
    background: var(--bg-secondary);
}

.transaction-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-right: var(--space-md);
    flex-shrink: 0;
}

.transaction-info {
    flex: 1;
    min-width: 0;
}

.transaction-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-meta {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.transaction-amount {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.transaction-amount.negative {
    color: var(--danger);
}

.transaction-amount.positive {
    color: var(--success);
}

.transaction-actions {
    display: flex;
    gap: var(--space-sm);
    margin-left: var(--space-sm);
}

.transaction-actions button {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.transaction-actions button:hover {
    background: var(--border);
    color: var(--text-primary);
}

.transaction-actions button.delete:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Weekly Chart */
.weekly-chart {
    background: var(--card-bg);
    margin: 0 var(--space-md);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.chart-title {
    font-size: 15px;
    font-weight: 700;
}

.chart-avg {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.chart-avg span {
    color: var(--text-primary);
    font-weight: 700;
}

.bars-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 120px;
    gap: var(--space-sm);
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.bar {
    width: 100%;
    background: var(--border);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all var(--transition);
    cursor: pointer;
}

.bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
    border-radius: var(--radius-sm);
    transition: height 0.5s ease;
}

.bar.today .bar-fill {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.bar-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.bar.today .bar-label {
    color: var(--accent);
    font-weight: 700;
}

/* Donut Chart */
.donut-chart-container {
    background: var(--card-bg);
    margin: 0 var(--space-md) var(--space-md);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.donut-chart {
    width: 200px;
    height: 200px;
    margin: 0 auto var(--space-xl);
    position: relative;
}

.donut-chart svg {
    transform: rotate(-90deg);
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-icon {
    font-size: 28px;
    margin-bottom: var(--space-xs);
}

.donut-value {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

.donut-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.category-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
}

.legend-info {
    flex: 1;
}

.legend-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.legend-percent {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Insight Cards */
.insight-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.insight-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.insight-title .icon {
    color: var(--accent);
}

.insight-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Alert Banner */
.alert-banner {
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    border-radius: var(--radius);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.alert-banner .icon {
    flex-shrink: 0;
}

.alert-banner.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%);
    color: var(--warning);
}

.alert-banner.danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%);
    color: var(--danger);
}

.alert-banner.success {
    background: linear-gradient(135deg, #dcfce7 0%, #f0fdf4 100%);
    color: var(--success);
}
