/* ============================================
   MOBILE ADAPTATION - Deploy & Run Only
   Breakpoint: 768px
   ============================================ */

@media (max-width: 768px) {

    /* === BODY === */
    body {
        overflow: auto;
        font-size: 14px;
    }

    .remix-container {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* === HEADER - compact === */
    .remix-header {
        height: 44px;
        padding: 0 12px;
    }

    .header-center {
        display: none;
    }

    .logo-text {
        font-size: 14px;
    }

    .header-right {
        gap: 6px;
    }

    .network-badge {
        font-size: 11px;
        padding: 3px 6px;
    }

    .proxy-status {
        display: none;
    }

    .security-warning-banner {
        display: none;
    }

    /* === HIDE desktop-only elements === */
    .remix-icon-panel,
    .vertical-resizer,
    .horizontal-resizer,
    .right-section,
    .remix-editor,
    .remix-terminal {
        display: none !important;
    }

    /* === MAIN LAYOUT - vertical on mobile === */
    .remix-main {
        flex-direction: column;
        overflow: auto;
    }

    .main-content {
        flex-direction: column;
        overflow: visible;
    }

    /* === SIDEBAR - fullwidth === */
    .remix-sidebar {
        width: 100% !important;
        min-width: 0;
        max-width: 100%;
        border-right: none;
        overflow: visible;
        flex-shrink: 0;
    }

    /* === HIDE all plugins except Deploy === */
    .plugin-content {
        display: none !important;
    }

    .plugin-content[data-content="udapp"] {
        display: flex !important;
        overflow: visible;
    }

    /* === PLUGIN HEADER === */
    .plugin-header {
        padding: 12px 16px;
    }

    .plugin-header h3 {
        font-size: 15px;
    }

    /* === DEPLOY FORM === */
    .deploy-config {
        overflow: visible;
        padding-bottom: 20px;
    }

    .deploy-form-section {
        padding: 12px 16px;
    }

    .form-group {
        margin-bottom: 14px;
    }

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

    .form-control {
        height: 44px;
        font-size: 14px;
        padding: 8px 12px;
        border-radius: 8px;
    }

    select.form-control {
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23999'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 32px;
    }

    .account-balance {
        font-size: 13px;
        margin-top: 6px;
        padding: 6px 10px;
    }

    /* === API KEY INPUT === */
    #api-key-input {
        height: 44px;
        font-size: 15px !important;
        letter-spacing: 2px !important;
    }

    /* === DEPLOY BUTTON === */
    .deploy-button {
        height: 48px !important;
        font-size: 15px !important;
        border-radius: 10px !important;
        margin-top: 8px;
    }

    /* === PRIVATE KEY SECTION === */
    .private-key-section {
        padding: 12px;
        border-radius: 8px;
    }

    .private-key-input {
        height: 44px;
        font-size: 14px;
    }

    #connect-private-key-btn {
        height: 44px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* === DEPLOYED CONTRACTS === */
    .deployed-contracts {
        padding: 12px 16px;
    }

    .deployed-contracts h4 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .contract-address-input {
        flex-direction: column;
        gap: 8px;
    }

    .contract-address-input input {
        height: 44px;
        font-size: 14px;
    }

    .contract-address-input button {
        height: 44px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* === CONTRACT ITEMS === */
    .contract-item {
        border-radius: 8px;
        margin-bottom: 10px;
    }

    .contract-item-header {
        padding: 12px;
        min-height: 44px;
    }

    /* === FUNCTION BUTTONS - touch friendly === */
    .function-item,
    .function-item-horizontal {
        margin-bottom: 8px;
    }

    .function-button {
        min-height: 44px !important;
        font-size: 13px !important;
        padding: 8px 16px !important;
        border-radius: 8px !important;
    }

    .function-item-horizontal {
        flex-direction: column;
        gap: 8px;
    }

    .function-inputs-horizontal {
        width: 100%;
    }

    .function-param-input {
        height: 44px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }

    .function-result {
        font-size: 12px;
        padding: 10px;
        border-radius: 8px;
        word-break: break-all;
    }

    /* === MOBILE TERMINAL (bottom sheet) === */
    .mobile-terminal {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #1e1e1e;
        border-top: 2px solid #3e3e42;
        max-height: 50vh;
        transition: transform 0.3s ease;
    }

    .mobile-terminal.collapsed {
        transform: translateY(calc(100% - 36px));
    }

    .mobile-terminal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 12px;
        background: #2d2d30;
        cursor: pointer;
        min-height: 36px;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-terminal-header span {
        font-size: 12px;
        color: #aaa;
    }

    .mobile-terminal-toggle {
        font-size: 14px;
        color: #aaa;
    }

    .mobile-terminal-content {
        overflow-y: auto;
        max-height: calc(50vh - 36px);
        padding: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-terminal-content .terminal-log {
        font-size: 12px;
        padding: 4px 0;
        word-break: break-all;
    }

    /* === Bottom padding for terminal bar === */
    .deploy-config {
        padding-bottom: 50px;
    }

    /* === MODALS - fullscreen on mobile === */
    .modal {
        padding: 0 !important;
    }

    .modal-content,
    .security-modal-content,
    .wallet-install-content {
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal-content {
        padding: 20px 16px !important;
    }

    /* === VALUE / WEI SECTION === */
    .value-section {
        flex-direction: column;
    }

    .value-section select,
    .value-section input {
        height: 44px;
        font-size: 14px;
    }

    /* === GAS LIMIT - hide on mobile === */
    .form-group:has(input[type="number"][value="3000000"]) {
        display: none;
    }

    /* === CONSTRUCTOR PARAMS === */
    .constructor-params .param-inputs input {
        height: 44px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* === CONNECTION STATUS === */
    #connection-status {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 8px;
    }
}

/* === SMALL PHONES (< 380px) === */
@media (max-width: 380px) {
    .remix-header {
        padding: 0 8px;
    }

    .logo-text {
        font-size: 12px;
    }

    .network-badge {
        font-size: 10px;
        padding: 2px 5px;
    }

    .deploy-form-section {
        padding: 10px 12px;
    }

    .function-button {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
}
