/* Enhanced Mobile-First Responsive Design */

/* Touch-friendly buttons with improved accessibility */
.btn {
    min-height: 48px;
    min-width: 48px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

/* Enhanced touch feedback */
@media (hover: none) and (pointer: coarse) {
    .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .btn-lg {
        min-height: 56px;
        padding: 16px 24px;
    }
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: width 0.3s, height 0.3s, top 0.3s, left 0.3s;
    transform: translate(-50%, -50%);
    z-index: 0;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn * {
    position: relative;
    z-index: 1;
}

/* Enhanced Mobile Navigation */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        margin-top: 1rem;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-xl);
        padding: 1.5rem;
        border: 1px solid var(--gray-200);
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .navbar-nav .nav-link {
        padding: 1rem 1.25rem;
        border-radius: var(--border-radius-sm);
        margin-bottom: 0.5rem;
        font-size: 1.1rem;
        transition: all 0.2s ease;
        position: relative;
        overflow: hidden;
    }
    
    .navbar-nav .nav-link::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
        transition: left 0.3s ease;
    }
    
    .navbar-nav .nav-link:hover::before {
        left: 100%;
    }
    
    .navbar-nav .nav-link:hover {
        background-color: var(--gray-100);
        transform: translateX(5px);
    }
    
    .navbar-nav .dropdown-menu {
        box-shadow: none;
        border: none;
        padding-left: 1.5rem;
        background: var(--gray-50);
        border-radius: var(--border-radius-sm);
        margin-top: 0.5rem;
    }
    
    .navbar-toggler {
        border: none;
        padding: 0.5rem;
        border-radius: var(--border-radius-sm);
        transition: all 0.2s ease;
    }
    
    .navbar-toggler:focus {
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    }
}

/* Enhanced Mobile Hero Section */
@media (max-width: 768px) {
    .hero-section {
        padding: 3rem 0 2rem;
        text-align: center;
        min-height: 70vh;
    }
    
    .hero-section h1 {
        font-size: clamp(1.75rem, 6vw, 2.5rem);
        line-height: 1.1;
        margin-bottom: 1rem;
        letter-spacing: -0.02em;
    }
    
    .hero-section p {
        font-size: 1.1rem;
        line-height: 1.5;
        margin-bottom: 2rem;
        padding: 0 1rem;
    }
    
    .hero-section .btn {
        width: 100%;
        margin-bottom: 1rem;
        min-height: 56px;
        font-size: 1.1rem;
        border-radius: var(--border-radius);
    }
    
    .hero-section .d-flex {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .hero-content {
        padding: 0 1rem;
    }
    
    /* Mobile-optimized floating elements */
    .floating-shapes .shape {
        opacity: 0.1;
        animation-duration: 8s;
    }
    
    .social-proof {
        margin-top: 2rem;
        padding: 1.5rem;
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
        border-radius: var(--border-radius);
    }
}

/* Portrait phone optimization */
@media (max-width: 480px) and (orientation: portrait) {
    .hero-section {
        min-height: 65vh;
        padding: 2rem 0 1.5rem;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
    }
    
    .hero-section p {
        font-size: 1rem;
        padding: 0 0.5rem;
    }
}

/* Enhanced Mobile Course Cards */
@media (max-width: 576px) {
    .course-card {
        margin-bottom: 2rem;
        border-radius: var(--border-radius);
        overflow: hidden;
        box-shadow: var(--shadow-md);
    }
    
    .course-thumbnail {
        height: 180px;
        position: relative;
    }
    
    .course-thumbnail::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 30%;
        background: linear-gradient(transparent, rgba(0,0,0,0.3));
        pointer-events: none;
    }
    
    .course-card .card-body {
        padding: 1.25rem;
    }
    
    .course-meta {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .course-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
        border-radius: var(--border-radius-sm);
    }
    
    .course-card .card-title {
        font-size: 1.125rem;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }
    
    .course-card .card-text {
        font-size: 0.9rem;
        line-height: 1.4;
        margin-bottom: 1rem;
    }
    
    /* Enhanced course card interactions */
    .course-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .course-card .card-body {
        padding: 1rem;
    }
    
    .course-thumbnail {
        height: 160px;
    }
}

/* Enhanced Mobile Forms */
@media (max-width: 576px) {
    .form-floating {
        margin-bottom: 1.25rem;
    }
    
    .form-control {
        min-height: 52px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
        border-radius: var(--border-radius);
        border-width: 2px;
        transition: all 0.3s ease;
    }
    
    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
        transform: none; /* Disable transform on mobile */
    }
    
    .form-select {
        min-height: 52px;
        font-size: 16px;
        padding: 0.875rem 1rem;
        border-radius: var(--border-radius);
        border-width: 2px;
    }
    
    .input-group .form-control {
        border-radius: var(--border-radius) 0 0 var(--border-radius);
    }
    
    .input-group .btn {
        border-radius: 0 var(--border-radius) var(--border-radius) 0;
        min-height: 52px;
    }
    
    /* Enhanced textarea */
    .form-control[rows] {
        min-height: 120px;
        resize: vertical;
    }
    
    /* Improved checkbox and radio styles */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0.125rem;
    }
    
    .form-check-label {
        font-size: 1rem;
        line-height: 1.5;
        padding-left: 0.5rem;
    }
}

/* Mobile Dashboard */
@media (max-width: 768px) {
    .dashboard-card .stat-number {
        font-size: 2rem;
    }
    
    .dashboard-card .card-body {
        padding: 1.25rem;
    }
    
    .sidebar-sticky {
        position: static !important;
        top: auto !important;
    }
}

/* Mobile Video Player */
@media (max-width: 768px) {
    .video-container {
        margin-bottom: 1rem;
    }
    
    .video-player {
        max-height: 250px;
    }
    
    .course-sidebar {
        position: static;
        margin-top: 1rem;
        padding: 1rem;
    }
    
    .video-controls {
        padding: 0.75rem;
    }
    
    .control-button {
        font-size: 1rem;
        margin-right: 0.75rem;
        min-width: 40px;
        min-height: 40px;
    }
}

/* Mobile Search */
@media (max-width: 768px) {
    .navbar .d-flex {
        width: 100%;
        margin-top: 1rem;
    }
    
    .search-results {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 1050;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .search-item {
        padding: 1rem;
        border-radius: var(--border-radius-sm);
    }
}

/* Mobile Tables */
@media (max-width: 768px) {
    .table-responsive {
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table td, .table th {
        padding: 0.75rem 0.5rem;
    }
}

/* Mobile Modals */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: var(--border-radius);
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 1rem;
    }
}

/* Mobile Alerts */
@media (max-width: 576px) {
    .alert {
        border-radius: var(--border-radius-sm);
        margin-bottom: 1rem;
    }
    
    .alert-dismissible .btn-close {
        padding: 1rem;
    }
}

/* Mobile Progress Bars */
.progress {
    height: 6px;
    border-radius: 3px;
    background-color: var(--gray-200);
}

.progress-bar {
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Mobile Pagination */
@media (max-width: 576px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--border-radius-sm);
        margin: 0.125rem;
    }
}

/* Touch feedback */
@media (hover: none) {
    .btn:hover {
        transform: none;
    }
    
    .course-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
    
    .course-card:active {
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}

/* Swipe gestures for mobile */
.swipeable {
    touch-action: pan-y pinch-zoom;
}

/* Mobile-optimized loading states */
.loading-skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--border-radius-sm);
}

@keyframes loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Enhanced Mobile-friendly spacing */
@media (max-width: 576px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
        max-width: 100%;
    }
    
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .py-5 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
    
    .py-6 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    .mb-5 {
        margin-bottom: 2.5rem !important;
    }
    
    .mt-5 {
        margin-top: 2.5rem !important;
    }
    
    .mb-6 {
        margin-bottom: 3rem !important;
    }
    
    .mt-6 {
        margin-top: 3rem !important;
    }
    
    /* Section spacing optimization */
    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .stats-section {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
}

/* Safe area handling for notched devices */
@supports (padding: max(0px)) {
    .container,
    .container-fluid {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
}

/* Improved mobile typography */
@media (max-width: 576px) {
    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    .lead {
        font-size: 1.1rem;
    }
    
    .small {
        font-size: 0.8rem;
    }
}

/* Enhanced Mobile-friendly dropdowns */
@media (max-width: 768px) {
    .dropdown-menu {
        width: 100%;
        max-height: 60vh;
        overflow-y: auto;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-xl);
        backdrop-filter: blur(20px);
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid var(--gray-200);
        animation: dropdownSlideIn 0.2s ease;
    }
    
    @keyframes dropdownSlideIn {
        from {
            opacity: 0;
            transform: translateY(-10px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
    
    .dropdown-item {
        padding: 1rem 1.25rem;
        font-size: 1rem;
        border-radius: var(--border-radius-sm);
        margin: 0.25rem 0.5rem;
        transition: all 0.2s ease;
        position: relative;
        overflow: hidden;
    }
    
    .dropdown-item::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
        transition: left 0.3s ease;
    }
    
    .dropdown-item:hover::before {
        left: 100%;
    }
    
    .dropdown-item:active {
        transform: scale(0.98);
        background-color: var(--primary-color);
        color: white;
    }
    
    /* Bottom sheet style for very small screens */
    @media (max-width: 400px) {
        .dropdown-menu {
            position: fixed !important;
            bottom: 0;
            left: 0;
            right: 0;
            top: auto !important;
            transform: none !important;
            border-radius: var(--border-radius) var(--border-radius) 0 0;
            max-height: 50vh;
        }
    }
}