/* =============================================================================
   SKILLFORGE - RESPONSIVE CSS
   Picture-perfect responsiveness for all devices
   ============================================================================= */

/* =============================================================================
   BASE RESPONSIVE UTILITIES
   ============================================================================= */

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Extra small breakpoint (less than 480px) */
.xs\:inline {
    display: none;
}
@media (min-width: 480px) {
    .xs\:inline {
        display: inline !important;
    }
    .xs\:hidden {
        display: none !important;
    }
}

/* Hide on mobile, show on tablet+ */
.hide-mobile {
    display: none !important;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block !important;
    }
    .hide-mobile.flex {
        display: flex !important;
    }
    .hide-mobile.inline-flex {
        display: inline-flex !important;
    }
    .hide-mobile.grid {
        display: grid !important;
    }
}

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

@media (min-width: 768px) {
    .show-mobile {
        display: none !important;
    }
}

/* =============================================================================
   NAVIGATION RESPONSIVE
   ============================================================================= */

/* Mobile menu improvements */
#mobileMenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

#mobileMenu.open {
    max-height: 500px;
}

/* Navigation padding adjustments */
@media (max-width: 640px) {
    nav .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Hide logo text on very small screens */
    nav .text-xl {
        display: none;
    }
    
    /* Smaller icons/buttons on mobile */
    nav button, nav a {
        padding: 0.5rem;
    }
}

@media (min-width: 641px) and (max-width: 767px) {
    nav .text-xl {
        font-size: 1rem;
    }
}

/* =============================================================================
   DASHBOARD RESPONSIVE
   ============================================================================= */

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Dashboard main grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 2fr 1fr;
    }
}

/* Cards responsive */
.dashboard-card {
    padding: 1rem;
}

@media (min-width: 640px) {
    .dashboard-card {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .dashboard-card {
        padding: 2rem;
    }
}

/* =============================================================================
   COURSE GRID RESPONSIVE
   ============================================================================= */

.course-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .course-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .course-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
}

@media (min-width: 1280px) {
    .course-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Course card responsive */
.course-card {
    border-radius: 1rem;
    overflow: hidden;
}

@media (max-width: 639px) {
    .course-card {
        border-radius: 0.75rem;
    }
    
    .course-card img {
        height: 10rem;
    }
    
    .course-card .p-6 {
        padding: 1rem;
    }
}

/* =============================================================================
   LESSON VIEW RESPONSIVE
   ============================================================================= */

/* Video container */
.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 0.5rem;
}

@media (min-width: 768px) {
    .video-container {
        border-radius: 1rem;
    }
}

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

/* Lesson layout */
.lesson-layout {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 4rem);
}

@media (min-width: 1024px) {
    .lesson-layout {
        flex-direction: row;
    }
}

/* Lesson sidebar */
.lesson-sidebar {
    width: 100%;
    max-height: 40vh;
    overflow-y: auto;
    order: 2;
}

@media (min-width: 1024px) {
    .lesson-sidebar {
        width: 24rem;
        max-height: none;
        height: calc(100vh - 5rem);
        order: 0;
    }
}

/* Lesson content area */
.lesson-content {
    flex: 1;
    padding: 1rem;
}

@media (min-width: 768px) {
    .lesson-content {
        padding: 2rem;
    }
}

/* Lesson navigation buttons */
.lesson-nav-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .lesson-nav-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

/* Mobile lesson sidebar toggle */
.lesson-sidebar-toggle {
    display: block;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 40;
    padding: 1rem;
    border-radius: 9999px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

@media (min-width: 1024px) {
    .lesson-sidebar-toggle {
        display: none;
    }
}

/* =============================================================================
   TABLES RESPONSIVE
   ============================================================================= */

/* Make tables scrollable on mobile */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
}

/* Stack table on mobile alternative */
@media (max-width: 639px) {
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        border-radius: 0.75rem;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
    }
    
    .table-stack tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .table-stack tbody td:last-child {
        border-bottom: none;
    }
    
    .table-stack tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-primary);
    }
}

/* =============================================================================
   FORMS RESPONSIVE
   ============================================================================= */

/* Form containers */
.form-container {
    padding: 1.5rem;
    max-width: 100%;
}

@media (min-width: 640px) {
    .form-container {
        padding: 2rem;
        max-width: 32rem;
        margin: 0 auto;
    }
}

@media (min-width: 768px) {
    .form-container {
        padding: 2.5rem;
        max-width: 36rem;
    }
}

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-grid.two-col {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Input sizes */
.input-responsive {
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
}

@media (min-width: 640px) {
    .input-responsive {
        padding: 0.75rem 1rem;
    }
}

/* =============================================================================
   MODALS RESPONSIVE
   ============================================================================= */

.modal-content {
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
    padding: 1.25rem;
    border-radius: 1rem;
}

@media (min-width: 640px) {
    .modal-content {
        width: 90%;
        max-width: 600px;
        padding: 1.5rem;
        border-radius: 1.5rem;
    }
}

@media (min-width: 768px) {
    .modal-content {
        padding: 2rem;
    }
}

/* =============================================================================
   TYPOGRAPHY RESPONSIVE
   ============================================================================= */

/* Responsive headings */
h1, .text-4xl {
    font-size: 1.5rem;
    line-height: 1.2;
}

h2, .text-3xl {
    font-size: 1.25rem;
}

h3, .text-2xl {
    font-size: 1.125rem;
}

@media (min-width: 640px) {
    h1, .text-4xl {
        font-size: 2rem;
    }
    
    h2, .text-3xl {
        font-size: 1.5rem;
    }
    
    h3, .text-2xl {
        font-size: 1.25rem;
    }
}

@media (min-width: 768px) {
    h1, .text-4xl {
        font-size: 2.25rem;
    }
    
    h2, .text-3xl {
        font-size: 1.875rem;
    }
    
    h3, .text-2xl {
        font-size: 1.5rem;
    }
}

/* Responsive text */
.text-responsive-sm {
    font-size: 0.75rem;
}

.text-responsive-base {
    font-size: 0.875rem;
}

.text-responsive-lg {
    font-size: 1rem;
}

@media (min-width: 640px) {
    .text-responsive-sm {
        font-size: 0.875rem;
    }
    
    .text-responsive-base {
        font-size: 1rem;
    }
    
    .text-responsive-lg {
        font-size: 1.125rem;
    }
}

/* =============================================================================
   SPACING RESPONSIVE
   ============================================================================= */

/* Responsive padding */
.p-responsive {
    padding: 1rem;
}

@media (min-width: 640px) {
    .p-responsive {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .p-responsive {
        padding: 2rem;
    }
}

/* Responsive margins */
.my-responsive {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    .my-responsive {
        margin-top: 2rem;
        margin-bottom: 2rem;
    }
}

@media (min-width: 1024px) {
    .my-responsive {
        margin-top: 3rem;
        margin-bottom: 3rem;
    }
}

/* Container padding */
.container-responsive {
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container-responsive {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container-responsive {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* =============================================================================
   BUTTONS RESPONSIVE
   ============================================================================= */

.btn-responsive {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

@media (min-width: 640px) {
    .btn-responsive {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
        border-radius: 0.625rem;
    }
}

@media (min-width: 768px) {
    .btn-responsive {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        border-radius: 0.75rem;
    }
}

/* Full width button on mobile */
.btn-mobile-full {
    width: 100%;
}

@media (min-width: 640px) {
    .btn-mobile-full {
        width: auto;
    }
}

/* =============================================================================
   CARDS RESPONSIVE
   ============================================================================= */

.card-responsive {
    border-radius: 0.75rem;
    padding: 1rem;
}

@media (min-width: 640px) {
    .card-responsive {
        border-radius: 1rem;
        padding: 1.5rem;
    }
}

@media (min-width: 768px) {
    .card-responsive {
        border-radius: 1.5rem;
        padding: 2rem;
    }
}

/* =============================================================================
   IMAGES RESPONSIVE
   ============================================================================= */

.img-responsive {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Avatar sizes */
.avatar-responsive {
    width: 2.5rem;
    height: 2.5rem;
}

@media (min-width: 640px) {
    .avatar-responsive {
        width: 3rem;
        height: 3rem;
    }
}

@media (min-width: 768px) {
    .avatar-responsive {
        width: 3.5rem;
        height: 3.5rem;
    }
}

/* =============================================================================
   HERO SECTIONS RESPONSIVE
   ============================================================================= */

.hero-section {
    padding: 3rem 1rem;
    text-align: center;
}

@media (min-width: 640px) {
    .hero-section {
        padding: 4rem 2rem;
    }
}

@media (min-width: 768px) {
    .hero-section {
        padding: 6rem 2rem;
    }
}

@media (min-width: 1024px) {
    .hero-section {
        padding: 8rem 2rem;
        text-align: left;
    }
}

/* =============================================================================
   FOOTER RESPONSIVE
   ============================================================================= */

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
}

@media (min-width: 640px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        text-align: left;
    }
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =============================================================================
   SIDEBAR RESPONSIVE
   ============================================================================= */

/* Left sidebar for dashboard */
.sidebar-responsive {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 50;
    transition: left 0.3s ease;
}

.sidebar-responsive.open {
    left: 0;
}

@media (min-width: 1024px) {
    .sidebar-responsive {
        position: relative;
        left: 0;
        width: 280px;
    }
}

/* Sidebar overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 1024px) {
    .sidebar-overlay {
        display: none;
    }
}

/* =============================================================================
   PROGRESS ANALYTICS RESPONSIVE
   ============================================================================= */

.analytics-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .analytics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .analytics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =============================================================================
   NOTIFICATIONS RESPONSIVE
   ============================================================================= */

/* Notification dropdown on mobile */
@media (max-width: 639px) {
    #notificationDropdownMenu {
        position: fixed;
        left: 1rem;
        right: 1rem;
        width: auto;
        max-height: 70vh;
    }
    
    #userDropdownMenu {
        position: fixed;
        left: 1rem;
        right: 1rem;
        width: auto;
    }
}

/* =============================================================================
   QUIZ RESPONSIVE
   ============================================================================= */

.quiz-option {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .quiz-option {
        padding: 1rem 1.25rem;
        font-size: 1rem;
    }
}

/* =============================================================================
   CERTIFICATE RESPONSIVE
   ============================================================================= */

.certificate-preview {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1.414 / 1;
}

@media (min-width: 768px) {
    .certificate-preview {
        max-width: 600px;
    }
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

.animate-slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* =============================================================================
   TOUCH OPTIMIZATIONS
   ============================================================================= */

/* Larger touch targets on mobile */
@media (max-width: 767px) {
    button, 
    a, 
    input[type="button"], 
    input[type="submit"],
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    @media (hover: none) {
        .hover\:bg-opacity-10:hover {
            background-color: transparent;
        }
    }
}

/* =============================================================================
   SAFE AREA INSETS (for notched phones)
   ============================================================================= */

@supports (padding: max(0px)) {
    .safe-area-inset {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .safe-area-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    nav, 
    .no-print,
    #mobileMenuBtn,
    .sidebar-responsive,
    .lesson-sidebar {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .dark-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
