/* Mobile Optimizations for DeQrypto */
.new-mobile-logo-img {
    display: none;
}

/* Viewport and Touch Improvements */
@media (max-width: 1260px) {
    .header-nav {
        gap: 30px;
    }
}

@media (max-width: 1200px) {

    /* Better touch targets */
    .btn,
    .btn-launch-terminal,
    .auth-btn,
    .icon-btn {
        min-width: 44px;
        min-height: 38px;
    }

    /* Prevent zoom on input focus (iOS) */
    input,
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Compact header for mobile */
    .header {
        padding: 5px 15px;
    }

    .logo span {
        display: none;
        /* Hide "DASHBOARD" text on mobile */
    }

    /* Stack action buttons vertically on mobile */
    .header-right {
        gap: 8px;
    }

    /* Full-width modals on mobile */
    .modal {
        width: 95%;
        max-height: 90vh;
    }

    /* Better modal scrolling */
    .modal {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Exchange settings form on mobile */
    .exchange-section {
        padding: 15px;
    }

    .exchange-form {
        padding: 15px;
    }

    /* Input fields full width on mobile */
    input,
    textarea,
    select {
        width: 100%;
    }

    /* Better table scrolling on mobile */
    .portfolio-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 200px;
        /* Force horizontal scroll */
    }

    /* Compact stats cards */
    .stat-card {
        padding: 10px;
    }

    .stat-value {
        font-size: 20px;
    }

    /* Touch-friendly chart interactions */
    canvas {
        touch-action: pan-y;
    }

    /* Bottom spacing for iOS home indicator */
    body {
        padding-bottom: 60px;
    }

    /* Hide scrollbars but keep functionality */
    .portfolio-table-container::-webkit-scrollbar {
        display: none;
    }

    /* Stack pricing cards on mobile */
    .pricing-grid {
        grid-template-columns: 1fr !important;
    }

    /* Better homepage hero on mobile */
    .hero h1 {
        font-size: 36px !important;
        line-height: 1.2;
    }

    .hero p {
        font-size: 16px !important;
    }
}

@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr !important;
    }

    .left-panel,
    .right-panel {
        margin: 10px !important;
    }

    .right-panel {
        margin-top: 0 !important;
    }
}

@media (max-width: 992px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .right-panel {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .pv-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .cycle-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .performance-stats {
        grid-template-columns: 1fr;
    }

    .header-nav {
        display: none;
    }

    .portfolio-summary {
        padding: 16px;
    }

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

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel-section {
        padding: 16px;
    }

    .cycle-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cycle-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .welcome-title {
        font-size: 34px;
    }

    .welcome-subtitle {
        font-size: 16px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    #allocationChart {
        max-height: 220px;
    }

    .progress-bar-container {
        width: 80%;
    }

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

    .analytics-grid-main,
    .analytics-grid-bottom,
    .history-grid {
        grid-template-columns: 1fr;
    }

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

    .tr-two-col {
        grid-template-columns: 1fr;
    }

    .how-steps {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .how-arrow,
    .log-table th:nth-child(4),
    .log-table td:nth-child(4),
    .log-table th:nth-child(5),
    .log-table td:nth-child(5) {
        display: none;
    }

    .heatmap-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .page-section {
        padding: 16px 12px;
    }

    .analytics-card {
        padding: 14px 12px;
        min-width: 200px;
    }

    .signal-table {
        font-size: 11px;
    }

    .signal-table th {
        padding: 0 6px 8px;
        font-size: 9px;
    }

    .signal-table td {
        padding: 7px 6px;
    }

    .signal-timeline {
        padding-left: 14px;
    }

    .hero h1 {
        font-size: 38px;
    }

    .stat-number {
        font-size: 34px;
    }

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

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .pricing-grid {
        grid-template-columns: 1fr;
    }

    .nav-buttons {
        gap: 8px;
    }

    .btn,
    .btn-launch-terminal {
        padding: 8px 16px;
        font-size: 13px;
    }

    #refreshText,
    #authBtnText,
    #terminalBtnText {
        display: none;
    }

    .refresh-btn {
        position: relative;
        height: 36px;
        width: 36px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0px;
    }

    .refresh-btn .refresh-icon {
        display: block;
    }

    .refresh-btn .terminal-icon {
        display: block;
    }

    .refresh-btn.loading .refresh-icon {
        animation: spinRefresh 1s linear infinite;
    }

    @keyframes spinRefresh {
        from {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(360deg);
        }
    }

    .btn-launch-terminal .btn-text,
    .btn-get-started .btn-text {
        display: none;
    }

    /* Auth button — icon only on mobile */
    .auth-btn,
    .btn-launch-terminal,
    .btn-get-started {
        width: 36px;
        height: 36px;
        padding: 0;
        min-width: unset;
        justify-content: center;
    }

    /* Avatar button — initials only on mobile, hide name and chevron */
    #avatarBtnName,
    .avatar-chevron {
        display: none;
    }

    .avatar-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
        border: none;
        background: transparent;
    }

    .avatar-initials {
        width: 44px;
        height: 38px;
        font-size: 12px;
    }

    /* Show account icon when logged in on mobile */
    .auth-btn.logged-in .auth-icon-loggedin {
        display: inline-block;
    }

    .footer>div:first-child {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 32px 0;
    }

    .footer-section:first-child {
        padding-bottom: 20px;
        margin-bottom: 4px;
    }

    .footer-section:not(:first-child) {
        border-top: 1px solid var(--border-color);
    }

    .footer-section-trigger {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: none;
        border: none;
        padding: 14px 0;
        cursor: pointer;
        outline: none;
    }

    .footer-section-trigger h4 {
        margin-bottom: 0;
    }

    .footer-section-trigger svg {
        color: var(--text-tertiary);
        transition: transform 0.2s;
        flex-shrink: 0;
    }

    .footer-section-trigger.open svg {
        transform: rotate(180deg);
    }

    .footer-section:not(:first-child)>h4 {
        display: none;
    }

    .footer-links {
        display: none;
        padding-bottom: 14px;
    }

    .footer-links.open {
        display: flex;
    }

    .how-banner {
        flex-direction: column;
    }

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

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

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

@media (max-width: 580px) {

    .user-balance>span:first-child {
        display: none;
    }

    .info-icon .tooltip {
        left: auto;
        right: 0;
        transform: none;
        max-width: 260px;
    }

    .info-icon .tooltip::after {
        left: auto;
        right: 10px;
        transform: none;
    }
}

@media (max-width: 500px) {

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

    td,
    .log-table td {
        font-size: 11px;
    }

    .new-logo-img {
        display: none;
    }

    .new-mobile-logo-img {
        display: block;
        width: 60px;
        height: auto;
        object-fit: contain;
        background: transparent;
        margin-left: -20px;
    }

    .success-logo {
        width: 80px;
        margin-bottom: 28px;
    }

    .user-balance {
        display: none;
    }

    .update-label {
        display: none;
    }

    .new-logo-img {
        width: 170px;
    }

    .tr-header-top {
        flex-direction: column;
    }

    .page-section {
        padding: 20px 14px;
    }

    .ps-nav {
        padding: 12px 16px;
    }

    .ps-card {
        padding: 32px 20px;
    }

    .avatar-dropdown {
        width: 260px;
    }

    .footer-connect-divider {
        display: none;
    }
    .footer-connect-row {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

@media (max-width: 380px) {
    .heatmap-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .cycle-info-value {
        font-size: 12px;
    }

    .cycle-info-label {
        font-size: 10px;
    }

    .cycle-modal-body,
    .cycle-modal-header {
        padding: 20px 10px;
    }
}

@media (max-width: 360px) {

    /* Stack CTA buttons on mobile */
    .hero .cta {
        flex-direction: column;
        gap: 12px;
    }

    .hero .cta .btn,
    .hero .cta .btn-primary {
        width: 100%;
    }

    .summary-header {
        flex-direction: column-reverse;
        align-items: flex-start;
    }

    .time-updated {
        margin-bottom: 20px;
    }
}

/* PWA-specific improvements */

/* Hide Safari UI chrome when installed as PWA */
@media (display-mode: standalone) {
    body {
        /* App-like experience */
        padding-top: env(safe-area-inset-top);
    }

    /* Add status bar spacing on iOS */
    .header {
        padding-top: calc(env(safe-area-inset-top) + 5px);
    }
}

/* Touch gesture improvements */

/* Prevent pull-to-refresh on iOS when scrolling */
body {
    overscroll-behavior-y: contain;
}

/* Better button press states */
.btn:active,
.btn-launch-terminal:active,
.auth-btn:active,
.icon-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Keyboard optimization (iOS) */

/* When keyboard is open, adjust viewport */
@supports (height: 100dvh) {
    .modal {
        max-height: 100dvh;
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        height: 60px;
    }

    .modal {
        max-height: 85vh;
    }
}