/* ============================================================
   KachiTech Mobile Redesign
   Professional mobile-first responsive design
   ============================================================ */

/* ============================================================
   1. MOBILE BASE & SMOOTH SCROLLING
   ============================================================ */

@media (max-width: 991.98px) {
    html {
        scroll-behavior: smooth;
        -webkit-text-size-adjust: 100%;
        overflow-x: auto;
    }

    body.kachi-frontend-body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        overflow-x: auto;
        overflow-y: auto;
        position: relative;
        height: auto;
    }

    /* Fix Bootstrap offcanvas blocking body scroll */
    body.offcanvas-open,
    body.offcanvas-backdrop {
        overflow: auto !important;
        position: static !important;
        height: auto !important;
    }

    body.offcanvas-open .site-boxed-layout {
        overflow: visible !important;
    }

    /* Fix boxed layout blocking scroll on mobile */
    .site-boxed-layout {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        overflow: visible !important;
        box-shadow: none !important;
    }

    /* Safe area insets for notched devices */
    .site-boxed-layout {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ============================================================
   2. MOBILE HEADER — Sticky, compact, glass-morphism
   ============================================================ */

@media (max-width: 991.98px) {
    .workspace-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: rgba(254, 253, 248, 0.85);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid rgba(91, 141, 184, 0.12);
        box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
    }

    .workspace-nav-shell {
        padding: 0;
    }

    .workspace-nav {
        padding: 10px 0;
        gap: 12px;
    }

    .workspace-brand {
        padding: 0;
    }

    .workspace-brand__mark img {
        height: 34px;
        width: auto;
    }

    /* Hide desktop-only elements */
    .workspace-language--gtranslate,
    .workspace-mode-toggle span {
        display: none;
    }

    .workspace-mode-toggle {
        height: 36px;
        min-width: 36px;
        padding: 0;
        border-radius: 50%;
        font-size: 16px;
    }

    .workspace-auth {
        display: none !important;
    }

    /* Hamburger button redesign */
    .workspace-mobile-toggle {
        position: relative;
        height: 42px;
        min-width: 42px;
        padding: 0;
        border: none;
        border-radius: 12px;
        background: linear-gradient(135deg, var(--kt-primary), var(--kt-primary-2));
        color: #fff;
        font-size: 18px;
        box-shadow: 0 4px 16px rgba(91, 141, 184, 0.30);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .workspace-mobile-toggle:active {
        transform: scale(0.92);
        box-shadow: 0 2px 8px rgba(91, 141, 184, 0.20);
    }

    .workspace-mobile-toggle i {
        font-size: 18px;
    }
}

/* ============================================================
   3. MOBILE DRAWER — Full-screen, smooth, sectioned
   ============================================================ */

@media (max-width: 991.98px) {
    .workspace-mobile-drawer {
        width: 100% !important;
        max-width: 100% !important;
        background: linear-gradient(180deg, #fefdf8 0%, #f8f6ee 100%);
        border: none;
        box-shadow: none;
    }

    .workspace-mobile-drawer .offcanvas-header {
        padding: 16px 20px;
        border-bottom: 1px solid rgba(91, 141, 184, 0.10);
        background: rgba(254, 253, 248, 0.95);
        backdrop-filter: blur(10px);
    }

    .workspace-mobile-drawer .offcanvas-header .btn-close {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(91, 141, 184, 0.10);
        opacity: 0.7;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }

    .workspace-mobile-drawer .offcanvas-header .btn-close:hover {
        background: rgba(91, 141, 184, 0.20);
        opacity: 1;
    }

    .workspace-mobile-drawer .offcanvas-body {
        padding: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Profile card at top */
    .workspace-mobile-profile {
        margin: 16px 20px;
        padding: 16px;
        background: linear-gradient(135deg, rgba(91, 141, 184, 0.08), rgba(196, 154, 60, 0.06));
        border: 1px solid rgba(91, 141, 184, 0.15);
        border-radius: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    }

    .workspace-mobile-profile img {
        width: 48px;
        height: 48px;
        border: 2px solid rgba(91, 141, 184, 0.20);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .workspace-mobile-profile span {
        font-size: 15px;
        font-weight: 700;
        color: var(--kt-text);
    }

    /* Menu sections */
    .workspace-mobile-section {
        margin: 0 20px 16px;
        padding: 16px;
        background: rgba(255, 255, 255, 0.7);
        border: 1px solid rgba(91, 141, 184, 0.10);
        border-radius: 16px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    }

    .workspace-mobile-section__title {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #94a3b8;
        font-weight: 700;
        margin-bottom: 10px;
        padding-left: 0;
    }

    /* Menu links as touch-friendly cards */
    .workspace-mobile-menu {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .workspace-mobile-menu a {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
        color: var(--kt-text);
        background: transparent;
        border: none;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        min-height: 48px;
        -webkit-tap-highlight-color: transparent;
    }

    .workspace-mobile-menu a i {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(91, 141, 184, 0.08);
        border-radius: 10px;
        font-size: 16px;
        color: var(--kt-primary);
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .workspace-mobile-menu a:active {
        transform: scale(0.98);
        background: rgba(91, 141, 184, 0.06);
    }

    .workspace-mobile-menu a.active {
        background: linear-gradient(135deg, var(--kt-primary), var(--kt-primary-2));
        color: #fff;
        box-shadow: 0 4px 16px rgba(91, 141, 184, 0.25);
    }

    .workspace-mobile-menu a.active i {
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
    }

    .workspace-mobile-menu a:hover {
        background: rgba(91, 141, 184, 0.06);
    }

    .workspace-mobile-menu a:hover i {
        background: rgba(91, 141, 184, 0.15);
    }

    /* Auth buttons in drawer */
    .workspace-mobile-auth-group {
        margin: 16px 20px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .workspace-mobile-auth-group a {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 14px 20px;
        border-radius: 14px;
        font-size: 15px;
        font-weight: 700;
        text-decoration: none;
        min-height: 50px;
        transition: all 0.2s ease;
    }

    .workspace-mobile-auth-group .btn-login {
        color: var(--kt-primary);
        background: rgba(91, 141, 184, 0.10);
        border: 1px solid rgba(91, 141, 184, 0.20);
    }

    .workspace-mobile-auth-group .btn-register {
        color: #fff;
        background: linear-gradient(135deg, var(--kt-primary), var(--kt-primary-2));
        border: none;
        box-shadow: 0 4px 16px rgba(91, 141, 184, 0.25);
    }

    .workspace-mobile-auth-group .btn-login:active,
    .workspace-mobile-auth-group .btn-register:active {
        transform: scale(0.98);
    }

    /* Language selector in drawer */
    .workspace-language--mobile {
        margin: 16px 20px;
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.7);
        border: 1px solid rgba(91, 141, 184, 0.10);
        border-radius: 12px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .workspace-language--mobile i {
        color: var(--kt-primary);
        font-size: 16px;
    }

    /* Drawer footer */
    .workspace-mobile-drawer-footer {
        margin: 20px;
        padding: 16px;
        text-align: center;
        color: #94a3b8;
        font-size: 12px;
        border-top: 1px solid rgba(91, 141, 184, 0.10);
    }
}

/* ============================================================
   4. MOBILE HERO SLIDER — Compact, thumb-friendly
   ============================================================ */

@media (max-width: 991.98px) {
    .course-home__intro {
        padding: 16px 0 12px;
    }

    .kachi-hero-slider {
        border-radius: 16px;
        overflow: hidden;
    }

    .kachi-hero-slider .slick-slide {
        padding: 0;
    }

    .course-home__panel {
        min-height: 260px;
        padding: 24px 20px;
        grid-template-columns: 1fr;
        gap: 16px;
        border-radius: 16px;
    }

    .course-home__eyebrow {
        font-size: 10px;
        padding: 6px 10px;
        margin-bottom: 10px;
    }

    .course-home__copy h1 {
        font-size: clamp(22px, 6vw, 32px);
        margin-bottom: 10px;
        line-height: 1.1;
    }

    .course-home__copy p {
        font-size: 13px;
        line-height: 1.5;
        margin-bottom: 14px;
    }

    .course-home__actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .course-home__primary,
    .course-home__secondary {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 20px;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 700;
        min-height: 46px;
        text-align: center;
        width: 100%;
    }

    .course-home__primary {
        background: linear-gradient(135deg, var(--kt-primary), var(--kt-primary-2));
        box-shadow: 0 4px 16px rgba(91, 141, 184, 0.30);
    }

    .course-home__secondary {
        background: rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    .course-home__metrics {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .course-home__metrics > div {
        text-align: center;
        padding: 10px 8px;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(8px);
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .course-home__metrics strong {
        display: block;
        font-size: 16px;
        font-weight: 800;
        margin-bottom: 2px;
    }

    .course-home__metrics span {
        font-size: 10px;
        font-weight: 600;
        opacity: 0.85;
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }

    /* Slick dots repositioned */
    .kachi-hero-slider .slick-dots {
        bottom: -28px;
    }

    .kachi-hero-slider .slick-dots li {
        width: 8px;
        height: 8px;
        margin: 0 4px;
    }

    .kachi-hero-slider .slick-dots li button:before {
        font-size: 0;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(91, 141, 184, 0.3);
        opacity: 1;
    }

    .kachi-hero-slider .slick-dots li.slick-active button:before {
        background: var(--kt-primary);
        transform: scale(1.2);
    }

    /* Slick arrows */
    .kachi-hero-slider .slick-prev,
    .kachi-hero-slider .slick-next {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        z-index: 10;
    }

    .kachi-hero-slider .slick-prev {
        left: 12px;
    }

    .kachi-hero-slider .slick-next {
        right: 12px;
    }

    .kachi-hero-slider .slick-prev i,
    .kachi-hero-slider .slick-next i {
        font-size: 14px;
    }
}

@media (max-width: 575.98px) {
    .course-home__panel {
        min-height: 240px;
        padding: 20px 16px;
    }

    .course-home__copy h1 {
        font-size: 20px;
    }

    .course-home__copy p {
        font-size: 12px;
    }

    .course-home__metrics {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .course-home__metrics strong {
        font-size: 14px;
    }

    .course-home__metrics span {
        font-size: 9px;
    }
}

/* ============================================================
   5. MOBILE SECTIONS — Pillars, operate, course sliders
   ============================================================ */

@media (max-width: 991.98px) {
    /* Section spacing */
    .kachi-home-pillars,
    .kachi-home-operate,
    .course-slider-section {
        padding: 28px 0;
    }

    /* Section headers */
    .course-section-head {
        margin-bottom: 20px;
    }

    .course-section-head span {
        font-size: 11px;
        padding: 6px 12px;
        margin-bottom: 10px;
    }

    .course-section-head h2 {
        font-size: 20px;
        line-height: 1.2;
        margin-bottom: 8px;
    }

    .course-section-head p {
        font-size: 13px;
        line-height: 1.5;
    }

    /* Pillars grid */
    .kachi-home-pillars__grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kachi-home-pillar {
        padding: 18px;
        border-radius: 14px;
        min-height: auto;
    }

    .kachi-home-pillar__icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
        margin-bottom: 12px;
    }

    .kachi-home-pillar h3 {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .kachi-home-pillar p {
        font-size: 13px;
        line-height: 1.5;
    }

    /* Operate steps */
    .kachi-home-operate__steps {
        grid-template-columns: 1fr;
        gap: 12px;
        counter-reset: none;
    }

    .kachi-home-operate__steps li {
        padding: 16px;
        border-radius: 14px;
        min-height: auto;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .kachi-home-operate__steps li::before {
        font-size: 14px;
        width: 32px;
        height: 32px;
        line-height: 32px;
        margin-bottom: 4px;
    }

    .kachi-home-operate__steps li strong {
        font-size: 15px;
    }

    .kachi-home-operate__steps li span {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* ============================================================
   6. COURSE SLIDER FIXES (Desktop + Mobile)
   ============================================================ */

/* Ensure course sliders are always visible, even before slick init */
.course-slider-section {
    display: block !important;
    visibility: visible !important;
}

.kachi-course-slider {
    display: block !important;
    visibility: visible !important;
}

/* Fallback: show slides even if slick hasn't initialized yet */
.kachi-course-slider .kachi-course-slide {
    display: block !important;
}

.kachi-course-slider .slick-slide {
    display: block !important;
}

.kachi-course-slider .slick-list {
    display: block !important;
}

.kachi-course-slider .slick-track {
    display: flex !important;
}

@media (max-width: 991.98px) {
    .kachi-course-slider {
        padding: 0 4px;
    }

    .kachi-course-slider .slick-slide {
        padding: 6px;
    }

    .kachi-course-card {
        min-height: auto;
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    }

    .kachi-course-card__image {
        height: 140px;
    }

    .kachi-course-card__body {
        padding: 14px;
    }

    .kachi-course-card__category {
        font-size: 10px;
        padding: 4px 10px;
        margin-bottom: 8px;
    }

    .kachi-course-card__body h3 {
        font-size: 14px;
        line-height: 1.3;
        margin-bottom: 6px;
    }

    .kachi-course-card__body p {
        font-size: 12px;
        line-height: 1.4;
        margin-bottom: 10px;
    }

    .kachi-course-card__footer {
        padding: 10px 14px;
    }

    .kachi-course-card__price {
        font-size: 14px;
    }

    .kachi-course-card__btn {
        padding: 8px 14px;
        font-size: 12px;
        min-height: 38px;
        border-radius: 10px;
    }

    /* Slider arrows */
    .kachi-course-slider .slick-prev,
    .kachi-course-slider .slick-next {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
        z-index: 10;
    }

    .kachi-course-slider .slick-prev {
        left: 8px;
    }

    .kachi-course-slider .slick-next {
        right: 8px;
    }

    .kachi-course-slider .slick-prev i,
    .kachi-course-slider .slick-next i {
        font-size: 12px;
    }
}

@media (max-width: 575.98px) {
    .kachi-course-slider {
        padding: 0 2px;
    }

    .kachi-course-card__image {
        height: 120px;
    }

    .kachi-course-card__body {
        padding: 12px;
    }

    .kachi-course-card__body h3 {
        font-size: 13px;
    }
}

/* ============================================================
   7. MOBILE FOOTER
   ============================================================ */

@media (max-width: 991.98px) {
    .workspace-footer {
        padding: 32px 0 20px;
    }

    .workspace-footer__grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .workspace-footer__brand {
        text-align: center;
    }

    .workspace-footer__brand img {
        height: 36px;
        margin-bottom: 12px;
    }

    .workspace-footer__brand p {
        font-size: 13px;
        line-height: 1.5;
    }

    .workspace-footer__col h4 {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .workspace-footer__col ul {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .workspace-footer__col ul li a {
        font-size: 13px;
        padding: 6px 0;
    }

    .workspace-footer__newsletter {
        margin-top: 16px;
    }

    .workspace-footer__newsletter form {
        flex-direction: column;
        gap: 8px;
    }

    .workspace-footer__newsletter input {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 46px;
    }

    .workspace-footer__newsletter button {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 46px;
        width: 100%;
    }

    .workspace-footer__bottom {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding-top: 20px;
        margin-top: 20px;
    }

    .workspace-footer__social {
        justify-content: center;
    }

    .workspace-footer__social a {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* ============================================================
   8. MOBILE AUTH PAGES
   ============================================================ */

@media (max-width: 991.98px) {
    .kachi-auth-card {
        margin: 16px;
        border-radius: 20px;
        padding: 24px 20px;
    }

    .kachi-auth-card h2 {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .kachi-auth-card p {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .kachi-auth-card .form-control {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 46px;
    }

    .kachi-auth-card .btn {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 48px;
    }

    .kachi-auth-tabs {
        margin-bottom: 20px;
        gap: 6px;
    }

    .kachi-auth-tab {
        padding: 10px 18px;
        font-size: 13px;
        border-radius: 10px;
        min-height: 42px;
    }
}

/* ============================================================
   9. MOBILE COURSE LISTING PAGE
   ============================================================ */

@media (max-width: 991.98px) {
    .kachi-course-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .kachi-course-filter-bar {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .kachi-course-filter-bar select,
    .kachi-course-filter-bar input {
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 12px;
        min-height: 44px;
    }
}

@media (max-width: 575.98px) {
    .kachi-course-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* ============================================================
   10. MOBILE SCROLL EFFECTS & MICRO-INTERACTIONS
   ============================================================ */

@media (max-width: 991.98px) {
    /* Smooth reveal on scroll */
    .wow {
        animation-duration: 0.5s;
    }

    /* Touch-friendly active states */
    a:active,
    button:active {
        -webkit-tap-highlight-color: transparent;
    }

    /* Smooth card press effect */
    .kachi-course-card:active,
    .kachi-home-pillar:active,
    .kachi-home-operate__steps li:active {
        transform: scale(0.98);
        transition: transform 0.15s ease;
    }

    /* Pull-to-refresh safe area */
    .site-boxed-layout {
        overscroll-behavior: auto;
    }

    /* Smooth section transitions */
    section {
        transition: opacity 0.3s ease;
    }

    /* Hide scrollbar but keep functionality */
    .workspace-mobile-drawer .offcanvas-body::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    .workspace-mobile-drawer .offcanvas-body {
        scrollbar-width: none;
    }

    /* Better focus states for accessibility */
    a:focus-visible,
    button:focus-visible {
        outline: 2px solid var(--kt-primary);
        outline-offset: 2px;
        border-radius: 8px;
    }
}

/* ============================================================
   11. VERY SMALL SCREENS (320px - 374px)
   ============================================================ */

@media (max-width: 374.98px) {
    .workspace-nav {
        padding: 8px 0;
    }

    .workspace-brand__mark img {
        height: 28px;
    }

    .workspace-mobile-toggle {
        height: 38px;
        min-width: 38px;
    }

    .course-home__panel {
        min-height: 220px;
        padding: 16px 14px;
    }

    .course-home__copy h1 {
        font-size: 18px;
    }

    .course-home__copy p {
        font-size: 11px;
    }

    .course-section-head h2 {
        font-size: 18px;
    }

    .kachi-home-pillar {
        padding: 14px;
    }

    .kachi-home-operate__steps li {
        padding: 14px;
    }
}

/* ============================================================
   12. MOBILE WORKSPACE PAGES
   ============================================================ */

@media (max-width: 991.98px) {
    .workspace-hero-slider {
        border-radius: 16px;
    }

    .workspace-features-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .workspace-feature-card {
        padding: 18px;
        border-radius: 14px;
    }

    .workspace-feature-card__icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
        margin-bottom: 12px;
    }

    .workspace-feature-card h3 {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .workspace-feature-card p {
        font-size: 13px;
        line-height: 1.5;
    }

    .workspace-pricing-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .workspace-pricing-card {
        padding: 20px;
        border-radius: 16px;
    }
}

/* ============================================================
   13. MOBILE INSTRUCTOR PAGES
   ============================================================ */

@media (max-width: 991.98px) {
    .instructor-dashboard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .instructor-stat-card {
        padding: 16px;
        border-radius: 14px;
    }

    .instructor-stat-card__icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .instructor-stat-card__value {
        font-size: 20px;
    }
}
