/* Exchange Page Styles */
.exchange-page {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Field validation error styles */
.field-error {
    border-color: #ff7675 !important;
    background-color: rgba(255, 118, 117, 0.1) !important;
}

.field-error-message {
    display: block;
    color: #ff7675;
    font-size: 12px;
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(255, 118, 117, 0.1);
    border-radius: 4px;
    border-left: 2px solid #ff7675;
}

.exchange-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 20, 40, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    margin: 8px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    display: flex;
    align-items: center;
    gap: 12px;
}

.exchange-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text, #ffffff);
    margin: 0;
    flex: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-back-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 10px;
    color: var(--text, #ffffff);
    text-decoration: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.btn-back-home:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.15);
}

.app-main {
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
}

/* Auth Notice */
.auth-notice {
    margin-bottom: 12px;
    background: rgba(108, 92, 231, 0.15);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.notice-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text, #ffffff);
}

.notice-content i {
    font-size: 20px;
    color: #6c5ce7;
}

.notice-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Balance Card */
.balance-card {
    margin-bottom: 12px;
}

/* Directions Status */
.directions-status {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    font-size: 14px;
    text-align: center;
}

.directions-status.error {
    background: rgba(255, 118, 117, 0.1);
    border-color: rgba(255, 118, 117, 0.3);
    color: #ff7675;
}

.balance-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.balance-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.balance-label {
    font-size: 12px;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.balance-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #ffffff);
}

/* Exchange Card */
.exchange-card {
    margin-bottom: 12px;
}

.exchange-form {
    margin-top: 16px;
    position: relative;
}

.btn-flip {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: rgba(108, 92, 231, 0.2);
    border: 1px solid rgba(108, 92, 231, 0.4);
    border-radius: 8px;
    color: #6c5ce7;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.btn-flip:hover {
    background: rgba(108, 92, 231, 0.3);
    border-color: rgba(108, 92, 231, 0.5);
}

.btn-flip:active {
    transform: translateY(-50%) scale(0.95);
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #ffffff);
    margin-bottom: 6px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text, #ffffff);
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    color-scheme: dark;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(108, 92, 231, 0.5);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.form-select option {
    color: #0f172a;
    background: #ffffff;
}

.amount-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.amount-input-wrapper .form-input {
    padding-right: 60px;
}

.amount-label {
    position: absolute;
    right: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    pointer-events: none;
}

.form-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
}

/* Quote Panel */
.quote-panel {
    margin-top: 16px;
    padding: 16px;
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: 12px;
}

.quote-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #6c5ce7;
}

.quote-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quote-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.quote-row.highlight {
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(108, 92, 231, 0.2);
}

.quote-label {
    color: var(--text-muted, rgba(255, 255, 255, 0.7));
}

.quote-value {
    font-weight: 600;
    color: var(--text, #ffffff);
}

.quote-row.highlight .quote-value {
    font-size: 16px;
    color: #6c5ce7;
}

.quote-errors {
    margin-top: 8px;
    padding: 8px;
    background: rgba(255, 118, 117, 0.15);
    border: 1px solid rgba(255, 118, 117, 0.3);
    border-radius: 8px;
    font-size: 12px;
    color: #ff7675;
}

.quote-errors ul {
    margin: 0;
    padding-left: 20px;
}

.quote-errors li {
    margin: 4px 0;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #6c5ce7 0%, #5a4fcf 100%);
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: 16px;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #7b6ff0 0%, #6a5fe0 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

/* History Card */
.history-card {
    margin-bottom: 12px;
}

.history-content {
    margin-top: 12px;
}

.history-placeholder {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
}

.history-placeholder i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.history-placeholder p {
    margin: 0;
    font-size: 14px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-direction {
    font-weight: 600;
    color: var(--text, #ffffff);
}

.history-date {
    font-size: 11px;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
}

.history-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.history-amount {
    font-weight: 700;
    color: #6c5ce7;
}

.history-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(108, 92, 231, 0.2);
    color: #6c5ce7;
}

.history-status.completed {
    background: rgba(0, 184, 148, 0.2);
    color: #00b894;
}

/* Admin Panel Styles */
.admin-panel {
    margin-top: 12px;
}

.admin-card {
    margin-bottom: 12px;
    border: 1px solid rgba(108, 92, 231, 0.3);
    background: rgba(108, 92, 231, 0.05);
}

.admin-card .card-title {
    color: #6c5ce7;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-list {
    margin-top: 12px;
}

.admin-loading,
.admin-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
    font-size: 14px;
}

/* Admin Direction Item */
.admin-direction-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin-bottom: 8px;
}

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

.admin-direction-pair {
    font-weight: 700;
    font-size: 16px;
    color: var(--text, #ffffff);
}

.admin-direction-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.admin-direction-status.enabled {
    background: rgba(0, 184, 148, 0.2);
    color: #00b894;
}

.admin-direction-status.disabled {
    background: rgba(255, 118, 117, 0.2);
    color: #ff7675;
}

.admin-direction-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.admin-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.admin-detail-row span:first-child {
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

.admin-detail-row span:last-child {
    color: var(--text, #ffffff);
    font-weight: 600;
}

.btn-admin-edit {
    width: 100%;
    padding: 8px;
    background: rgba(108, 92, 231, 0.2);
    border: 1px solid rgba(108, 92, 231, 0.4);
    border-radius: 8px;
    color: #6c5ce7;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-admin-edit:hover {
    background: rgba(108, 92, 231, 0.3);
    border-color: rgba(108, 92, 231, 0.5);
}

/* Admin Withdrawal Item */
.admin-withdrawal-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin-bottom: 8px;
}

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

.admin-withdrawal-id {
    font-weight: 700;
    font-size: 14px;
    color: var(--text, #ffffff);
}

.admin-withdrawal-status {
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.admin-withdrawal-status.pending {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.admin-withdrawal-status.approved {
    background: rgba(0, 184, 148, 0.2);
    color: #00b894;
}

.admin-withdrawal-status.rejected {
    background: rgba(255, 118, 117, 0.2);
    color: #ff7675;
}

.admin-withdrawal-status.paid {
    background: rgba(108, 92, 231, 0.2);
    color: #6c5ce7;
}

.admin-withdrawal-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.admin-withdrawal-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-admin-mark-paid,
.btn-admin-reject {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
}

.btn-admin-mark-paid {
    background: rgba(0, 184, 148, 0.2);
    border: 1px solid rgba(0, 184, 148, 0.4);
    color: #00b894;
}

.btn-admin-mark-paid:hover {
    background: rgba(0, 184, 148, 0.3);
    border-color: rgba(0, 184, 148, 0.5);
}

.btn-admin-reject {
    background: rgba(255, 118, 117, 0.2);
    border: 1px solid rgba(255, 118, 117, 0.4);
    color: #ff7675;
}

.btn-admin-reject:hover {
    background: rgba(255, 118, 117, 0.3);
    border-color: rgba(255, 118, 117, 0.5);
}

/* Responsive */
@media (max-width: 480px) {
    .exchange-header {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top, 10px));
    }

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

    .balance-content {
        grid-template-columns: 1fr;
    }

    .btn-flip {
        right: 4px;
    }

    .admin-withdrawal-actions {
        flex-direction: column;
    }
}

/* TON Settings Styles */
.ton-settings-content {
    padding: 16px;
}

.ton-settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ton-settings-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ton-settings-form label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.ton-settings-form .form-select {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 8px;
    color: var(--text, #ffffff);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.ton-settings-form .form-select:focus {
    border-color: var(--accent, #6366f1);
    background: rgba(255, 255, 255, 0.08);
}

.ton-status-content {
    margin-top: 20px;
}

.ton-status-box {
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ton-status-box.ton-status-ok {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.05);
}

.ton-status-box.ton-status-error {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.ton-status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.ton-status-header i {
    font-size: 18px;
}

.ton-status-ok .ton-status-header {
    color: #22c55e;
}

.ton-status-error .ton-status-header {
    color: #ef4444;
}

.ton-status-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ton-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ton-status-item:last-child {
    border-bottom: none;
}

.ton-status-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.ton-status-value {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-all;
    text-align: right;
}

.ton-status-missing,
.ton-status-next-steps {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ton-status-missing strong,
.ton-status-next-steps strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.ton-status-missing ul,
.ton-status-next-steps ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.ton-status-missing li,
.ton-status-next-steps li {
    margin: 4px 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}
