/* ROBOTRADING AI — global responsive layout for mobile, tablet, laptop, desktop */

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

/* ----- HEADER NAV (market, wallet, deposit, etc.) ----- */
.rt-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(0, 195, 255, 0.25);
    border-radius: 12px;
    background: #111c33;
    color: #00c3ff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

header {
    gap: 12px;
}

header .logo {
    flex: 1;
    min-width: 0;
}

header .logo-text,
.sidebar-logo-text {
    word-break: break-word;
}

/* ----- CONTENT & GRIDS ----- */
.content-container,
.main-content,
.page-content {
    width: min(100%, 1400px);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(12px, 3vw, 40px);
    padding-right: clamp(12px, 3vw, 40px);
}

.cards-grid,
.wallets-grid,
.benefits-grid,
.actions-grid,
.matrix-grid,
.history-stats {
    gap: clamp(10px, 2vw, 20px);
}

.section-box,
.history-table-wrap,
.rt-table-wrap,
table {
    max-width: 100%;
}

.section-box,
.history-table-wrap,
.rt-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----- MARKET PAGE ----- */
.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-workspace {
    width: 100%;
    min-height: 0;
}

.chart-workspace {
    min-width: 0;
}

.ticker-header {
    flex-wrap: wrap;
    gap: 10px;
}

.ticker-name {
    font-size: clamp(18px, 4vw, 24px);
}

.ticker-price {
    font-size: clamp(22px, 5vw, 30px);
}

.trade-history-section {
    width: auto;
    max-width: 100%;
}

/* ----- DASHBOARD SIDEBAR LAYOUT ----- */
.main {
    min-width: 0;
}

.content-container {
    padding-bottom: 24px;
}

/* ----- STATUS BAR (avoid cut-off) ----- */
.status-bar {
    flex-shrink: 0;
}

body.has-fixed-status .main,
body.has-fixed-status .page-shell,
body.has-fixed-status {
    padding-bottom: 56px;
}

/* ----- FORMS & BUTTONS ----- */
input,
select,
textarea,
.trade-input,
.search-box {
    max-width: 100%;
}

button,
.trade-btn,
.nav-buttons button,
.menu button {
    min-height: 44px;
}

/* ----- TABLET (768px – 1024px) ----- */
@media (max-width: 1024px) {
    header {
        height: auto;
        min-height: 72px;
        padding: 12px clamp(12px, 3vw, 24px);
        flex-wrap: wrap;
        align-items: center;
    }

    header .nav-buttons,
    header .nav-links {
        gap: 8px;
    }

    header .nav-buttons button,
    header .nav-links a {
        min-height: 44px;
    }

    .main-workspace {
        grid-template-columns: 260px 1fr 280px;
        padding: 12px;
    }

    .matrix-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .top-header {
        height: auto;
        padding: 16px clamp(12px, 3vw, 24px);
        flex-wrap: wrap;
        gap: 12px;
    }

    .user-info-bar {
        flex-wrap: wrap;
        gap: 12px;
    }

    /* Dashboard: sidebar becomes top scroll menu */
    body.rt-sidebar-layout {
        flex-direction: column;
    }

    body.rt-sidebar-layout .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(0, 195, 255, 0.1);
        padding: 16px;
        gap: 16px;
    }

    body.rt-sidebar-layout .sidebar .menu {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        gap: 8px;
    }

    body.rt-sidebar-layout .sidebar .menu button {
        width: auto;
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 13px;
        min-height: 44px;
    }

    body.rt-sidebar-layout .sidebar .menu button:hover,
    body.rt-sidebar-layout .sidebar .menu button.active {
        transform: none;
        border-left: none;
        border-bottom: 3px solid #00c3ff;
    }

    body.rt-sidebar-layout .main {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ----- MOBILE & SMALL TABLET (max 768px) ----- */
@media (max-width: 768px) {
    .rt-nav-toggle {
        display: inline-flex;
    }

    header {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "logo toggle"
            "nav nav";
        align-items: center;
    }

    header .logo {
        grid-area: logo;
    }

    header .rt-nav-toggle {
        grid-area: toggle;
    }

    header .nav-buttons,
    header .nav-links {
        grid-area: nav;
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 8px;
        padding-top: 4px;
    }

    header.rt-nav-open .nav-buttons,
    header.rt-nav-open .nav-links {
        display: flex;
    }

    header .nav-buttons button,
    header .nav-links a {
        width: 100%;
        min-width: 0;
        text-align: center;
    }

    header .logo-text {
        font-size: 18px;
    }

    /* Deposit / withdraw / workspace pages */
    .workspace {
        min-width: 0;
    }

    body header {
        height: auto !important;
        min-height: 72px;
    }

    .workspace {
        display: block !important;
        height: auto !important;
        min-height: auto !important;
    }

    .workspace > .sidebar {
        display: none !important;
    }

    .workspace > .main-panel {
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px 15px !important;
        overflow-x: hidden;
    }

    .balance-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .main-workspace {
        grid-template-columns: 1fr !important;
        padding: 10px;
        gap: 12px;
        min-height: auto;
    }

    .coin-sidebar,
    .trade-panel {
        position: static !important;
        max-height: none !important;
        height: auto !important;
    }

    .coin-list {
        max-height: 280px;
    }

    .chart-box {
        min-height: 360px;
        height: 52vh;
    }

    .orderbook-box {
        max-height: 220px;
    }

    .trade-history-section {
        margin: 10px;
        padding: 16px;
    }

    .history-header {
        flex-direction: column;
        align-items: stretch;
    }

    .history-filters {
        width: 100%;
    }

    .history-filters button {
        flex: 1;
    }

    .history-stats {
        grid-template-columns: 1fr !important;
    }

    .cards-grid,
    .wallets-grid,
    .matrix-grid,
    .benefits-grid,
    .actions-grid {
        grid-template-columns: 1fr !important;
    }

    .content-container {
        width: 100%;
        margin-top: 16px;
        margin-bottom: 16px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .page-title h1,
    .dashboard-title h1 {
        font-size: clamp(20px, 6vw, 28px);
    }

    .top-header {
        position: relative;
    }

    .user-info-bar {
        width: 100%;
    }

    .user-detail-item {
        min-width: calc(50% - 8px);
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 12px;
        white-space: nowrap;
    }

    .matrix-box h2,
    .panel-title {
        font-size: 14px;
    }

    .card .amount {
        font-size: clamp(20px, 6vw, 28px);
    }
}

/* ----- SMALL PHONES (max 480px) ----- */
@media (max-width: 480px) {
    header {
        padding: 10px 12px;
    }

    .brand-logo,
    .sidebar-brand-logo {
        width: 38px;
        height: 38px;
    }

    .logo-text,
    .sidebar-logo-text {
        font-size: 16px !important;
    }

    .nav-buttons button,
    .menu button {
        font-size: 12px;
        padding: 10px 12px;
    }

    .chart-box {
        min-height: 300px;
        height: 48vh;
    }

    .ticker-header {
        padding: 14px 16px;
    }

    .trade-container,
    .coin-sidebar,
    .trade-panel {
        padding: 12px;
    }

    .status-bar {
        padding: 10px 12px;
        font-size: 11px;
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* ----- LARGE DESKTOP (1400px+) ----- */
@media (min-width: 1400px) {
    .main-workspace {
        grid-template-columns: 300px minmax(0, 1fr) 340px;
    }

    .content-container {
        max-width: 1440px;
    }
}
