/* ============================================
   SHARED LAYOUT & CONTAINER STYLES
   Page containers, headers, sections, grids
   ============================================ */

/* ===== Page Container ===== */
.page-container {
    padding: 24px;
    background: var(--bg-primary, #0a0a0f);
    min-height: 100vh;
    overflow-x: hidden;
}

.page-container.no-padding {
    padding: 0;
}

.page-container.compact {
    padding: 16px;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header-content {
    flex: 1;
    min-width: 200px;
}

.page-header h1,
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header h1 .icon,
.page-title .icon {
    font-size: 32px;
}

.page-header p,
.page-subtitle {
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-size: 14px;
    margin: 0;
}

.page-header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* ===== Section ===== */
.section {
    margin-bottom: 32px;
}

.section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-description {
    font-size: 14px;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    margin-top: 4px;
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* ===== Content Panel ===== */
.content-panel {
    background: var(--bg-card, #1e1e2a);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    padding: 24px;
}

.content-panel.compact {
    padding: 16px;
}

/* ===== Grid Layouts ===== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-auto-sm {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Form Row Grid */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ===== Flex Layouts ===== */
.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-start {
    display: flex;
    align-items: flex-start;
}

.flex-end {
    display: flex;
    justify-content: flex-end;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-col {
    flex-direction: column;
}

.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

/* ===== Dividers ===== */
.divider {
    height: 1px;
    background: var(--border-color, rgba(255, 255, 255, 0.1));
    margin: 24px 0;
}

.divider.thick {
    height: 2px;
}

.divider.vertical {
    width: 1px;
    height: auto;
    margin: 0 16px;
}

/* ===== Empty States ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
    max-width: 400px;
    margin-bottom: 20px;
}

/* ===== Loading States ===== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-top-color: var(--accent-primary, #6366f1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.sm {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

.spinner.lg {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

.loading-text {
    font-size: 14px;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

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

/* ===== Scroll Container ===== */
.scroll-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.scroll-container::-webkit-scrollbar {
    width: 8px;
}

.scroll-container::-webkit-scrollbar-track {
    background: var(--bg-secondary, rgba(255, 255, 255, 0.05));
    border-radius: 4px;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 4px;
}

.scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== Light Mode Overrides ===== */
[data-theme="light"] .page-container {
    background: var(--bg-primary, #f8fafc);
}

[data-theme="light"] .page-header h1,
[data-theme="light"] .page-title {
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .page-header p,
[data-theme="light"] .page-subtitle {
    color: var(--text-muted, #64748b);
}

[data-theme="light"] .content-panel {
    background: var(--bg-card, #ffffff);
    border-color: var(--border-color, #e2e8f0);
}

[data-theme="light"] .divider {
    background: var(--border-color, #e2e8f0);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1,
    .page-title {
        font-size: 24px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .content-panel {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .page-container {
        padding: 12px;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn {
        flex: 1;
    }
}
