/**
 * Responsive Design Styles
 * Mobile-first approach with breakpoints
 */

/* Base styles - Mobile first (320px+) */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}

/* Container with responsive padding */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Responsive videos */
video {
    max-width: 100%;
    height: auto;
}

/* Responsive iframes */
iframe {
    max-width: 100%;
}

/* Flexible grid system */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;
}

.col {
    flex: 1;
    padding: 0 8px;
    min-width: 0;
}

/* Mobile: Stack columns */
@media (max-width: 767px) {
    .row {
        flex-direction: column;
    }
    
    .col {
        width: 100%;
        margin-bottom: 16px;
    }
}

/* Responsive typography */
h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

h4 {
    font-size: clamp(1.125rem, 2.5vw, 1.5rem);
}

p {
    font-size: clamp(0.875rem, 2vw, 1rem);
}

/* Responsive navigation */
.nav-menu {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

@media (max-width: 767px) {
    .nav-menu {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .nav-menu a {
        display: block;
        padding: 12px 16px;
    }
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

@media (max-width: 767px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .nav-menu.active {
        display: flex;
    }
}

/* Responsive tables */
@media (max-width: 767px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Alternative: Stack table rows */
    .responsive-table {
        display: block;
    }
    
    .responsive-table thead {
        display: none;
    }
    
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }
    
    .responsive-table tr {
        margin-bottom: 16px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
    }
    
    .responsive-table td {
        text-align: right;
        padding: 8px 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .responsive-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: #6b7280;
    }
}

/* Responsive forms */
.form-group {
    margin-bottom: 16px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Responsive buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

@media (max-width: 767px) {
    .btn-block-mobile {
        display: block;
        width: 100%;
        margin-bottom: 8px;
    }
}

/* Responsive cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

@media (max-width: 767px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive spacing */
.section {
    padding: 40px 0;
}

@media (max-width: 767px) {
    .section {
        padding: 24px 0;
    }
}

/* Hide/show elements based on screen size */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none;
    }
    
    .show-mobile {
        display: block;
    }
}

/* Tablet breakpoint (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 0 24px;
    }
    
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop breakpoint (1024px+) */
@media (min-width: 1024px) {
    .container {
        padding: 0 32px;
    }
    
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large desktop (1440px+) */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Responsive video container (16:9 aspect ratio) */
.video-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

.video-responsive iframe,
.video-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsive sidebar layout */
.sidebar-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 24px;
}

@media (max-width: 1023px) {
    .sidebar-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: 2;
    }
    
    .main-content {
        order: 1;
    }
}

/* Responsive modal */
.modal {
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

@media (min-width: 768px) {
    .modal {
        max-width: 600px;
    }
}

/* Touch-friendly spacing on mobile */
@media (max-width: 767px) {
    button,
    a.btn,
    .clickable {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Increase spacing between interactive elements */
    .btn + .btn {
        margin-top: 8px;
    }
}

/* Responsive text alignment */
@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center;
    }
    
    .text-left-mobile {
        text-align: left;
    }
}

/* Flexible media queries for specific components */
@media (max-width: 767px) {
    /* Course cards */
    .course-card {
        flex-direction: column;
    }
    
    .course-card img {
        width: 100%;
        height: auto;
    }
    
    /* Dashboard metrics */
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    /* Charts */
    .chart-container {
        overflow-x: auto;
    }
}

/* Print styles */
@media print {
    .no-print,
    nav,
    .sidebar,
    button,
    .btn {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .video-responsive {
        padding-bottom: 40%;
    }
}

/* Support for notch/safe areas on mobile devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}
