/* Mobile Responsive CSS for KICDA Website */
/* Created: 2025-01-10 */

/* ===================================
   Base Mobile Styles 
   =================================== */

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Ensure all containers are responsive */
.container {
    width: 100%;
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ===================================
   Mobile Navigation 
   =================================== */

@media (max-width: 768px) {
    /* Mobile Navigation Toggle */
    .mobile-menu-button {
        display: block !important;
        position: fixed;
        top: 1rem;
        right: 1rem;
        z-index: 9999;
        background: white;
        border: 2px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.5rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .mobile-menu-button svg {
        width: 24px;
        height: 24px;
        color: #374151;
    }

    /* Mobile Menu Overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-menu-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Mobile Menu Panel */
    .mobile-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100%;
        background: white;
        z-index: 9999;
        transition: right 0.3s ease;
        overflow-y: auto;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    }

    .mobile-menu.active {
        right: 0;
    }

    .mobile-menu-header {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-menu-close {
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: #6b7280;
    }

    /* Mobile Menu Items */
    .mobile-menu-items {
        padding: 1rem;
    }

    .mobile-menu-item {
        display: block;
        padding: 0.75rem 1rem;
        color: #374151;
        text-decoration: none;
        border-radius: 8px;
        transition: background 0.2s;
        margin-bottom: 0.5rem;
    }

    .mobile-menu-item:hover {
        background: #f3f4f6;
    }

    .mobile-menu-item.active {
        background: #3b82f6;
        color: white;
    }

    /* Hide desktop navigation */
    nav.hidden.md\\:block {
        display: none !important;
    }

    /* Top bar adjustments */
    .bg-gradient-to-r {
        font-size: 0.75rem;
    }

    /* Header adjustments */
    header {
        padding: 0.5rem 0;
    }

    header .container {
        flex-direction: column;
        align-items: center;
    }

    header img {
        height: 40px;
        margin-bottom: 0.5rem;
    }
}

/* ===================================
   Hero Section Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Hero content */
    .hero-section h1 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }

    .hero-section h2 {
        font-size: 1.25rem !important;
        margin-bottom: 1rem !important;
    }

    .hero-section p {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }

    /* Hero buttons */
    .hero-section .flex.gap-4 {
        flex-direction: column;
        width: 100%;
    }

    .hero-section button,
    .hero-section a[role="button"] {
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Hero stats */
    .grid.grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Video container */
    .aspect-w-16.aspect-h-9 {
        margin-top: 2rem;
    }
}

/* ===================================
   Cards and Grid Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Grid adjustments */
    .grid.md\\:grid-cols-2,
    .grid.md\\:grid-cols-3,
    .grid.md\\:grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Card adjustments */
    .bg-white.rounded-xl {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }

    /* Feature cards */
    .feature-card {
        padding: 1.5rem !important;
    }

    .feature-card h3 {
        font-size: 1.125rem !important;
    }

    .feature-card p {
        font-size: 0.875rem !important;
    }

    /* Course cards */
    .course-card {
        margin-bottom: 1rem;
    }

    .course-card img {
        height: 180px !important;
    }

    .course-card h3 {
        font-size: 1rem !important;
    }

    .course-card .text-sm {
        font-size: 0.75rem !important;
    }
}

/* ===================================
   Forms Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Form containers */
    .max-w-md,
    .max-w-lg,
    .max-w-xl {
        max-width: 100% !important;
        padding: 1rem !important;
    }

    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
    }

    /* Form labels */
    label {
        font-size: 0.875rem !important;
    }

    /* Form buttons */
    form button[type="submit"] {
        width: 100% !important;
        padding: 0.75rem !important;
        font-size: 1rem !important;
    }

    /* Login/Register forms */
    .auth-form {
        padding: 1.5rem !important;
        margin: 1rem !important;
    }
}

/* ===================================
   Tables Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Responsive table wrapper */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    /* Table adjustments */
    table {
        min-width: 600px;
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }

    /* Alternative: Card-based table for mobile */
    .mobile-table-card {
        display: block;
        background: white;
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    .mobile-table-card .table-row {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid #e5e7eb;
    }

    .mobile-table-card .table-row:last-child {
        border-bottom: none;
    }

    .mobile-table-card .table-label {
        font-weight: 600;
        color: #6b7280;
        font-size: 0.875rem;
    }

    .mobile-table-card .table-value {
        color: #111827;
        font-size: 0.875rem;
        text-align: right;
    }
}

/* ===================================
   Video Player Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Video container */
    .video-container {
        position: relative;
        width: 100%;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
        height: 0;
    }

    .video-container video,
    .video-container iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    /* Video controls */
    .video-controls {
        padding: 0.5rem !important;
    }

    .video-controls button {
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }

    /* Video player overlay */
    .video-overlay {
        font-size: 0.75rem !important;
    }

    /* DRM watermark */
    .drm-watermark {
        font-size: 0.625rem !important;
        opacity: 0.3 !important;
    }
}

/* ===================================
   Modal and Popups Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Modal adjustments */
    .modal {
        padding: 1rem !important;
    }

    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 1rem auto !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 1rem !important;
        font-size: 1.125rem !important;
    }

    .modal-body {
        padding: 1rem !important;
    }

    .modal-footer {
        padding: 1rem !important;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }
}

/* ===================================
   Footer Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Footer layout */
    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Footer content */
    footer h3 {
        font-size: 1.125rem !important;
        margin-bottom: 1rem !important;
    }

    footer p,
    footer a {
        font-size: 0.875rem !important;
    }

    /* Footer bottom */
    .border-t.border-gray-800 {
        flex-direction: column;
        text-align: center;
    }

    .border-t.border-gray-800 > div {
        margin-bottom: 1rem;
    }
}

/* ===================================
   Touch and Gesture Support 
   =================================== */

/* Touch-friendly buttons */
@media (max-width: 768px) {
    button,
    a[role="button"],
    .clickable {
        min-height: 44px; /* iOS recommendation */
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Increase tap target size */
    .small-button {
        padding: 0.75rem 1rem !important;
    }

    /* Swiper support */
    .swiper-container {
        padding: 0 !important;
    }

    .swiper-button-prev,
    .swiper-button-next {
        display: none !important;
    }

    .swiper-pagination {
        bottom: 10px !important;
    }
}

/* ===================================
   Performance Optimizations 
   =================================== */

@media (max-width: 768px) {
    /* Reduce animations on mobile */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Optimize images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Lazy loading placeholder */
    .lazy-load {
        background: #f3f4f6;
        min-height: 200px;
    }
}

/* ===================================
   Utility Classes 
   =================================== */

@media (max-width: 768px) {
    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }

    /* Text sizing */
    .mobile-text-sm {
        font-size: 0.875rem !important;
    }

    .mobile-text-xs {
        font-size: 0.75rem !important;
    }

    /* Spacing adjustments */
    .mobile-p-2 {
        padding: 0.5rem !important;
    }

    .mobile-m-2 {
        margin: 0.5rem !important;
    }

    /* Full width on mobile */
    .mobile-full-width {
        width: 100% !important;
    }
}

/* ===================================
   Admin Panel Mobile 
   =================================== */

@media (max-width: 768px) {
    /* Admin sidebar */
    .admin-sidebar {
        position: fixed;
        left: -100%;
        width: 70%;
        height: 100%;
        transition: left 0.3s ease;
        z-index: 9999;
    }

    .admin-sidebar.active {
        left: 0;
    }

    /* Admin content */
    .admin-content {
        margin-left: 0 !important;
        padding: 1rem !important;
    }

    /* Admin cards */
    .admin-stat-card {
        margin-bottom: 1rem;
    }

    /* Admin table */
    .admin-table {
        font-size: 0.75rem !important;
    }
}

/* ===================================
   Print Styles 
   =================================== */

@media print {
    /* Hide navigation and non-essential elements */
    nav, header, footer,
    .mobile-menu-button,
    .no-print {
        display: none !important;
    }

    /* Adjust content for print */
    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* Ensure text is readable */
    body {
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }
}