/**
 * ===========================================================
 * TAHIR COLLECTION — Layout System
 * ===========================================================
 * Container, grid, and responsive layout utilities.
 * ===========================================================
 */

/* -------------------------------------------------------
 * CONTAINER — Centered content wrapper
 * ------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* Global Responsive Safety */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

img,
video,
canvas,
svg,
iframe,
embed,
object {
    display: block;
    max-width: 100%;
}

.container--narrow {
    max-width: var(--container-narrow);
}

.container--wide {
    max-width: var(--container-wide);
}

/* -------------------------------------------------------
 * SECTION SPACING — Vertical padding for page sections
 * ------------------------------------------------------- */
.section {
    padding: var(--space-20) 0;
}

.section--sm {
    padding: var(--space-12) 0;
}

.section--lg {
    padding: var(--space-24) 0;
}

.section--gray {
    background-color: var(--color-offwhite);
}

.section--dark {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.section--dark .section-title {
    color: var(--color-white);
}

/* -------------------------------------------------------
 * GRID SYSTEM — Responsive CSS Grid
 * ------------------------------------------------------- */
.grid {
    display: grid;
    gap: var(--space-8);
}

.grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid--6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* Ensure grid items don't expand beyond column width */
.grid>* {
    min-width: 0;
    max-width: 100%;
}

/* Responsive grid breakpoints */
@media (max-width: 1024px) {
    .grid--4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid--6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {

    .grid--2,
    .grid--3,
    .grid--4 {
        grid-template-columns: minmax(0, 1fr);
    }

    .grid--6 {
        grid-template-columns: minmax(0, 1fr);
    }

    .section {
        padding: var(--space-12) 0;
    }
}

@media (max-width: 480px) {
    .grid--6 {
        grid-template-columns: minmax(0, 1fr);
    }

    .container {
        padding: 0 var(--space-4);
    }
}

/* -------------------------------------------------------
 * TABLE RESPONSIVENESS — prevent horizontal overflow
 * ------------------------------------------------------- */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-10);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background-color: var(--color-white);
    display: block;
    position: relative;
}

.table-responsive table {
    min-width: 900px;
    /* Force table to be wider than mobile/tablet viewports to trigger scroll */
    margin-bottom: 0;
    border: none;
}

/* -------------------------------------------------------
 * FLEXBOX UTILITIES
 * ------------------------------------------------------- */
.flex {
    display: flex;
}

.flex--center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex--between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex--wrap {
    flex-wrap: wrap;
}

.flex--col {
    flex-direction: column;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.gap-8 {
    gap: var(--space-8);
}