/* ============================================
   COMPREHENSIVE RESPONSIVE FIX FOR STUDENT-SITE
   Production-Ready Responsive Design
   ============================================ */

/* ===== BASE RESET ===== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    overflow-x: hidden;
    width: 100%;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
}

img {
    max-width: 100%;
    height: auto;
}

.content-wrapper,
.main-content,
.container,
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

/* ===== MOBILE FIRST (320px - 767px) ===== */
@media (max-width: 767px) {
    /* Force hide desktop hero sections */
    .hero-section,
    .products-hero,
    .ebooks-hero,
    .contact-hero,
    .policy-hero {
        display: none !important;
    }
    
    /* Mobile header */
    .mobile-header {
        display: block !important;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        padding: 20px 15px;
        text-align: center;
        margin: 15px;
        border-radius: 15px;
        color: white;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }
    
    .mobile-header h1 {
        font-size: 22px;
        margin: 0 0 8px;
        font-weight: 700;
    }
    
    .mobile-header p {
        font-size: 14px;
        margin: 0 0 15px;
        opacity: 0.95;
    }
    
    /* Fixed taskbar */
    .taskbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
        z-index: 998 !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
        padding: 0 !important;
        display: block !important;
    }
    
    /* Taskbar top row */
    .taskbar-top {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 15px !important;
        height: 60px !important;
        position: relative !important;
        background: transparent !important;
    }
    
    /* Mobile hamburger menu - LEFT SIDE */
    .mobile-nav-toggle {
        background: rgba(255, 255, 255, 0.2) !important;
        border: 2px solid rgba(255, 255, 255, 0.5) !important;
        color: white !important;
        width: 40px !important;
        height: 40px !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 20px !important;
        cursor: pointer !important;
        z-index: 999 !important;
        position: relative !important;
        flex-shrink: 0 !important;
        transition: all 0.3s ease !important;
    }
    
    .mobile-nav-toggle:active {
        transform: scale(0.95) !important;
        background: rgba(255, 255, 255, 0.3) !important;
    }
    
    /* Logo - CENTERED */
    .taskbar .logo {
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 997 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .taskbar .logo img {
        width: 42px !important;
        height: 42px !important;
        border-radius: 50% !important;
        border: 2px solid white !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
        object-fit: cover !important;
    }
    
    /* Right side - cart and login */
    .right-taskbar {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        flex-shrink: 0 !important;
        position: relative !important;
        z-index: 997 !important;
    }
    
    /* Cart icon */
    .cart-icon {
        position: relative !important;
        color: white !important;
        font-size: 20px !important;
        text-decoration: none !important;
        padding: 8px !important;
        border-radius: 50% !important;
        transition: all 0.3s ease !important;
        background: rgba(255, 255, 255, 0.15) !important;
    }
    
    .cart-container {
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
    }
    
    .cart-count {
        position: absolute !important;
        top: -2px !important;
        right: -2px !important;
        background: var(--accent-color) !important;
        color: var(--text-color) !important;
        border-radius: 50% !important;
        width: 18px !important;
        height: 18px !important;
        font-size: 11px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 700 !important;
        border: 2px solid white !important;
    }
    
    /* Login button */
    .login-button {
        background: rgba(255, 255, 255, 0.2) !important;
        color: white !important;
        padding: 8px 14px !important;
        border-radius: 20px !important;
        text-decoration: none !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        transition: all 0.3s ease !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        white-space: nowrap !important;
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
    }
    
    .login-button:hover {
        background: rgba(255, 255, 255, 0.3) !important;
        color: white !important;
    }
    
    /* User profile dropdown on mobile */
    .user-profile-dropdown {
        position: relative !important;
        display: inline-block !important;
    }
    
    .user-avatar-container {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 6px 12px !important;
        background-color: rgba(255, 255, 255, 0.2) !important;
        border-radius: 20px !important;
        cursor: pointer !important;
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
        transition: all 0.3s ease !important;
    }
    
    .user-avatar-container:active {
        background-color: rgba(255, 255, 255, 0.3) !important;
    }
    
    .user-avatar-small {
        width: 26px !important;
        height: 26px !important;
        border-radius: 50% !important;
        border: 2px solid white !important;
        object-fit: cover !important;
    }
    
    .user-name-small {
        font-size: 13px !important;
        font-weight: 600 !important;
        max-width: 70px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        color: white !important;
    }
    
    .dropdown-arrow {
        font-size: 10px !important;
        color: white !important;
    }
    
    /* Search bar row - FULL WIDTH BELOW TOP ROW */
    .search-form {
        padding: 0 15px 12px !important;
        width: 100% !important;
        display: block !important;
        position: relative !important;
        background: transparent !important;
        border: none !important;
        margin: 0 !important;
    }
    
    .search-form-inner {
        display: flex !important;
        width: 100% !important;
        background: rgba(255, 255, 255, 0.9) !important;
        border-radius: 25px !important;
        overflow: hidden !important;
        border: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
    
    .search-input {
        flex: 1 !important;
        border: none !important;
        background: transparent !important;
        padding: 11px 15px !important;
        font-size: 15px !important;
        outline: none !important;
        color: var(--text-color) !important;
    }
    
    .search-input::placeholder {
        color: rgba(44, 62, 80, 0.5) !important;
    }
    
    .search-button {
        background: var(--primary-color) !important;
        border: none !important;
        color: white !important;
        padding: 11px 18px !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        flex-shrink: 0 !important;
    }
    
    .search-button:active {
        background: var(--secondary-color) !important;
    }
    
    /* Mobile sidebar - SLIDE IN FROM LEFT */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 280px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        background: white !important;
        z-index: 1000 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        box-shadow: 2px 0 15px rgba(0,0,0,0.3) !important;
        display: block !important;
    }
    
    .sidebar.open,
    .sidebar.active,
    .sidebar.show {
        left: 0 !important;
    }
    
    /* Sidebar overlay */
    .sidebar-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0,0,0,0.5) !important;
        z-index: 999 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.3s ease !important;
        pointer-events: none !important;
    }
    
    .sidebar-overlay.active {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    
    /* Lock body when sidebar open */
    body.sidebar-open {
        overflow: hidden !important;
        touch-action: none !important;
    }
    
    /* Sidebar header */
    .sidebar-header {
        padding: 20px !important;
        text-align: center !important;
        border-bottom: 1px solid rgba(0,0,0,0.1) !important;
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    }
    
    .sidebar-header .logo {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 12px !important;
        color: white !important;
        text-decoration: none !important;
    }
    
    .sidebar-header .logo img {
        width: 45px !important;
        height: 45px !important;
        border-radius: 50% !important;
        border: 2px solid white !important;
    }
    
    .sidebar-header .logo span {
        font-size: 18px !important;
        font-weight: 700 !important;
    }
    
    /* Sidebar navigation */
    .sidebar ul {
        list-style: none !important;
        padding: 15px !important;
        margin: 0 !important;
    }
    
    .sidebar ul li {
        margin-bottom: 8px !important;
        border-bottom: none !important;
    }
    
    .sidebar ul li a {
        display: flex !important;
        align-items: center !important;
        padding: 14px 16px !important;
        color: var(--text-color) !important;
        text-decoration: none !important;
        transition: all 0.3s ease !important;
        font-size: 16px !important;
        font-weight: 500 !important;
        border-radius: 12px !important;
        background: white !important;
    }
    
    .sidebar ul li a:hover,
    .sidebar ul li a:active,
    .sidebar ul li a.active {
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
        color: white !important;
        transform: translateX(5px) !important;
    }
    
    .sidebar ul li a i {
        width: 24px !important;
        margin-right: 14px !important;
        font-size: 18px !important;
        text-align: center !important;
    }
    
    .sidebar-separator {
        height: 1px !important;
        background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent) !important;
        margin: 12px 0 !important;
    }
    
    /* Main content - PROPER SPACING */
    .main-content {
        margin-top: 125px !important;
        margin-left: 0 !important;
        padding: 15px !important;
        width: 100% !important;
        min-height: calc(100vh - 125px) !important;
        position: relative !important;
    }
    
    .container {
        padding: 0 15px;
        width: 100%;
    }
    
    .col-12,
    .col-md-6,
    .col-lg-3,
    .col-lg-4 {
        width: 100% !important;
        padding: 0 10px !important;
        margin-bottom: 20px !important;
    }
    
    /* Row fixes */
    .row {
        display: flex !important;
        flex-wrap: wrap !important;
        margin: 0 -10px !important;
    }
    
    /* Container fixes */
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* Product cards on mobile */
    .product-card {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px !important;
        border-radius: 15px !important;
        overflow: hidden !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
    }
    
    .product-image-container {
        width: 100% !important;
        height: 200px !important;
        overflow: hidden !important;
        position: relative !important;
    }
    
    .product-image-container img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        background: #f8f9fa !important;
    }
    
    /* Product info */
    .product-info {
        padding: 15px !important;
        background: white !important;
    }
    
    .product-title {
        font-size: 17px !important;
        font-weight: 600 !important;
        margin-bottom: 10px !important;
        color: var(--text-color) !important;
    }
    
    .product-price {
        font-size: 18px !important;
        font-weight: 700 !important;
        color: var(--primary-color) !important;
        margin-bottom: 12px !important;
    }
    
    .product-description {
        font-size: 14px !important;
        line-height: 1.5 !important;
        color: #666 !important;
        margin-bottom: 15px !important;
    }
    
    /* Button fixes */
    .btn,
    .product-actions .btn {
        width: 100% !important;
        padding: 12px 20px !important;
        border-radius: 25px !important;
        font-size: 15px !important;
        font-weight: 600 !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        margin-bottom: 8px !important;
    }
    
    .btn-primary {
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
        color: white !important;
    }
    
    .btn-outline-primary {
        background: white !important;
        border: 2px solid var(--primary-color) !important;
        color: var(--primary-color) !important;
    }
    
    /* Section spacing */
    .section-title {
        font-size: 24px !important;
        font-weight: 700 !important;
        text-align: center !important;
        margin: 30px 0 10px !important;
        color: var(--primary-color) !important;
    }
    
    .section-subtitle {
        font-size: 15px !important;
        text-align: center !important;
        margin-bottom: 25px !important;
        color: #666 !important;
        line-height: 1.6 !important;
    }
    
    /* Feature cards */
    .feature-card {
        background: white !important;
        padding: 20px !important;
        border-radius: 15px !important;
        text-align: center !important;
        margin-bottom: 20px !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.08) !important;
    }
    
    .feature-icon {
        width: 60px !important;
        height: 60px !important;
        margin: 0 auto 15px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 24px !important;
    }
    
    /* Footer fixes */
    .footer-section {
        margin-left: 0 !important;
        margin-top: 40px !important;
        width: 100% !important;
        padding: 30px 0 !important;
    }
    
    .footer-content {
        padding: 0 15px !important;
    }
    
    .footer-heading {
        font-size: 18px !important;
        margin-bottom: 15px !important;
        text-align: center !important;
    }
    
    .footer-links {
        text-align: center !important;
        list-style: none !important;
        padding: 0 !important;
    }
    
    .social-icons {
        display: flex !important;
        justify-content: center !important;
        gap: 12px !important;
        margin-top: 20px !important;
    }
    
    /* Card grid */
    .card-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        margin-top: 20px !important;
    }
    
    /* Text alignment */
    .text-center {
        text-align: center !important;
    }
    
    .text-left {
        text-align: left !important;
    }
    
    .text-right {
        text-align: right !important;
    }
    
    /* Spacing utilities */
    .mt-1 { margin-top: 0.25rem !important; }
    .mt-2 { margin-top: 0.5rem !important; }
    .mt-3 { margin-top: 1rem !important; }
    .mt-4 { margin-top: 1.5rem !important; }
    .mt-5 { margin-top: 3rem !important; }
    
    .mb-1 { margin-bottom: 0.25rem !important; }
    .mb-2 { margin-bottom: 0.5rem !important; }
    .mb-3 { margin-bottom: 1rem !important; }
    .mb-4 { margin-bottom: 1.5rem !important; }
    .mb-5 { margin-bottom: 3rem !important; }
    
    .pt-1 { padding-top: 0.25rem !important; }
    .pt-2 { padding-top: 0.5rem !important; }
    .pt-3 { padding-top: 1rem !important; }
    .pt-4 { padding-top: 1.5rem !important; }
    .pt-5 { padding-top: 3rem !important; }
    
    .pb-1 { padding-bottom: 0.25rem !important; }
    .pb-2 { padding-bottom: 0.5rem !important; }
    .pb-3 { padding-bottom: 1rem !important; }
    .pb-4 { padding-bottom: 1.5rem !important; }
    .pb-5 { padding-bottom: 3rem !important; }
}

/* ===== TABLET (768px - 1024px) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
    .mobile-header {
        display: none !important;
    }
    
    .taskbar {
        height: 70px;
        padding: 0 20px;
    }
    
    .sidebar {
        top: 70px;
        width: 220px;
        height: calc(100vh - 70px);
    }
    
    .main-content {
        margin-left: 220px;
        margin-top: 70px;
        padding: 25px 30px;
        width: calc(100% - 220px);
    }
    
    .col-md-6 {
        width: 50%;
    }
    
    .col-lg-3 {
        width: 50%;
    }
    
    .footer-section {
        margin-left: 220px;
        width: calc(100% - 220px);
    }
}

/* ===== DESKTOP (1025px+) ===== */
@media (min-width: 1025px) {
    .mobile-header {
        display: none !important;
    }
    
    .taskbar {
        height: 80px;
        padding: 0 30px;
    }
    
    .sidebar {
        top: 80px;
        width: 250px;
        height: calc(100vh - 80px);
    }
    
    .main-content {
        margin-left: 250px;
        margin-top: 80px;
        padding: 30px 50px;
        width: calc(100% - 250px);
    }
    
    .col-lg-3 {
        width: 25%;
    }
    
    .col-lg-4 {
        width: 33.333%;
    }
    
    .footer-section {
        margin-left: 250px;
        width: calc(100% - 250px);
    }
}

/* ===== ADDITIONAL FIXES FOR ALL DEVICES ===== */

/* Product Card Fixes */
.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 100%;
}

.product-image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.product-image-container img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Form Fixes */
input,
select,
textarea,
button {
    max-width: 100%;
    font-size: 16px;
}

/* Table Responsiveness */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    max-width: 100%;
}

/* Image Responsiveness */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Video Responsiveness */
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Prevent Text Overflow */
h1, h2, h3, h4, h5, h6,
p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Cart Page Fixes */
.cart-item {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

@media (max-width: 767px) {
    .cart-item {
        flex-direction: column;
    }
    
    .cart-item-image {
        width: 100%;
        max-width: 100%;
    }
}

/* Checkout Page Fixes */
.checkout-form {
    width: 100%;
    max-width: 100%;
}

/* Profile Page Fixes */
.profile-container {
    width: 100%;
    max-width: 100%;
    padding: 15px;
}

/* Settings Page Fixes */
.settings-container {
    width: 100%;
    max-width: 100%;
    padding: 15px;
}

/* eBooks Page Fixes */
.ebook-card {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
}

/* Classes Page Fixes */
.class-card {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
}

/* Contact Page Fixes */
.contact-form {
    width: 100%;
    max-width: 100%;
}

/* Help Page Fixes */
.help-section {
    width: 100%;
    max-width: 100%;
}

/* Orders Page Fixes */
.order-card {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
}

/* Utility Classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .taskbar,
    .mobile-nav-toggle,
    .footer-section {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
}
