/* ============================================================
   KZ Checker - Mobile UI
   Dedicated mobile-first experience
   ============================================================ */

/* Mobile detection - only apply on screens <= 768px */
@media (max-width: 768px) {
    /* ============================================================
       BASE MOBILE RESETS
       ============================================================ */
    html {
        font-size: 15px;
    }

    body {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* Hide desktop elements */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile elements */
    .mobile-only {
        display: flex !important;
    }

    /* ============================================================
       MOBILE TOPBAR
       ============================================================ */
    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        padding: 0 16px;
        z-index: 1000;
        background: var(--bg-subtle);
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .topbar-brand {
        flex-shrink: 0;
    }

    .topbar-brand .logo-mini-text {
        display: none;
    }

    .topbar-brand .logo-mini-svg {
        width: 28px;
        height: 32px;
    }

    /* Hide desktop nav */
    .topnav {
        display: none !important;
    }

    /* Mobile topbar right */
    .topbar-right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
        justify-content: flex-end;
    }

    /* Live pill - compact */
    .live-pill {
        padding: 5px 10px;
        font-size: 11px;
        gap: 5px;
    }

    .live-pill span:last-child {
        display: none;
    }

    /* Credits chip - compact */
    .credits-chip {
        padding: 4px 5px 4px 10px;
        gap: 6px;
        min-width: auto;
    }

    .credits-chip-label {
        display: none;
    }

    .credits-chip-meta {
        gap: 0;
    }

    .credits-chip-value {
        font-size: 12px;
    }

    .credits-chip-plus {
        width: 24px;
        height: 24px;
    }

    .credits-chip-plus svg {
        width: 12px;
        height: 12px;
    }

    /* Icon buttons - compact */
    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .icon-btn svg {
        width: 18px;
        height: 18px;
    }

    /* User widget - avatar only */
    .topbar .user-widget {
        padding: 0;
        background: none;
        border: none;
        gap: 0;
    }

    .topbar .user-info,
    .topbar .user-menu-btn {
        display: none;
    }

    .topbar .user-avatar {
        width: 36px;
        height: 36px;
    }

    /* ============================================================
       MOBILE HAMBURGER MENU
       ============================================================ */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        cursor: pointer;
        transition: all var(--transition-fast);
    }

    .mobile-menu-btn:hover,
    .mobile-menu-btn:active {
        background: var(--surface-hover);
        color: var(--text);
    }

    .mobile-menu-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Mobile slide-out menu */
    .mobile-menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 2000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        background: var(--bg-subtle);
        border-left: 1px solid var(--border);
        z-index: 2001;
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-menu-overlay.active .mobile-menu {
        transform: translateX(0);
    }

    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid var(--border);
    }

    .mobile-menu-close {
        width: 36px;
        height: 36px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-user {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 20px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }

    .mobile-menu-user .user-avatar {
        width: 48px;
        height: 48px;
    }

    .mobile-menu-user .user-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-menu-user .user-name {
        font-size: 15px;
        font-weight: 600;
    }

    .mobile-menu-user .user-role {
        font-size: 11px;
        color: var(--success);
    }

    .mobile-menu-nav {
        flex: 1;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 4px;
        overflow-y: auto;
    }

    .mobile-menu-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
        background: transparent;
        border: none;
        border-radius: var(--radius);
        color: var(--text-secondary);
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        text-decoration: none;
        transition: all var(--transition-fast);
        text-align: left;
        width: 100%;
    }

    .mobile-menu-item:hover,
    .mobile-menu-item:active {
        background: var(--surface-hover);
        color: var(--text);
    }

    .mobile-menu-item.active {
        background: var(--surface-active);
        color: var(--text);
    }

    .mobile-menu-item svg {
        width: 20px;
        height: 20px;
        opacity: 0.7;
    }

    .mobile-menu-item.danger {
        color: var(--danger);
    }

    .mobile-menu-divider {
        height: 1px;
        background: var(--border);
        margin: 8px 0;
    }

    .mobile-menu-footer {
        padding: 16px 20px;
        border-top: 1px solid var(--border);
    }

    .mobile-menu-balance {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 16px;
        background: var(--surface);
        border-radius: var(--radius);
        margin-bottom: 12px;
    }

    .mobile-menu-balance-label {
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.1em;
    }

    .mobile-menu-balance-value {
        font-family: var(--font-mono);
        font-size: 24px;
        font-weight: 600;
        color: var(--success);
    }

    .mobile-menu-recharge {
        width: 100%;
        padding: 14px;
        background: var(--accent);
        border: none;
        border-radius: var(--radius);
        color: var(--on-accent);
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    /* ============================================================
       MOBILE WORKSPACE
       ============================================================ */
    .console-shell {
        flex-direction: column;
    }

    .workspace {
        padding: 76px 16px 24px;
        gap: 20px;
        min-height: 100vh;
    }

    .workspace-head {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

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

    .page-title {
        font-size: 26px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    /* ============================================================
       MOBILE KPI STRIP
       ============================================================ */
    .kpi-strip {
        width: 100%;
        padding: 14px 16px;
        gap: 0;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    .kpi {
        flex: 1;
        align-items: center;
        text-align: center;
        min-width: 0;
    }

    .kpi-value {
        font-size: 16px;
        white-space: nowrap;
    }

    .kpi-label {
        font-size: 9px;
        white-space: nowrap;
    }

    .kpi-div {
        height: 30px;
        flex-shrink: 0;
    }

    /* ============================================================
       MOBILE METRICS
       ============================================================ */
    .metrics {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        width: 100%;
    }

    .metric-card {
        padding: 16px;
        border-radius: var(--radius);
        min-height: auto;
        overflow: visible;
    }

    /* Remove decorative glow on mobile for performance */
    .metric-card::before {
        display: none;
    }

    .metric-card:hover {
        transform: none;
    }

    .metric-header {
        margin-bottom: 8px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .metric-label {
        font-size: 9px;
        letter-spacing: 0.08em;
    }

    .metric-icon {
        width: 26px;
        height: 26px;
        border-radius: 6px;
    }

    .metric-icon svg {
        width: 12px;
        height: 12px;
    }

    .metric-value {
        font-size: 24px;
        margin-bottom: 8px;
        line-height: 1.1;
    }

    .metric-bar {
        display: block;
        height: 3px;
    }

    /* Hide sparklines on mobile */
    .sparkline {
        display: none !important;
    }

    /* ============================================================
       MOBILE WORK GRID
       ============================================================ */
    .work-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* ============================================================
       MOBILE PANELS
       ============================================================ */
    .panel {
        border-radius: var(--radius);
    }

    .panel-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .panel-title {
        font-size: 14px;
    }

    .panel-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }

    .panel-actions .btn-ghost {
        padding: 6px 10px;
        font-size: 11px;
    }

    .panel-actions .btn-ghost svg {
        width: 14px;
        height: 14px;
    }

    .panel-body {
        padding: 16px;
        gap: 14px;
    }

    /* ============================================================
       MOBILE INPUT
       ============================================================ */
    #cards-input {
        min-height: 120px;
        font-size: 12px;
        padding: 12px;
        line-height: 1.6;
    }

    .input-footer {
        font-size: 10px;
        padding-top: 6px;
    }

    .options-row {
        flex-direction: column;
        gap: 12px;
        padding: 12px 0;
    }

    .toggle {
        width: 100%;
        justify-content: space-between;
    }

    .toggle-label {
        font-size: 14px;
    }

    .number-input {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .btn-primary {
        width: 100%;
        padding: 16px 20px;
        font-size: 15px;
    }

    /* ============================================================
       MOBILE TABS
       ============================================================ */
    .tabs-wrapper {
        padding: 0 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tabs {
        min-width: max-content;
        gap: 2px;
    }

    .tab {
        padding: 10px 14px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* ============================================================
       MOBILE RESULTS
       ============================================================ */
    .results-list {
        padding: 12px;
        min-height: 180px;
        max-height: 280px;
    }

    .result-item {
        padding: 10px;
        gap: 10px;
        margin-bottom: 6px;
    }

    .result-status-icon {
        width: 24px;
        height: 24px;
    }

    .result-status-icon svg {
        width: 12px;
        height: 12px;
    }

    .result-card {
        font-size: 11px;
    }

    .result-message {
        font-size: 10px;
    }

    .result-time {
        font-size: 9px;
    }

    .empty-state {
        padding: 24px 16px;
        min-height: 150px;
    }

    .empty-state svg {
        width: 40px;
        height: 40px;
        padding: 12px;
    }

    .empty-title {
        font-size: 14px;
    }

    .empty-text {
        font-size: 11px;
    }

    /* ============================================================
       MOBILE ACTIVITY PANEL
       ============================================================ */
    .activity-panel {
        margin-top: 0;
    }

    .activity-list {
        padding: 10px 12px;
        max-height: 100px;
    }

    .activity-item {
        font-size: 11px;
    }

    .activity-time {
        width: 36px;
    }

    /* ============================================================
       MOBILE MODALS
       ============================================================ */
    .modal-overlay {
        padding: 16px;
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        max-height: 85vh;
        margin: 0;
        padding: 24px 20px;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal-close {
        top: 12px;
        right: 12px;
        width: 28px;
        height: 28px;
    }

    .modal-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 16px;
    }

    .modal-icon svg {
        width: 32px;
        height: 32px;
    }

    .modal-title {
        font-size: 20px;
    }

    .modal-subtitle {
        font-size: 13px;
    }

    /* Stepper */
    .stepper {
        margin-bottom: 24px;
    }

    .step-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .step-label {
        font-size: 10px;
    }

    .step-line {
        width: 32px;
        margin: 0 8px 16px;
    }

    /* Amount grid */
    .amount-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 16px;
    }

    .amount-btn {
        padding: 12px 8px;
    }

    .amount-value {
        font-size: 16px;
    }

    .amount-bonus {
        font-size: 10px;
    }

    .amount-tag {
        font-size: 8px;
        padding: 2px 6px;
        top: -8px;
    }

    /* Custom amount */
    .custom-amount {
        margin-bottom: 16px;
    }

    .custom-amount-input input {
        font-size: 16px;
        padding: 12px 12px 12px 44px;
    }

    .currency-prefix {
        font-size: 14px;
        left: 14px;
    }

    /* QR code */
    .qr-wrapper {
        width: 160px;
        height: 160px;
        padding: 10px;
    }

    .qr-timer {
        font-size: 12px;
    }

    /* Payment info */
    .payment-info {
        padding: 14px;
        margin-bottom: 12px;
    }

    .payment-label {
        font-size: 12px;
    }

    .payment-value {
        font-size: 18px;
    }

    /* PIX code */
    .pix-code-wrapper {
        margin-bottom: 16px;
    }

    .pix-code-input {
        flex-direction: column;
        gap: 8px;
    }

    .pix-code-input input {
        font-size: 10px;
        padding: 10px;
    }

    .copy-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    /* Success animation */
    .success-circle {
        width: 80px;
        height: 80px;
    }

    .success-circle svg {
        width: 48px;
        height: 48px;
    }

    /* Confirmation details */
    .confirmation-details {
        padding: 14px;
        margin-bottom: 16px;
    }

    .detail-row span {
        font-size: 12px;
    }

    .detail-row strong {
        font-size: 14px;
    }

    /* ============================================================
       MOBILE SETTINGS MODAL
       ============================================================ */
    .settings-modal {
        padding: 20px 16px;
    }

    .settings-header {
        padding: 16px;
        margin-bottom: 16px;
    }

    .settings-avatar {
        width: 52px;
        height: 52px;
    }

    .settings-avatar svg {
        width: 24px;
        height: 24px;
    }

    .settings-user-info h2 {
        font-size: 18px;
    }

    .settings-badge {
        font-size: 9px;
        padding: 3px 8px;
    }

    .settings-section {
        margin-bottom: 20px;
    }

    .settings-section-title {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .settings-item {
        padding: 14px;
        gap: 12px;
    }

    .settings-item-icon {
        width: 36px;
        height: 36px;
    }

    .settings-item-title {
        font-size: 14px;
    }

    .settings-item-desc {
        font-size: 11px;
    }

    .settings-info-row {
        padding: 10px 14px;
    }

    .settings-info-label,
    .settings-info-value {
        font-size: 12px;
    }

    /* ============================================================
       MOBILE TOASTS
       ============================================================ */
    .toast-container {
        top: auto;
        bottom: 70px;
        left: 16px;
        right: 16px;
    }

    .toast {
        min-width: auto;
        max-width: none;
        padding: 12px 14px;
        font-size: 13px;
    }

    /* ============================================================
       MOBILE NOTIFICATIONS
       ============================================================ */
    .notification-center {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .notification-header {
        padding: 14px 16px;
    }

    .notification-header h3 {
        font-size: 14px;
    }

    .notification-item {
        padding: 10px;
    }

    .notification-icon {
        width: 28px;
        height: 28px;
    }

    .notification-content strong {
        font-size: 12px;
    }

    .notification-content p {
        font-size: 11px;
    }

    /* ============================================================
       MOBILE AUTH SCREEN
       ============================================================ */
    .auth-screen {
        padding: 20px;
    }

    .auth-card {
        max-width: 100%;
        padding: 28px 20px;
        border-radius: var(--radius-lg);
    }

    .logo-shield {
        width: 52px;
        height: 58px;
    }

    .logo-chk {
        font-size: 24px;
    }

    .logo-panel {
        font-size: 15px;
    }

    .auth-tagline {
        font-size: 12px;
    }

    .auth-card input {
        padding: 14px 12px;
        font-size: 16px;
    }

    .auth-card button[type="button"] {
        padding: 16px;
        font-size: 15px;
    }

    /* ============================================================
       MOBILE HISTORY MODAL
       ============================================================ */
    .history-modal {
        padding: 20px 16px;
    }

    .history-tabs {
        gap: 6px;
        margin-bottom: 12px;
        flex-wrap: wrap;
    }

    .history-tab {
        padding: 8px 12px;
        font-size: 12px;
        flex: 1;
        text-align: center;
    }

    .history-list {
        max-height: 300px;
    }

    .history-item {
        padding: 10px;
    }

    .history-icon {
        width: 32px;
        height: 32px;
    }

    .history-content strong {
        font-size: 12px;
    }

    .history-content span {
        font-size: 10px;
    }

    .history-amount {
        font-size: 13px;
    }

    /* ============================================================
       MOBILE 2FA MODALS
       ============================================================ */
    .setup-2fa-modal .qr-wrapper,
    #setup-2fa-modal .qr-wrapper {
        width: 160px;
        height: 160px;
    }

    .setup-2fa-secret {
        padding: 12px;
    }

    .secret-code {
        font-size: 12px;
        letter-spacing: 2px;
    }

    /* ============================================================
       MOBILE FORM ELEMENTS
       ============================================================ */
    .form-group {
        margin-bottom: 14px;
    }

    .form-group label {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .form-group input,
    .form-group select {
        padding: 14px 12px;
        font-size: 16px;
    }

    .form-group small {
        font-size: 10px;
    }

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

    .form-actions .btn-secondary,
    .form-actions .btn-primary {
        width: 100%;
        justify-content: center;
    }

    /* ============================================================
       MOBILE USER DROPDOWN (inside mobile menu)
       ============================================================ */
    .user-dropdown {
        display: none !important;
    }
}

/* ============================================================
   VERY SMALL SCREENS (< 380px)
   ============================================================ */
@media (max-width: 380px) {
    html {
        font-size: 14px;
    }

    .topbar {
        padding: 0 10px;
        gap: 6px;
        height: 56px;
    }

    .topbar-brand .logo-mini-svg {
        width: 24px;
        height: 28px;
    }

    .credits-chip {
        padding: 3px 4px 3px 8px;
    }

    .credits-chip-value {
        font-size: 11px;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
    }

    .mobile-menu-btn {
        width: 32px;
        height: 32px;
    }

    .mobile-menu-btn svg {
        width: 18px;
        height: 18px;
    }

    .workspace {
        padding: 64px 10px 20px;
        gap: 14px;
    }

    .workspace-head {
        gap: 12px;
    }

    .page-title {
        font-size: 20px;
    }

    .page-subtitle {
        font-size: 12px;
    }

    .kpi-strip {
        padding: 10px 12px;
        border-radius: var(--radius-sm);
    }

    .kpi-value {
        font-size: 13px;
    }

    .kpi-label {
        font-size: 7px;
    }

    .kpi-div {
        height: 24px;
    }

    .metrics {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .metric-card {
        padding: 12px;
        border-radius: var(--radius-sm);
    }

    .metric-header {
        margin-bottom: 6px;
    }

    .metric-label {
        font-size: 8px;
    }

    .metric-icon {
        width: 22px;
        height: 22px;
    }

    .metric-icon svg {
        width: 10px;
        height: 10px;
    }

    .metric-value {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .work-grid {
        gap: 12px;
    }

    .panel {
        border-radius: var(--radius-sm);
    }

    .panel-header {
        padding: 10px 12px;
    }

    .panel-title {
        font-size: 13px;
    }

    .panel-body {
        padding: 10px 12px;
        gap: 10px;
    }

    #cards-input {
        min-height: 100px;
        font-size: 11px;
        padding: 10px;
    }

    .btn-primary {
        padding: 12px 16px;
        font-size: 14px;
    }

    .modal {
        padding: 18px 14px;
    }

    .modal-title {
        font-size: 18px;
    }

    .amount-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .amount-btn {
        padding: 10px 6px;
    }

    .amount-value {
        font-size: 14px;
    }

    .mobile-menu {
        width: 260px;
    }

    .mobile-menu-balance-value {
        font-size: 20px;
    }
}

/* ============================================================
   LANDSCAPE MOBILE
   ============================================================ */
@media (max-width: 768px) and (orientation: landscape) {
    .workspace {
        padding-top: 60px;
    }

    .metrics {
        grid-template-columns: repeat(4, 1fr);
    }

    .metric-card {
        padding: 12px;
    }

    .metric-value {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .work-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }

    .modal-overlay {
        align-items: center;
    }
}
