/* ===============================================
   LMS Global Responsive Stylesheet
   Bootstrap 5 Responsive Overrides + Media Queries
   =============================================== */

/* === Base Responsive Typography === */
:root {
    --font-scale: 1;
}

html {
    font-size: calc(16px * var(--font-scale));
}

/* === Fluid Container Override === */
.container, .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

/* === Responsive Navbar === */
.navbar {
    padding: 0.5rem 1rem;
}

.navbar-brand {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    white-space: nowrap;
}

.navbar-nav .nav-link {
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

.navbar-collapse {
    flex-grow: 0;
}

.navbar-toggler {
    border: none;
    padding: 0.25rem 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* === Responsive Cards === */
.card, .card-custom, .image-card, .stat-card {
    border-radius: clamp(10px, 2vw, 20px);
    padding: clamp(15px, 3vw, 25px);
}

.card-header {
    padding: clamp(12px, 2.5vw, 20px);
    font-size: clamp(0.9rem, 2vw, 1.1rem);
}

/* === Responsive Buttons === */
.btn {
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    padding: clamp(6px, 1.5vw, 12px) clamp(14px, 3vw, 24px);
    border-radius: clamp(6px, 1.5vw, 10px);
}

.btn-sm {
    font-size: clamp(0.75rem, 1.5vw, 0.85rem);
    padding: clamp(4px, 1vw, 6px) clamp(10px, 2vw, 14px);
}

.btn-lg {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    padding: clamp(10px, 2vw, 16px) clamp(20px, 4vw, 32px);
}

/* === Responsive Images === */
img {
    max-width: 100%;
    height: auto;
}

.carousel-item img {
    height: clamp(200px, 40vw, 450px);
    object-fit: cover;
    width: 100%;
}

/* === Responsive Tables === */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    margin-bottom: 0;
}

.table th, .table td {
    padding: clamp(6px, 1.5vw, 12px);
    white-space: nowrap;
}

/* === Responsive Forms === */
.form-control, .form-select {
    font-size: clamp(0.85rem, 2vw, 1rem);
    padding: clamp(8px, 2vw, 12px) clamp(10px, 2.5vw, 15px);
    border-radius: clamp(6px, 1.5vw, 10px);
}

.form-label {
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    margin-bottom: clamp(4px, 1vw, 8px);
}

/* === Responsive Section Spacing === */
section, .py-5 {
    padding-top: clamp(30px, 6vw, 80px) !important;
    padding-bottom: clamp(30px, 6vw, 80px) !important;
}

.py-4 {
    padding-top: clamp(20px, 4vw, 48px) !important;
    padding-bottom: clamp(20px, 4vw, 48px) !important;
}

.py-3 {
    padding-top: clamp(12px, 2.5vw, 24px) !important;
    padding-bottom: clamp(12px, 2.5vw, 24px) !important;
}

/* === Responsive Headings === */
h1, .h1 {
    font-size: clamp(1.5rem, 5vw, 3rem);
}

h2, .h2, .section-title {
    font-size: clamp(1.25rem, 4vw, 2.25rem);
}

h3, .h3 {
    font-size: clamp(1.1rem, 3vw, 1.75rem);
}

h4, .h4 {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
}

h5, .h5 {
    font-size: clamp(0.9rem, 2vw, 1.25rem);
}

h6, .h6 {
    font-size: clamp(0.85rem, 1.8vw, 1.1rem);
}

p, .lead {
    font-size: clamp(0.85rem, 2vw, 1.05rem);
}

/* === Responsive Hero Section === */
.hero-section {
    min-height: clamp(300px, 50vh, 600px);
    padding: clamp(40px, 8vw, 100px) 0;
}

.hero-section h1 {
    font-size: clamp(1.75rem, 6vw, 3.5rem);
}

.hero-section p {
    font-size: clamp(0.9rem, 2.5vw, 1.25rem);
}

/* === Responsive Carousel Captions === */
.carousel-caption {
    padding: clamp(10px, 2.5vw, 25px) clamp(15px, 3vw, 40px);
    bottom: clamp(10px, 3vw, 30px);
}

.carousel-caption h5 {
    font-size: clamp(0.9rem, 3vw, 1.5rem);
}

.carousel-caption p {
    font-size: clamp(0.75rem, 2vw, 1rem);
}

/* === Responsive Sidebar (Admin/Instructor/Student) === */
.sidebar {
    width: clamp(200px, 25vw, 250px);
    padding: clamp(10px, 2vw, 20px);
}

.sidebar-brand {
    font-size: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: clamp(15px, 3vw, 40px);
}

.sidebar .nav-link {
    padding: clamp(8px, 1.5vw, 12px) clamp(10px, 2vw, 20px);
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
}

.main-content {
    margin-left: clamp(200px, 25vw, 250px);
    padding: clamp(15px, 3vw, 30px);
}

/* === Responsive Footer === */
footer {
    padding: clamp(20px, 4vw, 40px) 0;
}

footer .footer-title {
    font-size: clamp(0.9rem, 2vw, 1.125rem);
}

footer .footer-link {
    font-size: clamp(0.75rem, 1.8vw, 0.875rem);
}

.footer-link:hover {
    transform: translateX(5px);
}

/* === Responsive Grid Gaps === */
.row.g-4 {
    --bs-gutter-x: clamp(10px, 2.5vw, 1.5rem);
    --bs-gutter-y: clamp(10px, 2.5vw, 1.5rem);
}

.row.g-3 {
    --bs-gutter-x: clamp(8px, 2vw, 1rem);
    --bs-gutter-y: clamp(8px, 2vw, 1rem);
}

/* === Responsive Badges === */
.badge {
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    padding: clamp(3px, 0.8vw, 5px) clamp(6px, 1.5vw, 10px);
}

/* === Responsive Alert === */
.alert {
    padding: clamp(10px, 2vw, 16px) clamp(12px, 2.5vw, 20px);
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    border-radius: clamp(8px, 2vw, 12px);
}

/* === Responsive Modal === */
.modal-dialog {
    max-width: clamp(90%, 95vw, 900px);
    margin: clamp(10px, 2vw, 30px) auto;
}

.modal-body {
    padding: clamp(15px, 3vw, 25px);
}

.modal-header {
    padding: clamp(12px, 2.5vw, 20px);
}

.modal-title {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
}

/* === Back to Top Button === */
#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9999;
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#backToTop:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
}

/* === Responsive Stat Cards === */
.stat-card .stat-icon {
    width: clamp(35px, 5vw, 45px);
    height: clamp(35px, 5vw, 45px);
    font-size: clamp(14px, 2.5vw, 18px);
}

.stat-card h4 {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
}

.stat-card p {
    font-size: clamp(0.7rem, 1.5vw, 0.85rem);
}

/* === Responsive Search Bar === */
.search-bar input, .form-control[type="search"] {
    font-size: clamp(0.85rem, 2vw, 1rem);
    padding: clamp(8px, 2vw, 12px) clamp(10px, 2.5vw, 16px);
}

/* ===============================================
   Media Queries - Breakpoint Specific Overrides
   =============================================== */

/* === Large Desktop (≤ 1199px) === */
@media (max-width: 1199.98px) {
    .hero-section h1 {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }
    
    .main-content {
        padding: 20px;
    }
}

/* === Medium Desktop / Tablet Landscape (≤ 991px) === */
@media (max-width: 991.98px) {
    :root {
        --font-scale: 0.95;
    }
    
    /* Navbar: collapse to hamburger */
    .navbar-collapse {
        background: rgba(255, 255, 255, 0.98);
        border-radius: 12px;
        padding: 15px;
        margin-top: 10px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    }
    
    .navbar-dark .navbar-collapse,
    .navbar-dark .navbar-nav {
        background: rgba(26, 26, 46, 0.98);
    }
    
    .navbar-nav .nav-link {
        padding: 10px 15px;
        border-radius: 8px;
    }
    
    .navbar-nav .nav-link:hover {
        background: rgba(102, 126, 234, 0.1);
    }
    
    /* Sidebar: collapse to top bar on tablets */
    .sidebar {
        position: relative;
        width: 100%;
        min-height: auto;
        display: none;
    }
    
    .sidebar.show {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    /* Carousel: smaller on tablet */
    .carousel-item img {
        height: clamp(180px, 30vw, 300px);
    }
    
    /* Tables: make scrollable */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Hero: reduce padding */
    .hero-section {
        padding: 30px 0;
        text-align: center;
    }
    
    .hero-section .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .hero-section .btn {
        width: 100%;
    }
}

/* === Tablet Portrait (≤ 767px) === */
@media (max-width: 767.98px) {
    :root {
        --font-scale: 0.9;
    }
    
    /* Stack all columns */
    .col-md-6, .col-md-4, .col-md-3, .col-md-2, .col-md-8, .col-md-9, .col-md-10 {
        width: 100%;
    }
    
    /* Carousel: even smaller */
    .carousel-item img {
        height: 220px;
    }
    
    .carousel-caption {
        padding: 10px 15px;
        bottom: 10px;
    }
    
    .carousel-caption h5 {
        font-size: 0.9rem;
    }
    
    .carousel-caption p {
        font-size: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    /* Footer: stack columns */
    footer .col-md-4, footer .col-md-2 {
        text-align: center;
        margin-bottom: 15px;
    }
    
    footer .d-flex.gap-3 {
        justify-content: center;
    }
    
    /* Cards: full width */
    .card, .card-custom, .image-card {
        margin-bottom: 15px;
    }
    
    /* Stat cards: 2 per row */
    .stat-card {
        text-align: center;
    }
    
    /* Modal: nearly full width */
    .modal-dialog {
        max-width: 95%;
        margin: 10px;
    }
    
    /* Tables: smaller font */
    .table {
        font-size: 0.75rem;
    }
    
    .table th, .table td {
        padding: 6px 8px;
    }
    
    /* Back to top: smaller */
    #backToTop {
        width: 40px;
        height: 40px;
        font-size: 16px;
        bottom: 15px;
        right: 15px;
    }
    
    /* Hero section: minimal padding */
    .hero-section {
        min-height: 250px;
        padding: 25px 0;
    }
    
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .hero-section p {
        font-size: 0.9rem;
    }
    
    /* Announcement bar */
    .announcement-bar {
        font-size: 0.75rem;
    }
    
    /* Search bar: full width */
    .search-bar {
        width: 100%;
        margin: 10px 0;
    }
}

/* === Mobile (≤ 575px) === */
@media (max-width: 575.98px) {
    :root {
        --font-scale: 0.85;
    }
    
    /* Ensure navbar doesn't cover content */
    body {
        padding-top: 60px;
    }
    
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: white !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    .navbar-collapse {
        background: white;
        border-radius: 0 0 12px 12px;
        margin-top: 0;
        padding: 15px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    }
    
    .navbar-dark .navbar-collapse {
        background: #1a1a2e;
    }
    
    /* Navbar brand: smaller */
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-brand i {
        font-size: 1.2rem;
    }
    
    /* Carousel: minimal height */
    .carousel-item img {
        height: 180px;
    }
    
    .carousel-caption {
        padding: 8px 12px;
    }
    
    .carousel-caption h5 {
        font-size: 0.8rem;
    }
    
    .carousel-caption p {
        display: none;
    }
    
    .carousel-indicators {
        margin-bottom: 0.25rem;
    }
    
    .carousel-indicators [data-bs-target] {
        width: 8px;
        height: 8px;
    }
    
    /* Buttons: full width on mobile */
    .btn-mobile-full {
        width: 100%;
        display: block;
    }
    
    /* Hero: minimal */
    .hero-section {
        min-height: 200px;
        padding: 20px 0;
        margin-top: 0;
    }
    
    .hero-section h1 {
        font-size: 1.25rem;
        line-height: 1.3;
    }
    
    .hero-section p {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }
    
    .hero-section .btn {
        font-size: 0.85rem;
        padding: 8px 16px;
    }
    
    /* Announcement bar: ensure visible and not covering content */
    .announcement-bar {
        position: relative;
        margin-top: 0;
        font-size: 0.75rem;
        padding: 8px 0;
    }
    
    /* Ensure carousel section starts properly */
    .carousel-section {
        margin-top: 0;
        padding-top: 20px;
    }
    
    /* Stats: 1 per row */
    .stat-card {
        padding: 12px;
    }
    
    .stat-card h4 {
        font-size: 1.1rem;
    }
    
    /* Footer: minimal */
    footer {
        padding: 15px 0;
    }
    
    footer .footer-title {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    
    /* Tables: very compact */
    .table {
        font-size: 0.7rem;
    }
    
    .table th, .table td {
        padding: 4px 6px;
    }
    
    /* Modal: minimal padding */
    .modal-body {
        padding: 12px;
    }
    
    /* Forms: larger touch targets */
    .form-control, .form-select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Back to top: even smaller */
    #backToTop {
        width: 36px;
        height: 36px;
        font-size: 14px;
        bottom: 10px;
        right: 10px;
    }
    
    /* Section spacing: minimal */
    section, .py-5 {
        padding-top: 25px !important;
        padding-bottom: 25px !important;
    }
    
    .py-4 {
        padding-top: 15px !important;
        padding-bottom: 15px !important;
    }
    
    .py-3 {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
    
    /* Headings: smaller */
    h1, .h1 { font-size: 1.25rem; }
    h2, .h2, .section-title { font-size: 1.15rem; }
    h3, .h3 { font-size: 1.05rem; }
    h4, .h4 { font-size: 1rem; }
    h5, .h5 { font-size: 0.9rem; }
    
    /* Alerts: compact */
    .alert {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    
    .alert .btn-close {
        padding: 0.5rem;
    }
    
    /* Badges: smaller */
    .badge {
        font-size: 0.65rem;
        padding: 3px 6px;
    }
    
    /* Social icons: smaller */
    .social-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
    
    /* Contact cards: full width */
    .contact-card {
        padding: 15px;
    }
    
    /* Course cards: compact */
    .course-card, .category-card {
        margin-bottom: 12px;
    }
}

/* === Small Mobile (≤ 375px) === */
@media (max-width: 375px) {
    :root {
        --font-scale: 0.8;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .carousel-item img {
        height: 150px;
    }
    
    .hero-section h1 {
        font-size: 1.1rem;
    }
    
    .hero-section .btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    #backToTop {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

/* === Print Styles === */
@media print {
    .sidebar, .navbar, #backToTop, .announcement-bar, footer {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card, .card-custom {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* === Utility Classes === */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.w-auto { width: auto; }
.min-w-auto { min-width: auto; }

/* === Responsive Flex Utilities === */
@media (max-width: 767.98px) {
    .d-md-flex-wrap {
        flex-wrap: wrap;
    }
    
    .gap-md-0 {
        gap: 0 !important;
    }
    
    .flex-md-column {
        flex-direction: column !important;
    }
    
    .text-md-center {
        text-align: center !important;
    }
}
