/**
 * PAGE LAYOUT BALANCE - Perfect horizontal and vertical alignment for ALL pages
 * Fixes content and image placement issues across the entire website
 */

/* ========================================
   GLOBAL CONTAINER BALANCE
   ======================================== */

.container-custom {
    width: 100% !important;
    max-width: 1280px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 2rem !important;
    padding-right: 2rem !important;
}

@media (max-width: 1024px) {
    .container-custom {
        max-width: 100% !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
}

@media (max-width: 640px) {
    .container-custom {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ========================================
   SECTION SPACING - Consistent Padding
   ======================================== */

.section-padding {
    padding-top: 4rem !important;
    padding-bottom: 4rem !important;
}

@media (min-width: 768px) {
    .section-padding {
        padding-top: 5rem !important;
        padding-bottom: 5rem !important;
    }
}

@media (min-width: 1024px) {
    .section-padding {
        padding-top: 6rem !important;
        padding-bottom: 6rem !important;
    }
}

/* First section after header: tie to real header height (tight) */
main > section:first-child,
section:first-of-type {
    padding-top: calc(var(--header-height, 72px) + 0px) !important;
}

@media (min-width: 768px) {
    main > section:first-child,
    section:first-of-type {
        padding-top: calc(var(--header-height, 72px) + 0px) !important;
    }
}

@media (min-width: 1024px) {
    main > section:first-child,
    section:first-of-type {
        padding-top: calc(var(--header-height, 72px) + 0px) !important;
    }
}

/* ========================================
   GRID LAYOUTS - Perfect Balance
   ======================================== */

/* 2 Column Grid */
.grid.md\\:grid-cols-2,
.grid.lg\\:grid-cols-2 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    align-items: start !important;
}

@media (min-width: 768px) {
    .grid.md\\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 3rem !important;
    }
}

@media (min-width: 1024px) {
    .grid.lg\\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 3rem !important;
    }
}

/* 3 Column Grid */
.grid.lg\\:grid-cols-3,
.grid.md\\:grid-cols-3 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    align-items: start !important;
}

@media (min-width: 768px) {
    .grid.md\\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .grid.lg\\:grid-cols-3,
    .grid.md\\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2.5rem !important;
    }
}

/* 4 Column Grid */
.grid.lg\\:grid-cols-4,
.grid.md\\:grid-cols-4 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    align-items: start !important;
}

@media (min-width: 640px) {
    .grid.lg\\:grid-cols-4,
    .grid.md\\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 768px) {
    .grid.md\\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2rem !important;
    }
}

@media (min-width: 1024px) {
    .grid.lg\\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2rem !important;
    }
}

/* Ensure grid items are vertically aligned */
.grid > * {
    width: 100% !important;
    height: auto !important;
}

/* ========================================
   CARD LAYOUTS - Equal Heights & Spacing
   ======================================== */

.card {
    background: white !important;
    border-radius: 12px !important;
    padding: 2rem !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    transition: all 0.3s ease !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.card-hover:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
    transform: translateY(-4px) !important;
}

/* Card content should flex properly */
.card > * {
    margin-bottom: 1rem !important;
}

.card > *:last-child {
    margin-bottom: 0 !important;
    margin-top: auto !important;
}

/* ========================================
   IMAGE BALANCE - Proper Sizing & Alignment
   ======================================== */

/* All images should be responsive */
img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Card images */
.card img {
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 8px !important;
}

/* Product/Service card images */
.product-item img,
.service-card img,
.portfolio-item img {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: cover !important;
    border-radius: 8px !important;
}

/* Icon placeholders */
.bg-gray-100 {
    background-color: #f3f4f6 !important;
}

/* Logo images */
img[alt*="Logo"],
img[alt*="logo"] {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

/* ========================================
   TEXT ALIGNMENT - Centered Content
   ======================================== */

.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

/* Center content in sections */
section > .text-center {
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Limit text width for readability */
.max-w-2xl {
    max-width: 42rem !important;
}

.max-w-3xl {
    max-width: 48rem !important;
}

.max-w-4xl {
    max-width: 56rem !important;
}

.mx-auto {
    margin-left: auto !important;
    margin-right: auto !important;
}

/* ========================================
   FLEX LAYOUTS - Perfect Alignment
   ======================================== */

.flex {
    display: flex !important;
    align-items: center !important;
}

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

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

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

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

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

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

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

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

.gap-4 {
    gap: 1rem !important;
}

.gap-6 {
    gap: 1.5rem !important;
}

.gap-8 {
    gap: 2rem !important;
}

.gap-12 {
    gap: 3rem !important;
}

/* ========================================
   HERO SECTIONS - Full Width Balance
   ======================================== */

.hero-gradient {
    min-height: auto !important;
    display: flex !important;
    align-items: flex-start !important;
    padding-top: 0 !important;
    padding-bottom: 2rem !important;
}

@media (min-width: 768px) {
    .hero-gradient {
        min-height: auto !important;
    }
}

.min-h-screen { min-height: auto !important; }

/* ========================================
   BUTTON ALIGNMENT
   ======================================== */

.btn-primary,
.btn-secondary,
.btn-outline {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.75rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    border: none !important;
    cursor: pointer !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary), var(--primary)) !important;
    color: #ffffff !important;
}

.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(37, 117, 252, 0.35) !important;
}

.btn-secondary {
    background: #001F3F !important;
    color: white !important;
}

.btn-secondary:hover {
    background: #003366 !important;
}

.btn-outline {
    background: transparent !important;
    color: var(--primary) !important;
    border: 2px solid var(--primary) !important;
}

.btn-outline:hover {
    background: linear-gradient(135deg, var(--secondary), var(--primary)) !important;
    color: #ffffff !important;
}

/* Button groups */
.flex.gap-4 > .btn-primary,
.flex.gap-4 > .btn-outline,
.flex.gap-4 > .btn-secondary {
    flex: 0 1 auto !important;
}

/* ========================================
   SPACING UTILITIES - Consistent Margins
   ======================================== */

.mb-4 { margin-bottom: 1rem !important; }
.mb-6 { margin-bottom: 1.5rem !important; }
.mb-8 { margin-bottom: 2rem !important; }
.mb-12 { margin-bottom: 3rem !important; }
.mb-16 { margin-bottom: 4rem !important; }

.mt-4 { margin-top: 1rem !important; }
.mt-6 { margin-top: 1.5rem !important; }
.mt-8 { margin-top: 2rem !important; }
.mt-12 { margin-top: 3rem !important; }
.mt-16 { margin-top: 4rem !important; }

.py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-6 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-8 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
.py-12 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

.px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-6 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
.px-8 { padding-left: 2rem !important; padding-right: 2rem !important; }

/* ========================================
   PRODUCT/SERVICE CARDS - Equal Layout
   ======================================== */

.product-item,
.service-card,
.portfolio-item {
    background: white !important;
    border-radius: 12px !important;
    padding: 1.5rem !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    transition: all 0.3s ease !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.product-item:hover,
.service-card:hover,
.portfolio-item:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
    transform: translateY(-4px) !important;
}

/* Product image containers */
.product-item .bg-gray-100,
.service-card .bg-gray-100 {
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    margin-bottom: 1rem !important;
}

/* ========================================
   FORM LAYOUTS - Proper Spacing
   ======================================== */

form {
    width: 100% !important;
}

.input-group,
.form-group {
    margin-bottom: 1.5rem !important;
}

input,
textarea,
select {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    transition: all 0.2s ease !important;
}

input:focus,
textarea:focus,
select:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.15) !important;
}

label {
    display: block !important;
    margin-bottom: 0.5rem !important;
    font-weight: 600 !important;
    color: #374151 !important;
}

/* ========================================
   TABLE LAYOUTS - Responsive
   ======================================== */

table {
    width: 100% !important;
    border-collapse: collapse !important;
}

th,
td {
    padding: 1rem !important;
    text-align: left !important;
    border-bottom: 1px solid #e5e7eb !important;
}

th {
    font-weight: 600 !important;
    color: #111827 !important;
    background: #f9fafb !important;
}

/* ========================================
   MODAL/POPUP CENTERING
   ======================================== */

.modal {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0,0,0,0.5) !important;
    z-index: 99999 !important;
}

.modal-content {
    background: white !important;
    border-radius: 12px !important;
    padding: 2rem !important;
    max-width: 500px !important;
    width: 90% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

/* ========================================
   FOOTER BALANCE
   ======================================== */

footer {
    margin-top: auto !important;
}

footer .container-custom {
    display: block !important;
    gap: initial !important;
}

@media (min-width: 768px) {
    footer .container-custom {
        display: block !important;
    }
}

@media (min-width: 1024px) {
    footer .container-custom {
        display: block !important;
    }
}

/* ========================================
   LOADING STATES & PLACEHOLDERS
   ======================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%) !important;
    background-size: 200% 100% !important;
    animation: loading 1.5s ease-in-out infinite !important;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   PRINT OPTIMIZATION
   ======================================== */

@media print {
    .section-padding {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .card {
        break-inside: avoid !important;
    }
    
    header {
        position: relative !important;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

*:focus-visible {
    outline: 2px solid var(--primary) !important;
    outline-offset: 2px !important;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

/* ========================================
   SMOOTH SCROLLING
   ======================================== */

html {
    scroll-behavior: smooth !important;
}

/* ========================================
   PREVENT LAYOUT SHIFT
   ======================================== */

* {
    box-sizing: border-box !important;
}

img,
video,
iframe {
    max-width: 100% !important;
    height: auto !important;
}

/* ========================================
   CUSTOM DESIGN PAGE SPECIFIC
   ======================================== */

.aspect-square {
    aspect-ratio: 1 / 1 !important;
}

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

/* File upload areas */
[type="file"] + label {
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ========================================
   CART & CHECKOUT PAGES
   ======================================== */

.cart-item,
.checkout-item {
    display: flex !important;
    align-items: center !important;
    gap: 1.5rem !important;
    padding: 1.5rem !important;
    background: white !important;
    border-radius: 12px !important;
    margin-bottom: 1rem !important;
}

.cart-item img {
    width: 80px !important;
    height: 80px !important;
    object-fit: cover !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
}

/* ========================================
   RESPONSIVE FONT SIZES
   ======================================== */

h1 {
    font-size: 2.25rem !important;
    line-height: 1.2 !important;
}

h2 {
    font-size: 1.875rem !important;
    line-height: 1.3 !important;
}

h3 {
    font-size: 1.5rem !important;
    line-height: 1.4 !important;
}

@media (min-width: 768px) {
    h1 {
        font-size: 3rem !important;
    }
    
    h2 {
        font-size: 2.25rem !important;
    }
    
    h3 {
        font-size: 1.875rem !important;
    }
}

@media (min-width: 1024px) {
    h1 {
        font-size: 3.75rem !important;
    }
    
    h2 {
        font-size: 3rem !important;
    }
    
    h3 {
        font-size: 2.25rem !important;
    }
}

/* ========================================
   END OF LAYOUT BALANCE
   ======================================== */
