/* Responsive Layout CSS - Mobile-First Design */
/* This file ensures all pages work well with the unified navbar */

:root {
    /* Layout Variables */
    --navbar-height: 60px;
    --sidebar-width: 300px;
    --sidebar-width-mobile: 100%;
    --content-max-width: 1200px;
    --content-padding: 20px;
    --content-padding-mobile: 15px;
    
    /* Breakpoints */
    --mobile-breakpoint: 768px;
    --tablet-breakpoint: 1024px;
    --desktop-breakpoint: 1200px;
}

/* Base Layout */
body {
    margin: 0;
    padding: 0;
    padding-top: var(--navbar-height);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Page Container */
.page-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--content-padding);
    gap: var(--content-padding);
}

/* Sidebar Layout */
.left-sidebar,
.right-sidebar {
    flex: 0 0 var(--sidebar-width);
    position: sticky;
    top: calc(var(--navbar-height) + var(--content-padding));
    height: fit-content;
    max-height: calc(100vh - var(--navbar-height) - var(--content-padding) * 2);
    overflow-y: auto;
}

.main-content {
    flex: 1;
    min-width: 0; /* Allow shrinking */
    max-width: 600px;
    margin: 0 auto;
}

/* Mobile Layout */
@media (max-width: 768px) {
    body {
        padding-top: var(--navbar-height);
    }
    
    .page-container {
        flex-direction: column;
        padding: var(--content-padding-mobile);
        gap: var(--content-padding-mobile);
    }
    
    .left-sidebar,
    .right-sidebar {
        flex: 0 0 var(--sidebar-width-mobile);
        position: static;
        max-height: none;
        order: 2;
    }
    
    .main-content {
        order: 1;
        max-width: 100%;
    }
    
    /* Ensure proper spacing for new layout */
    .left-sidebar .sidebar-card {
        margin-bottom: 15px;
    }
    
    .right-sidebar .sidebar-card {
        margin-bottom: 15px;
    }
}

/* Tablet Layout */
@media (min-width: 769px) and (max-width: 1024px) {
    .right-sidebar {
        display: none;
    }
    
    .left-sidebar {
        flex: 0 0 250px;
    }
    
    .main-content {
        max-width: 500px;
    }
}

/* Desktop Layout - Standard (Laptops/Desktops) */
@media (min-width: 1025px) {
    .page-container {
        gap: 25px;
        /* Ensure it fits within 1200px max-width */
        max-width: 1200px; 
    }
    
    .left-sidebar {
        flex: 0 0 280px;
    }
    
    .right-sidebar {
        flex: 0 0 280px;
    }
    
    .main-content {
        max-width: 590px;
    }
}

/* Large Desktop Layout */
@media (min-width: 1400px) {
    .page-container {
        max-width: 1500px;
    }
    
    .left-sidebar {
        flex: 0 0 350px;
    }
    
    .right-sidebar {
        flex: 0 0 350px;
    }
    
    .main-content {
        max-width: 750px;
    }
}

/* Card Layout */
.sidebar-card,
.create-post-card,
.post,
.ad-item,
.event-item {
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.sidebar-card:hover,
.create-post-card:hover,
.post:hover,
.ad-item:hover,
.event-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Mobile Card Adjustments */
@media (max-width: 768px) {
    .sidebar-card,
    .create-post-card,
    .post,
    .ad-item,
    .event-item {
        border-radius: 6px;
        margin-bottom: 15px;
    }
    
    .sidebar-card {
        padding: 16px;
    }
    
    .create-post-card,
    .post {
        padding: 14px;
    }
}

/* Content Spacing */
.content-section {
    margin-bottom: 30px;
}

.content-section:last-child {
    margin-bottom: 0;
}

/* Mobile Content Adjustments */
@media (max-width: 768px) {
    .content-section {
        margin-bottom: 20px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.3rem;
    }
}

/* Form Layout */
.form-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .form-container {
        padding: 15px;
        max-width: 100%;
    }
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* Flexbox Utilities */
.flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.align-start {
    align-items: flex-start;
}

.align-end {
    align-items: flex-end;
}

/* Spacing Utilities */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

/* Visibility Utilities */
.hidden { display: none; }
.visible { display: block; }

@media (max-width: 768px) {
    .hidden-mobile { display: none; }
    .visible-mobile { display: block; }
}

@media (min-width: 769px) {
    .hidden-desktop { display: none; }
    .visible-desktop { display: block; }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Smooth Transitions */
* {
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* Focus States */
button:focus,
input:focus,
textarea:focus,
select:focus,
a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .main-navbar,
    .left-sidebar,
    .right-sidebar,
    .mobile-nav-menu,
    .mobile-nav-toggle {
        display: none;
    }
    
    body {
        padding-top: 0;
    }
    
    .page-container {
        max-width: none;
        padding: 0;
    }
    
    .main-content {
        max-width: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .sidebar-card,
    .create-post-card,
    .post,
    .ad-item,
    .event-item {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
