/* Layout System - Mobile First */

/* Base Layout */
.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-main {
    flex: 1 0 auto;
}

.site-footer {
    flex-shrink: 0;
}

/* Container System */
.container {
    width: 100%;
    padding-right: var(--space-4);
    padding-left: var(--space-4);
    margin-right: auto;
    margin-left: auto;
}

.container-fluid {
    width: 100%;
    padding-right: var(--space-4);
    padding-left: var(--space-4);
    margin-right: auto;
    margin-left: auto;
}

/* Grid System Enhancements */
.grid {
    display: grid;
    gap: var(--space-6);
}

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

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

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

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

/* Flex Utilities */
.flex {
    display: flex;
}

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

.flex-row {
    flex-direction: row;
}

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

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

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

.items-center {
    align-items: center;
}

.items-end {
    align-items: flex-end;
}

.justify-start {
    justify-content: flex-start;
}

.justify-center {
    justify-content: center;
}

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

.justify-between {
    justify-content: space-between;
}

.justify-around {
    justify-content: space-around;
}

.gap-0 { gap: var(--space-0); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.gap-12 { gap: var(--space-12); }

/* Header Layout */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-40);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    transition: var(--transition-normal);
}

.site-header.scrolled {
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-md);
}

/* Hero Layout */
.hero-section {
    position: relative;
    overflow: hidden;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: var(--z-0);
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(26, 26, 27, 0.8) 0%, rgba(26, 26, 27, 0.6) 100%);
    z-index: var(--z-10);
}

.hero-content {
    position: relative;
    z-index: var(--z-20);
}

/* Section Spacing */
.section {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
}

.section-sm {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
}

.section-lg {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
}

.section-xl {
    padding-top: var(--space-20);
    padding-bottom: var(--space-20);
}

/* Card Layout */
.card-grid {
    display: grid;
    gap: var(--space-6);
}

/* Sidebar Layout */
.with-sidebar {
    display: grid;
    gap: var(--space-8);
}

/* Footer Layout */
.footer-grid {
    display: grid;
    gap: var(--space-8);
}

/* Process Timeline */
.process-timeline {
    position: relative;
}

.timeline-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background-color: var(--color-primary);
    transform: translateX(-50%);
    z-index: var(--z-0);
}

.process-step {
    position: relative;
    z-index: var(--z-10);
}

/* Modal Layout */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-50);
    padding: var(--space-4);
}

.modal-container {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

/* Sticky Elements */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: var(--z-30);
}

.sticky-bottom {
    position: sticky;
    bottom: 0;
    z-index: var(--z-30);
}

/* Aspect Ratios */
.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-portrait {
    aspect-ratio: 3 / 4;
}

/* Overflow */
.overflow-hidden {
    overflow: hidden;
}

.overflow-auto {
    overflow: auto;
}

.overflow-x-auto {
    overflow-x: auto;
}

.overflow-y-auto {
    overflow-y: auto;
}

/* Position */
.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.fixed {
    position: fixed;
}

.sticky {
    position: sticky;
}

/* Z-Index */
.z-0 { z-index: var(--z-0); }
.z-10 { z-index: var(--z-10); }
.z-20 { z-index: var(--z-20); }
.z-30 { z-index: var(--z-30); }
.z-40 { z-index: var(--z-40); }
.z-50 { z-index: var(--z-50); }

/* Responsive Layout Utilities */
@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .md\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    
    .md\:flex-row {
        flex-direction: row;
    }
    
    .md\:flex-col {
        flex-direction: column;
    }
    
    .md\:with-sidebar {
        grid-template-columns: 2fr 1fr;
    }
    
    .md\:footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    
    .lg\:grid-cols-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
    
    .lg\:with-sidebar {
        grid-template-columns: 3fr 1fr;
    }
}

/* Print Layout */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print\:block {
        display: block !important;
    }
    
    .print\:w-full {
        width: 100% !important;
    }
    
    .page-break {
        page-break-before: always;
    }
    
    .avoid-break {
        page-break-inside: avoid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .hero-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .btn {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hero-content {
        opacity: 1 !important;
        transform: none !important;
    }
    
    .btn:hover {
        transform: none !important;
    }
}

/* Dark Mode Layout */
@media (prefers-color-scheme: dark) {
    .site-header {
        background-color: rgba(26, 26, 27, 0.95);
    }
    
    .site-header.scrolled {
        background-color: rgba(26, 26, 27, 0.98);
    }
    
    .hero-overlay {
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.6) 100%);
    }
}