/* =========================================================
   LAYOUT.CSS
   DATAQ production layout system
   ========================================================= */

/* =========================
   Main app shell
   ========================= */

.app-shell {
    width: min(1440px, calc(100% - 64px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

/* =========================
   Page Header
   ========================= */

.page-header {
    background:
        radial-gradient(circle at 96% 10%, rgba(43, 156, 141, 0.36) 0 0, transparent 28%),
        linear-gradient(135deg, var(--dq-primary), var(--dq-primary-dark));
    color: white;
    border-radius: var(--dq-radius-xl);
    padding: 34px 38px;
    margin-bottom: 26px;
    box-shadow: var(--dq-shadow);
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 150px;
}

/* DATAQ-inspired circular identity element */
.page-header::after {
    content: "";
    position: absolute;
    width: 250px;
    height: 250px;
    inset-inline-end: -70px;
    top: -72px;
    border: 32px solid rgba(43, 156, 141, 0.34);
    border-radius: 50%;
    opacity: 0.95;
}

.page-header::before {
    content: "";
    position: absolute;
    width: 125px;
    height: 125px;
    inset-inline-end: 38px;
    bottom: -42px;
    border: 22px solid rgba(235, 229, 218, 0.12);
    border-radius: 50%;
}

.page-header > * {
    position: relative;
    z-index: 1;
}

.page-header h1 {
    margin: 6px 0 8px;
    font-size: clamp(30px, 3vw, 44px);
    font-weight: 900;
    letter-spacing: -0.045em;
    color: #ffffff;
}

.page-header .eyebrow {
    color: var(--dq-accent);
}

.page-subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.84);
    font-weight: 500;
    font-size: 15px;
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    max-width: 620px;
}

/* =========================
   Page content grids
   ========================= */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    margin-bottom: 24px;
}

.chart-wide {
    grid-column: span 2;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}

/* =========================
   Tables
   ========================= */

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--dq-radius-md);
    border: 1px solid var(--dq-border);
    background: white;
}

/* =========================
   Page sections
   ========================= */

.page-section {
    margin-bottom: 24px;
}

.section-stack {
    display: grid;
    gap: 24px;
}

/* =========================
   Two-column utility
   ========================= */

.two-column-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.three-column-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

/* =========================
   Arabic / RTL polish
   ========================= */

html[dir="rtl"] .header-actions {
    justify-content: flex-start;
}

html[dir="rtl"] .page-header h1 {
    letter-spacing: 0;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 1200px) {
    .app-shell {
        width: min(100% - 40px, 1440px);
    }

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

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

@media (max-width: 900px) {
    .app-shell {
        width: min(100% - 28px, 1440px);
        padding-top: 20px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        min-height: auto;
        padding: 30px 26px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .header-actions .btn {
        flex: 1;
        min-width: 140px;
    }

    .kpi-grid,
    .chart-grid,
    .filter-grid,
    .two-column-grid,
    .three-column-grid {
        grid-template-columns: 1fr;
    }

    .chart-wide {
        grid-column: span 1;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 20px, 1440px);
        padding-top: 14px;
    }

    .page-header {
        border-radius: var(--dq-radius-lg);
        padding: 26px 20px;
    }

    .page-header h1 {
        font-size: 30px;
    }

    .header-actions {
        flex-direction: column;
    }

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