/* =====================================================
   Berjuara - Comprehensive Responsive Styles
   ===================================================== */

/* =====================================================
   Mobile First Base Adjustments
   ===================================================== */

/* Touch-friendly tap targets */
@media (pointer: coarse) {
    .btn, button, a, input, select, textarea {
        min-height: 44px;
    }

    /* Slider dots should keep their small size */
    .slider-dot {
        min-height: auto;
    }

    .nav-item, .display-option {
        min-height: 48px;
    }
}

/* =====================================================
   Large Desktop (1400px+)
   ===================================================== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* =====================================================
   Desktop (1200px - 1399px)
   ===================================================== */
@media (max-width: 1399px) {
    .container {
        max-width: 1140px;
    }
}

/* =====================================================
   Laptop / Small Desktop (992px - 1199px)
   ===================================================== */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }

    /* Dashboard adjustments */
    .dashboard-page .sidebar {
        width: 220px;
    }

    .dashboard-page .main-content {
        margin-left: 220px;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Menu cards */
    .menu-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =====================================================
   Tablet Landscape (768px - 991px)
   ===================================================== */
@media (max-width: 991px) {
    :root {
        --header-height: 60px;
    }

    .container {
        max-width: 720px;
    }

    /* Typography */
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.5rem; }

    /* Navigation */
    .nav-links {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        flex-direction: column;
        padding: 0.5rem 0;
        z-index: 999;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links .nav-link {
        padding: 0.875rem 1.5rem;
        border-bottom: 1px solid var(--border-light, #f1f5f9);
    }

    .nav-links .nav-link:last-child {
        border-bottom: none;
    }

    .mobile-menu-btn {
        display: flex !important;
        font-size: 1.25rem;
    }

    /* Dashboard Layout */
    .dashboard-page .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s ease;
    }

    .dashboard-page .sidebar.open {
        left: 0;
    }

    .dashboard-page .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Menu cards */
    .menu-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Features grid */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Category grid */
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tryout grid */
    .tryout-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Video grid */
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Bundle grid */
    .bundle-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Materi grid */
    .materi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Canvas Page */
    .canvas-page {
        flex-direction: column;
    }

    .canvas-sidebar {
        width: 100%;
        max-width: none;
        height: auto;
        max-height: 40vh;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .canvas-main {
        height: 60vh;
    }

    .canvas-toolbar {
        flex-wrap: wrap;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .toolbar-group {
        flex-wrap: wrap;
    }
}

/* =====================================================
   Tablet Portrait (576px - 767px)
   ===================================================== */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
        padding: 0 1rem;
    }

    /* Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }

    /* Section padding */
    .section {
        padding: 2.5rem 0;
    }

    /* Hero */
    .hero-title {
        font-size: 2rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    .hero-stats {
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .hero-stat {
        flex: 0 0 calc(50% - 0.75rem);
        text-align: center;
    }

    /* Grids to single column */
    .features-grid,
    .category-grid,
    .pricing-grid,
    .tryout-grid,
    .video-grid,
    .bundle-grid,
    .materi-grid,
    .mentor-grid {
        grid-template-columns: 1fr;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Menu cards */
    .menu-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .menu-card {
        padding: 1rem;
    }

    .menu-card .menu-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .menu-card h4 {
        font-size: 0.875rem;
    }

    /* Filter tabs */
    .filter-tabs,
    .bimbel-tabs,
    .category-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .filter-tab,
    .bimbel-tab,
    .category-tab {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    /* Cards */
    .card {
        padding: 1rem;
    }

    .tryout-card,
    .video-card,
    .bundle-card {
        margin-bottom: 0;
    }

    /* Welcome Banner */
    .welcome-banner {
        padding: 1.25rem;
    }

    .welcome-banner h2 {
        font-size: 1.25rem;
    }

    /* Canvas Page */
    .canvas-page {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .canvas-sidebar {
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
    }

    .canvas-sidebar-header {
        padding: 0.75rem;
    }

    .canvas-sidebar-content {
        padding: 0.75rem;
    }

    .canvas-sidebar-footer {
        padding: 0.75rem;
    }

    .canvas-main {
        height: 50vh;
        min-height: 300px;
    }

    .canvas-toolbar {
        padding: 0.5rem;
        gap: 0.25rem;
        overflow-x: auto;
    }

    .toolbar-btn {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .toolbar-divider {
        margin: 0 0.25rem;
    }

    .color-btn {
        width: 24px;
        height: 24px;
    }

    .stroke-width-group {
        display: none;
    }

    /* Question display */
    .question-display {
        padding: 0.75rem;
    }

    .question-display-text {
        font-size: 0.9375rem;
    }

    .display-option {
        padding: 0.625rem;
    }

    /* Question navigator */
    .question-navigator {
        gap: 0.375rem;
    }

    .nav-item {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    /* Modals */
    .modal {
        width: calc(100% - 2rem);
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .footer-social {
        justify-content: center;
    }

    /* Pricing */
    .pricing-card {
        padding: 1.5rem;
    }

    .pricing-header .price {
        font-size: 2rem;
    }

    /* Schedule */
    .schedule-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .schedule-date {
        display: none;
    }

    .schedule-action {
        width: 100%;
    }

    .schedule-action .btn {
        width: 100%;
    }

    /* Demo banner */
    .demo-banner {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .demo-banner-actions {
        width: 100%;
        justify-content: center;
    }
}

/* =====================================================
   Mobile Large (480px - 575px)
   ===================================================== */
@media (max-width: 575px) {
    .container {
        padding: 0 0.75rem;
    }

    /* Typography */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    /* Buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .btn-lg {
        padding: 0.75rem 1.25rem;
    }

    /* Stats grid to 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.6875rem;
    }

    /* Menu cards */
    .menu-cards {
        gap: 0.5rem;
    }

    .menu-card {
        padding: 0.75rem;
    }

    .menu-card .menu-icon {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .menu-card h4 {
        font-size: 0.8125rem;
    }

    .menu-card p {
        font-size: 0.6875rem;
    }

    /* Page hero */
    .page-hero,
    .belajar-hero,
    .bimbel-hero {
        padding: 1.5rem 0;
    }

    .page-hero h1 {
        font-size: 1.25rem;
    }

    .page-hero p {
        font-size: 0.875rem;
    }

    /* Canvas adjustments */
    .canvas-sidebar {
        max-height: 45vh;
    }

    .canvas-main {
        height: 55vh;
        min-height: 250px;
    }

    .canvas-toolbar {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .canvas-toolbar::-webkit-scrollbar {
        display: none;
    }

    .toolbar-group {
        flex-shrink: 0;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .color-btn {
        width: 20px;
        height: 20px;
    }

    .zoom-controls {
        display: none;
    }

    /* Sidebar footer buttons */
    .canvas-sidebar-footer .btn {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    /* Question navigator compact */
    .question-navigator {
        gap: 0.25rem;
    }

    .nav-item {
        width: 28px;
        height: 28px;
        font-size: 0.6875rem;
    }

    /* Tryout meta */
    .tryout-meta {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .tryout-meta-value {
        font-size: 1.25rem;
    }

    .tryout-meta-label {
        font-size: 0.6875rem;
    }

    /* Video card */
    .video-thumbnail {
        aspect-ratio: 16/9;
    }

    .video-duration {
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
    }

    /* Bundle card */
    .bundle-card {
        padding: 1rem;
    }

    .bundle-price .price {
        font-size: 1.25rem;
    }
}

/* =====================================================
   Mobile Small (< 480px)
   ===================================================== */
@media (max-width: 479px) {
    body {
        font-size: 0.9375rem;
    }

    .container {
        padding: 0 0.5rem;
    }

    /* Typography */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    h4 { font-size: 1rem; }

    /* Header */
    .header {
        padding: 0 0.5rem;
    }

    .logo span {
        font-size: 1rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    /* Buttons - prevent overflow */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
        white-space: normal;
        text-align: center;
        word-break: break-word;
        max-width: 100%;
        overflow-wrap: break-word;
    }

    .btn i {
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    .btn-block {
        width: 100%;
    }

    .btn-lg {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    /* Stats */
    .stats-grid {
        gap: 0.375rem;
    }

    .stat-card {
        padding: 0.5rem;
    }

    .stat-value {
        font-size: 1.125rem;
    }

    .stat-label {
        font-size: 0.625rem;
    }

    /* Menu cards single column option */
    .menu-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Canvas */
    .canvas-sidebar {
        max-height: 40vh;
    }

    .canvas-sidebar-header {
        padding: 0.5rem;
    }

    .canvas-sidebar-header h3 {
        font-size: 0.9375rem;
    }

    .canvas-sidebar-content {
        padding: 0.5rem;
    }

    .question-display {
        padding: 0.5rem;
    }

    .question-display-text {
        font-size: 0.875rem;
        line-height: 1.5;
    }

    .display-option {
        padding: 0.5rem;
    }

    .display-option-letter {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .display-option-text {
        font-size: 0.8125rem;
    }

    /* Canvas toolbar mobile */
    .canvas-toolbar {
        padding: 0.375rem;
    }

    .toolbar-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .toolbar-divider {
        display: none;
    }

    .color-picker-group {
        gap: 0.25rem;
    }

    .color-btn {
        width: 18px;
        height: 18px;
    }

    .history-controls {
        gap: 0.25rem;
    }

    .history-btn {
        width: 28px;
        height: 28px;
    }

    /* Question navigator */
    .question-navigator {
        flex-wrap: wrap;
    }

    .nav-item {
        width: 26px;
        height: 26px;
        font-size: 0.625rem;
    }

    /* Modals */
    .modal {
        width: calc(100% - 1rem);
        margin: 0.5rem;
        border-radius: 0.75rem;
    }

    .modal-header {
        padding: 0.75rem;
    }

    .modal-title {
        font-size: 1rem;
    }

    .modal-body {
        padding: 0.75rem;
    }

    .modal-footer {
        padding: 0.75rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Filter tabs scroll */
    .filter-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .filter-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Cards compact */
    .tryout-card-header {
        padding: 0.75rem;
    }

    .tryout-card-body {
        padding: 0.75rem;
    }

    .tryout-card-footer {
        padding: 0.75rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .tryout-card-footer .btn {
        width: 100%;
    }

    /* Badge smaller */
    .badge {
        padding: 0.125rem 0.5rem;
        font-size: 0.625rem;
    }

    /* Toast */
    .toast {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        max-width: none;
    }
}

/* =====================================================
   Landscape Mobile Adjustments
   ===================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 5rem 0 2rem;
    }

    .canvas-page {
        flex-direction: row;
    }

    .canvas-sidebar {
        width: 300px;
        max-width: 40%;
        height: 100vh;
        max-height: none;
    }

    .canvas-main {
        height: 100vh;
        flex: 1;
    }
}

/* =====================================================
   Print Styles
   ===================================================== */
@media print {
    .header,
    .sidebar,
    .canvas-toolbar,
    .canvas-sidebar-footer,
    .btn,
    .mobile-menu-btn,
    .nav-actions {
        display: none !important;
    }

    .dashboard-page .main-content {
        margin-left: 0;
    }

    .canvas-page {
        display: block;
    }

    .canvas-sidebar {
        width: 100%;
        max-height: none;
    }
}

/* =====================================================
   Accessibility - Reduced Motion
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =====================================================
   High Contrast Mode
   ===================================================== */
@media (prefers-contrast: high) {
    :root {
        --border: #000;
        --text-muted: #333;
    }

    .btn-outline {
        border-width: 2px;
    }

    .card,
    .stat-card,
    .menu-card {
        border-width: 2px;
    }
}

/* =====================================================
   Dark Mode Support (if needed in future)
   ===================================================== */
@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode styles */
}
