/* ========================================
   GLOBAL RESPONSIVE STYLES FOR LMS
   Apply to all pages for consistent responsiveness
   ======================================== */

/* Base Responsive Settings */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container Adjustments */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* ========================================
   NAVIGATION RESPONSIVE
   ======================================== */

/* Mobile Menu Toggle */
.navbar-toggler {
    border: none;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.navbar-toggler:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

/* Mobile Navigation */
@media (max-width: 991px) {
    .navbar-collapse {
        background: rgba(0, 0, 0, 0.95);
        padding: 20px;
        border-radius: 10px;
        margin-top: 15px;
    }
    
    .navbar-nav {
        flex-direction: column;
    }
    
    .nav-item {
        margin: 5px 0;
    }
    
    .nav-link {
        padding: 12px 15px !important;
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: translateX(5px);
    }
    
    .dropdown-menu {
        position: static !important;
        transform: none !important;
        border: none;
        background: rgba(255, 255, 255, 0.05);
        margin-top: 10px;
        display: none !important; /* Hide by default */
    }
    
    .dropdown-menu.show {
        display: block !important; /* Show when has show class */
    }
}

/* ========================================
   CARDS & CONTENT RESPONSIVE
   ======================================== */

/* Card Adjustments */
@media (max-width: 768px) {
    .card {
        margin-bottom: 20px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .stats-card,
    .dashboard-card,
    .quick-actions {
        padding: 20px !important;
        margin-bottom: 20px;
    }
}

/* ========================================
   TABLES RESPONSIVE
   ======================================== */

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 8px;
        white-space: nowrap;
    }
    
    /* Stack table on very small screens */
    .table-stack {
        display: block;
    }
    
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }
    
    .table-stack tr {
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 10px;
    }
    
    .table-stack td {
        text-align: right;
        padding: 8px;
        position: relative;
        padding-left: 50%;
        border-bottom: 1px solid #dee2e6;
    }
    
    .table-stack td:last-child {
        border-bottom: none;
    }
    
    .table-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: bold;
        text-align: left;
    }
}

/* ========================================
   FORMS RESPONSIVE
   ======================================== */

@media (max-width: 576px) {
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 8px !important;
        margin: 5px 0;
    }
}

/* ========================================
   MODALS RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 15px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px;
    }
}

/* ========================================
   CHAT SYSTEM RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .chat-floating-window {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
    }
    
    .chat-floating-window.active {
        transform: none !important;
    }
    
    .telegram-chat-container {
        flex-direction: column;
    }
    
    .telegram-sidebar {
        width: 100% !important;
        height: 40vh !important;
        border-right: none !important;
        border-bottom: 2px solid #e9ecef;
    }
    
    .telegram-main {
        width: 100% !important;
        height: 60vh !important;
    }
    
    /* Hide sidebar when chat is active on mobile */
    .mobile-chat-active .telegram-sidebar {
        display: none;
    }
    
    .mobile-chat-active .telegram-main {
        height: 100vh !important;
    }
}

/* ========================================
   DASHBOARD HERO SECTIONS
   ======================================== */

@media (max-width: 768px) {
    .teacher-hero,
    .student-hero,
    .admin-hero {
        padding: 80px 0 40px !important;
    }
    
    .hero h1,
    .display-4 {
        font-size: 1.75rem !important;
    }
    
    .hero p,
    .lead {
        font-size: 1rem !important;
    }
    
    .hero .pulse-animation,
    .hero-icon {
        display: none;
    }
}

/* ========================================
   GRID SYSTEM ADJUSTMENTS
   ======================================== */

@media (max-width: 576px) {
    .row {
        margin-right: -10px;
        margin-left: -10px;
    }
    
    .row > * {
        padding-right: 10px;
        padding-left: 10px;
    }
    
    /* Force full width on mobile */
    .col-sm-6,
    .col-md-4,
    .col-md-6,
    .col-lg-3,
    .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ========================================
   BUTTONS & ACTIONS
   ======================================== */

@media (max-width: 576px) {
    .action-btn {
        padding: 15px !important;
        margin-bottom: 10px;
    }
    
    .action-icon {
        font-size: 1.5rem !important;
    }
    
    .btn-group-vertical {
        width: 100%;
    }
    
    .quick-action-buttons {
        display: flex;
        flex-direction: column;
    }
    
    .quick-action-buttons .btn {
        margin: 5px 0;
    }
}

/* ========================================
   TEXT & TYPOGRAPHY
   ======================================== */

@media (max-width: 768px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
    
    p {
        font-size: 0.95rem;
    }
    
    small {
        font-size: 0.8rem;
    }
}

/* ========================================
   SPACING UTILITIES
   ======================================== */

@media (max-width: 768px) {
    .py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
    .my-5 { margin-top: 2rem !important; margin-bottom: 2rem !important; }
    .my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
}

/* ========================================
   SIDEBAR RESPONSIVE
   ======================================== */

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

/* ========================================
   BOOK/MATERIAL CARDS
   ======================================== */

@media (max-width: 768px) {
    .book-card,
    .material-card {
        margin-bottom: 15px;
    }
    
    .book-card img,
    .material-card img {
        max-height: 200px;
        object-fit: cover;
    }
    
    .card-columns {
        column-count: 1 !important;
    }
}

@media (min-width: 576px) and (max-width: 768px) {
    .card-columns {
        column-count: 2 !important;
    }
}

/* ========================================
   LABORATORY/SPECIAL SECTIONS
   ======================================== */

@media (max-width: 768px) {
    .lab-equipment-grid,
    .topic-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .equipment-card,
    .topic-card {
        padding: 15px;
    }
}

/* ========================================
   SHOPPING CART RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .cart-item {
        flex-direction: column;
        text-align: center;
    }
    
    .cart-item img {
        margin-bottom: 15px;
    }
    
    .cart-summary {
        position: static;
        margin-top: 20px;
    }
}

/* ========================================
   PROFILE & SETTINGS
   ======================================== */

@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-avatar {
        margin-bottom: 20px;
    }
    
    .profile-stats {
        flex-direction: column;
    }
    
    .stat-item {
        margin: 10px 0;
    }
}

/* ========================================
   FOOTER RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    footer {
        text-align: center;
    }
    
    footer .row > div {
        margin-bottom: 30px;
    }
    
    .footer-links {
        flex-direction: column;
    }
    
    .footer-links a {
        margin: 5px 0;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* Text alignment responsive */
@media (max-width: 768px) {
    .text-md-left,
    .text-md-right,
    .text-md-center {
        text-align: center !important;
    }
}

/* ========================================
   TOUCH IMPROVEMENTS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        transform: none !important;
    }
}

/* ========================================
   LANDSCAPE ORIENTATION
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .chat-floating-window {
        height: 95vh !important;
    }
    
    .hero,
    .teacher-hero,
    .student-hero {
        padding: 40px 0 20px !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .navbar,
    .sidebar,
    .chat-floating-window,
    .chat-window-overlay,
    .btn,
    footer {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Hide floating time on mobile */
@media (max-width: 768px) {
    .floating-time-container {
        display: none;
    }
}
