﻿/* IKUN LAB mobile-first layout overrides.
   Loaded after styles.css so the desktop shell cannot constrain phone widths. */
:root {
    --mobile-gutter: 12px;
    --mobile-radius: 16px;
    --mobile-touch: 44px;
}

@media (max-width: 680px) {
    html,
    body {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        overflow-x: hidden;
    }

    body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .app-shell {
        display: block;
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 8px var(--mobile-gutter) calc(24px + env(safe-area-inset-bottom));
    }

    .topbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
        min-width: 0;
        min-height: 0;
        margin: 0 0 10px;
        padding: 14px;
        border-radius: var(--mobile-radius);
    }

    .topbar > div:first-child {
        min-width: 0;
    }

    .topbar h1 {
        margin: 0;
        font-size: clamp(24px, 7vw, 30px);
        line-height: 1.1;
        white-space: nowrap;
    }

    .topbar-right {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-width: 0;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .topbar-right .user-badge {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    .topbar-right .secondary-button,
    .topbar-right button {
        flex: 0 0 auto;
        width: auto;
        min-width: 74px;
        min-height: var(--mobile-touch);
        padding: 0 14px;
    }

    .app-main-layout {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        min-width: 0;
        gap: 10px;
    }

    .app-sidebar,
    .app-content {
        position: static;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .app-sidebar {
        z-index: 5;
    }

    .service-nav {
        position: static;
        display: flex;
        align-items: stretch;
        width: 100%;
        min-height: 0;
        max-width: 100%;
        gap: 8px;
        padding: 4px 2px 9px;
        overflow-x: auto;
        overflow-y: hidden;
        border: 1px solid rgba(184, 204, 188, 0.72);
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.56);
        box-shadow: 0 8px 20px rgba(31, 57, 42, 0.05);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .service-nav::-webkit-scrollbar {
        display: none;
    }

    .service-nav-item,
    .service-nav-item[data-category="home"],
    .service-nav-item[data-category="settings"] {
        position: relative;
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: auto;
        min-width: max-content;
        min-height: var(--mobile-touch);
        margin: 0;
        padding: 0 13px;
        border-radius: 12px;
        white-space: nowrap;
        box-shadow: none;
    }

    .service-nav-item::after {
        content: none;
    }

    .service-nav-item::before,
    .service-nav-item[data-category="settings"]::before {
        display: none;
    }

    .service-nav-item .service-tag,
    .service-nav-item[data-category="home"] .service-tag,
    .service-nav-item[data-category="settings"] .service-tag {
        min-width: 0;
        padding: 4px 7px;
        font-size: 11px;
    }

    /* On phones the colored service tag is the navigation label. Hiding the
       repeated desktop title keeps the horizontal rail short and scannable. */
    .service-nav-item strong {
        display: none;
    }

    .service-nav-item.is-active,
    .service-nav-item[data-category="home"].is-active,
    .service-nav-item[data-category="settings"].is-active {
        box-shadow: inset 0 -3px 0 #1f8a54;
    }

    .view,
    .login-main,
    .profile-panel,
    .charge-page,
    .mteam-page,
    .mixue-page {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .login-main,
    .profile-panel,
    .charge-page,
    .mteam-page,
    .mixue-page {
        padding: 14px;
        border-radius: var(--mobile-radius);
    }

    .section-heading,
    .charge-heading,
    .mteam-heading,
    .charge-step-heading {
        align-items: flex-start;
        gap: 10px;
        margin-top: 0;
    }

    .section-heading h2,
    .charge-heading h2,
    .mteam-heading h2,
    .mixue-page h2 {
        font-size: clamp(20px, 6vw, 26px);
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .home-hero {
        display: block;
        min-width: 0;
        margin-bottom: 12px;
        padding: 18px;
        border-radius: var(--mobile-radius);
    }

    .home-hero h2 {
        max-width: 100%;
        margin: 8px 0;
        font-size: clamp(24px, 7.5vw, 32px);
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .home-hero p {
        font-size: 13px;
        line-height: 1.65;
    }

    .home-orbit {
        display: none;
    }

    .home-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 0;
    }

    .home-stat-card {
        min-height: 104px;
        padding: 13px;
        border-radius: 14px;
    }

    .home-stat-card strong {
        margin-top: 9px;
        font-size: clamp(19px, 5.5vw, 25px);
        overflow-wrap: anywhere;
    }

    .home-stat-card small {
        font-size: 10px;
        line-height: 1.4;
    }

    .home-module-grid,
    .home-section-heading {
        display: none;
    }

    .tool-grid,
    .form-grid,
    .auth-grid,
    .charge-account-grid,
    .charge-option-grid,
    .charge-confirm-layout {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .tool-grid {
        gap: 10px;
    }

    .tool-card {
        min-height: 88px;
        padding: 14px;
    }

    .charge-progress,
    .mixue-progress {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        margin: 14px 0;
    }

    .charge-progress li,
    .mixue-progress li {
        min-height: 40px;
        gap: 5px;
        padding: 4px 6px;
        font-size: 11px;
        text-align: center;
    }

    .charge-step,
    .mixue-step {
        min-height: 0;
        padding: 14px;
        border-radius: 15px;
    }

    .charge-step-heading h3,
    .mixue-step-title h3 {
        font-size: 18px;
    }

    .charge-account-heading-actions,
    .mixue-shop-search-row,
    .mixue-card-controls,
    .mixue-cart-title,
    .charge-step-actions,
    .mixue-step-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .charge-account-heading-actions > *,
    .mixue-shop-search-row > *,
    .charge-step-actions > *,
    .mixue-step-actions > * {
        width: 100%;
        min-height: var(--mobile-touch);
    }

    .charge-port-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .charge-port-card {
        min-height: 88px;
        padding: 10px 6px;
    }

    .charge-port-card strong {
        font-size: 22px;
    }

    .mixue-progress {
        margin-top: 0;
    }

    .mixue-step-actions {
        margin-top: 14px;
    }

    .mixue-input,
    .mixue-select,
    input,
    select,
    textarea {
        max-width: 100%;
        font-size: 16px;
    }

    .mixue-log-box {
        max-height: 34vh;
        overflow: auto;
    }

    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table,
    .mixue-res-table {
        min-width: 620px;
    }

    .modal-backdrop,
    .custom-modal-overlay {
        align-items: flex-end;
        padding: 8px;
    }

    .modal-card,
    .custom-modal-card {
        width: 100%;
        max-width: none;
        max-height: min(86dvh, 720px);
        border-radius: 18px 18px 12px 12px;
    }

    .app-content > .admin-shell.settings-workspace {
        width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 0;
    }

    .settings-workspace .admin-body {
        min-width: 0;
    }

    .settings-workspace .admin-nav {
        display: block !important;
        width: 100%;
        max-width: 100%;
        margin-bottom: 12px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .settings-workspace .admin-nav::-webkit-scrollbar {
        display: none;
    }

    .settings-workspace .admin-nav-group.admin-nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        width: max-content;
        min-width: 100%;
    }

    .settings-workspace .admin-nav-item {
        width: auto;
        min-height: var(--mobile-touch);
        white-space: nowrap;
    }

    .settings-workspace .admin-mobile-nav-menu {
        display: none !important;
    }

    .settings-workspace .admin-panel {
        min-width: 0;
        padding: 14px;
        border-radius: 15px;
    }

    .admin-mobile-nav-menu {
        margin-bottom: 12px;
    }
}

@media (max-width: 390px) {
    .app-shell {
        --mobile-gutter: 8px;
    }

    .topbar {
        padding: 12px;
    }

    .topbar-right .secondary-button,
    .topbar-right button {
        min-width: 66px;
        padding-inline: 10px;
    }

    .service-nav-item,
    .service-nav-item[data-category="home"],
    .service-nav-item[data-category="settings"] {
        padding-inline: 10px;
    }

    .home-stat-card {
        padding: 11px;
    }

    .charge-port-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
