/* ============================================
   QuizKaro - Responsive Stylesheet
   Mobile, Tablet, Desktop के लिए
   ============================================ */

/* ============================================
   EXTRA LARGE DEVICES (Large Desktops, 1400px+)
   ============================================ */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ============================================
   LARGE DEVICES (Desktops, 1200px - 1399px)
   ============================================ */
@media (max-width: 1399.98px) {
    .container {
        max-width: 1140px;
    }
}

/* ============================================
   MEDIUM DEVICES (Tablets/Laptops, 992px - 1199px)
   ============================================ */
@media (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }
    
    /* Grid Changes */
    .col-lg-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-lg-2 { flex: 0 0 16.666%; max-width: 16.666%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-8 { flex: 0 0 66.666%; max-width: 66.666%; }
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
    
    /* Font Sizes */
    .timer {
        font-size: 2.5rem;
    }
    
    .question-text {
        font-size: var(--font-base);
    }
}

/* ============================================
   SMALL DEVICES (Tablets, 768px - 991px)
   ============================================ */
@media (max-width: 991.98px) {
    .container {
        max-width: 720px;
    }
    
    /* Grid Changes */
    .col-md-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    
    /* Hide/Show Elements */
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    /* Mobile Menu Button */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: 1.5rem;
        color: var(--text-primary);
    }
    
    /* Nav Menu - Mobile */
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--bg-primary);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        box-shadow: var(--shadow-xl);
        transition: left var(--transition);
        z-index: 9999;
        overflow-y: auto;
        gap: 0;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-menu .nav-link {
        padding: 0.75rem 1rem;
        border-radius: var(--radius-sm);
    }
    
    /* Overlay */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }
    
    .menu-overlay.active {
        display: block;
    }
    
    /* Close Button */
    .menu-close {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 1rem;
    }
    
    .menu-close button {
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-primary);
    }
    
    /* Dashboard Grid */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Test Page */
    .test-layout {
        flex-direction: column;
    }
    
    .test-sidebar {
        width: 100%;
        order: -1;
    }
    
    /* Result Page */
    .result-details {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Leaderboard */
    .leaderboard-item {
        padding: 0.75rem 1rem;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Chat Widget */
    .chat-widget {
        bottom: 1rem;
        right: 1rem;
    }
}

/* ============================================
   EXTRA SMALL DEVICES (Phones, 576px - 767px)
   ============================================ */
@media (max-width: 767.98px) {
    .container {
        max-width: 540px;
    }
    
    /* Grid Changes */
    .col-sm-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-sm-2 { flex: 0 0 16.666%; max-width: 16.666%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
    
    /* Typography */
    body {
        font-size: 14px;
    }
    
    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    
    /* Navbar */
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .navbar-brand i {
        font-size: 1.5rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn-xl {
        padding: 1rem 2rem;
        font-size: 1.125rem;
    }
    
    /* Cards */
    .card {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Forms */
    .form-control {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Tables */
    table {
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 0.625rem 0.75rem;
    }
    
    /* Timer */
    .timer {
        font-size: 2rem;
    }
    
    .timer-container {
        padding: 0.75rem 1rem;
    }
    
    /* Question */
    .question-card {
        padding: 1.25rem;
    }
    
    .question-text {
        font-size: 1rem;
    }
    
    .option-item {
        padding: 0.75rem 1rem;
        padding-left: 3rem;
        font-size: 0.875rem;
    }
    
    .option-radio {
        left: 1rem;
    }
    
    /* Result */
    .result-card {
        padding: 1.5rem;
    }
    
    .result-score {
        font-size: 3rem;
    }
    
    .result-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .result-stat {
        padding: 1rem;
    }
    
    /* Leaderboard */
    .leaderboard-item {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
    }
    
    .rank {
        font-size: 1.25rem;
        width: 2rem;
    }
    
    .leaderboard-avatar {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.875rem;
    }
    
    .leaderboard-name {
        font-size: 0.875rem;
    }
    
    .leaderboard-stats {
        font-size: 0.75rem;
    }
    
    /* Wallet */
    .wallet-balance {
        padding: 1.5rem;
    }
    
    .wallet-amount {
        font-size: 2.5rem;
    }
    
    .wallet-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .footer {
        padding: 2rem 0 1rem;
    }
    
    /* Alerts */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Pagination */
    .page-link {
        min-width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
    }
    
    /* Ads */
    .ad-container {
        min-height: 60px;
        padding: 0.5rem;
    }
    
    /* Hide elements on mobile */
    .hide-on-mobile {
        display: none !important;
    }
}

/* ============================================
   VERY SMALL DEVICES (Small Phones, 575px and below)
   ============================================ */
@media (max-width: 575.98px) {
    .container {
        max-width: 100%;
        padding: 0 0.75rem;
    }
    
    /* Grid - Everything full width */
    .col-xs-12 { flex: 0 0 100%; max-width: 100%; }
    
    /* Typography */
    h1, .h1 { font-size: 1.5rem; }
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.125rem; }
    
    /* Buttons - Full width on mobile */
    .btn-mobile-block {
        display: flex;
        width: 100%;
    }
    
    /* Test Navigation */
    .test-navigation {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .test-navigation .btn {
        width: 100%;
    }
    
    /* Question Palette */
    .question-palette {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.25rem;
    }
    
    .question-palette-item {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
    
    /* Result */
    .result-details {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-score {
        font-size: 2.5rem;
    }
    
    .result-icon {
        font-size: 3.5rem;
    }
    
    /* Wallet Balance Card */
    .wallet-amount {
        font-size: 2rem;
    }
    
    /* Leaderboard */
    .rank {
        font-size: 1rem;
        width: 1.5rem;
    }
    
    .rank.top-1,
    .rank.top-2,
    .rank.top-3 {
        font-size: 1.25rem;
    }
    
    /* Modal/Dialog */
    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    /* Timer in small screen */
    .timer {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }
}

/* ============================================
   LANDSCAPE MODE (Phone landscape)
   ============================================ */
@media (max-width: 991.98px) and (orientation: landscape) {
    .nav-menu {
        width: 50%;
    }
    
    .test-layout {
        flex-direction: row;
    }
    
    .test-sidebar {
        width: 200px;
    }
}

/* ============================================
   HIGH RESOLUTION SCREENS (Retina, 2x)
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* For high-res images if needed */
}

/* ============================================
   DARK MODE PREFERENCE (System)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Auto dark mode if user hasn't toggled manually */
    body:not([data-theme]) {
        --primary-color: #818CF8;
        --bg-primary: #111827;
        --bg-secondary: #1F2937;
        --text-primary: #F9FAFB;
        --text-secondary: #D1D5DB;
        --border-color: #374151;
    }
}

/* ============================================
   REDUCED MOTION (Accessibility)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    @page {
        margin: 2cm;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
    }
    
    .navbar,
    .footer,
    .btn,
    .chat-widget,
    .ad-container,
    .dark-mode-toggle,
    .mobile-menu-toggle,
    .menu-overlay {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
    
    table {
        border-collapse: collapse;
    }
    
    th, td {
        border: 1px solid #ccc;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    /* Certificate specific */
    .certificate {
        border: 5px solid #000 !important;
        padding: 50px !important;
        page-break-after: always;
    }
}
/* ============================================
   MOBILE READABILITY FIX
   ============================================ */
@media (max-width: 768px) {
   @media (max-width: 768px) {
    /* Dark text everywhere - BOLDER */
    .main-content, .container, .card, .stat-box, .test-card,
    #features, #pricing, #banks {
        color: #111827 !important;
    }
    
    /* Headings - BOLDER */
    h1, h2, h3, h4, h5, h6, .stat-value, .score, strong,
    .card h3, .card p, .card li, .card-body, .card-body *,
    #features h2, #features h3, #features p,
    #pricing h2, #pricing h3, #pricing li, #pricing div {
        color: #111827 !important;
        font-weight: 700 !important;
    }
    
    /* Stat cards */
    .stat-box {
        background: white !important;
        border: 1px solid #E5E7EB !important;
    }
    
    .stat-box .stat-value {
        color: #4F46E5 !important;
        font-weight: 800 !important;
    }
    
    .stat-box .stat-label {
        color: #374151 !important;
        font-weight: 600 !important;
    }
    
    /* Tables */
    table, th, td {
        color: #1F2937 !important;
    }
    
    /* Wallet, Price, Badge text */
    .badge, .price, .wallet-amount {
        font-weight: 700 !important;
    }
    
    /* Buttons */
    .btn {
        font-weight: 700 !important;
    }
    
    /* Links */
    a {
        color: #4F46E5 !important;
        font-weight: 600 !important;
    }
    
    /* Timer */
    .timer-box {
        color: white !important;
        font-weight: 800 !important;
    }
    
    /* Result page */
    .result-header, .result-header * {
        color: white !important;
    }
    
    .answer-card {
        color: #1F2937 !important;
    }
    
    /* Dashboard */
    .welcome-banner * {
        color: white !important;
    }
}
/* SIDEBAR FIX */
@media (min-width: 769px) {
    .sidebar { width: 260px !important; }
    .sidebar a span { display: inline !important; }
    .main-content { margin-left: 260px !important; }
    .mobile-menu-toggle { display: none !important; }
}

@media (max-width: 768px) {
    .sidebar { 
        width: 260px !important;
        position: fixed;
        left: -260px;
        transition: 0.3s;
        z-index: 999;
    }
    .sidebar.open { left: 0; }
    .sidebar a span { display: inline !important; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 10px; left: 10px;
        z-index: 1000;
        background: #4F46E5;
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 8px;
        font-size: 1.5rem;
        cursor: pointer;
    }
}