/* Base styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

:root {
    --primary-color: #00CED1;
    --primary-light: #e0f7fa;
    --primary-dark: #00BCD4;
    --text-color: #333;
    --light-gray: #f5f5f5;
    --medium-gray: #e0e0e0;
    --dark-gray: #888;
    --white: #fff;
    --transition: all 0.3s ease;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
}

body {
    background-color: var(--light-gray);
    color: var(--text-color);
    line-height: 1.6;
    /* Ensure no horizontal scroll on mobile */
    overflow-x: hidden;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 10px; /* Reduced padding for tighter mobile fit */
}

/* Total Assets section */
.total-assets {
    background-color: #e0f7fa;
    color: black;
    padding: 15px; /* Reduced padding for mobile compactness */
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 15px;
    margin-top: 15px;
    text-align: center;
}

.total-assets h2 {
    font-size: 16px; /* Slightly smaller for mobile */
    font-weight: 500;
    margin-bottom: 8px;
    text-align: center;
}

.total-amount {
    font-size: 28px; /* Adjusted for better mobile readability */
    font-weight: 700;
    margin-bottom: 5px;
}

.total-usd {
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

#country-currency-code {
    font-size: 22px;
    font-weight: 600;
    margin-left: 6px;
}

.currency {
    font-weight: 500;
    margin-left: 5px;
}

/* Action buttons */
.action-buttons {
    display: flex;
    flex-direction: row; /* Keep row layout but adjust spacing */
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 10px; /* Reduced gap for tighter spacing */
}

.btn {
    background-color: var(--white);
    border: 2px solid var(--primary-color);
    color: var(--text-color);
    padding: 10px 15px; /* Smaller padding for mobile */
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    transition: var(--transition);
    font-weight: 500;
    text-align: center;
    box-shadow: var(--shadow);
    /* Larger touch target for mobile */
    min-height: 48px;
    font-size: 14px;
}

.btn i {
    margin-bottom: 5px;
    font-size: 18px;
    color: var(--primary-color);
    transition: var(--transition);
}

.btn:hover {
    background-color: var(--primary-light);
    transform: translateY(-3px);
}

/* Balance card */
.balance-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.currency-type {
    background-color: var(--primary-light);
    padding: 8px 12px; /* Reduced padding for mobile */
    font-weight: 600;
    border-bottom: 1px solid var(--medium-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px; /* Smaller font for mobile */
}

#balance-currency-selector {
    margin-left: auto;
}

.balance-details {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap; /* Allow wrapping on very small screens */
}

.balance-item {
    flex: 1;
    text-align: center;
    padding: 15px 8px; /* Reduced padding */
    border-right: 1px solid var(--medium-gray);
    min-width: 100px; /* Ensure minimum width for readability */
}

.balance-item:last-child {
    border-right: none;
}

.balance-item .amount {
    font-size: 18px; /* Smaller for mobile */
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 5px;
}

.balance-item .label {
    font-size: 11px; /* Smaller for mobile */
    color: var(--dark-gray);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-modal:hover {
    color: #000;
}

.modal-body {
    text-align: left;
}

.modal-body h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.modal-body h4 {
    color: #333;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.modal-body i {
    font-size: 40px; /* Slightly smaller for mobile */
    color: var(--primary-color);
    margin-bottom: 15px;
}

.modal-body p {
    margin-bottom: 15px;
    font-size: 16px; /* Smaller text for mobile */
}

.close-btn {
    display: inline-block;
    margin-top: 10px;
}

#withdraw-frame {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none;
}

/* Transaction History Section */
.transaction-history {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-top: 15px;
    margin-bottom: 20px;
    overflow: hidden;
}

.section-header {
    background-color: var(--primary-light);
    padding: 12px 15px; /* Reduced padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--medium-gray);
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 10px;
}

.section-header h2 {
    font-size: 16px; /* Smaller for mobile */
    font-weight: 600;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px; /* Reduced gap */
    width: 100%; /* Full width on mobile for better spacing */
}

#transaction-type-filter {
    padding: 6px 8px; /* Smaller padding */
    border: 1px solid var(--medium-gray);
    border-radius: 4px;
    font-size: 13px; /* Smaller font */
    background-color: var(--white);
    flex: 1; /* Take full available width */
}

.refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-color);
    padding: 5px;
    border-radius: 4px;
    transition: var(--transition);
    min-width: 40px; /* Touch-friendly size */
    min-height: 40px;
}

.refresh-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.refresh-btn.loading i {
    animation: spin 1s infinite linear;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.transaction-table-container {
    overflow-x: auto;
    padding: 0;
}

.transaction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px; /* Smaller font for mobile */
}

.transaction-table th,
.transaction-table td {
    padding: 8px 10px; /* Reduced padding */
    text-align: left;
    border-bottom: 1px solid var(--medium-gray);
}

.transaction-table th {
    background-color: var(--light-gray);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.transaction-table tr:last-child td {
    border-bottom: none;
}

.transaction-table tr:nth-child(even) {
    background-color: var(--light-gray);
}

.transaction-table tr:hover {
    background-color: var(--primary-light);
}

.transaction-type {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.transaction-type i {
    font-size: 12px;
}

.type-deposit {
    color: #2ecc71; /* Green */
}

.type-withdrawal {
    color: #e74c3c; /* Red */
}

.type-trade {
    color: #3498db; /* Blue */
}

.transaction-amount {
    font-weight: 500;
}

.amount-positive {
    color: #2ecc71;
}

.amount-negative {
    color: #e74c3c;
}

.transaction-status {
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px; /* Smaller for mobile */
    display: inline-block;
}

.status-completed {
    background-color: #d5f5e3;
    color: #27ae60;
}

.status-pending {
    background-color: #fef9e7;
    color: #f39c12;
}

.status-failed {
    background-color: #fadbd8;
    color: #c0392b;
}

.loading-row td {
    text-align: center;
    color: var(--dark-gray);
    padding: 20px 10px; /* Reduced padding */
}

.no-transactions-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 0; /* Reduced padding */
    color: var(--dark-gray);
}

/* Withdrawal Modal Styles */
.withdrawal-modal {
    padding: 20px;
}

.payment-section {
    margin-bottom: 30px;
}

.payment-method-selection {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 206, 209, 0.1);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    color: #333;
    padding: 12px 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
    background-color: white;
    border: 2px solid transparent;
}

.radio-label:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
}

.radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
}

.radio-label input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.payment-card-section,
.bank-account-section {
    margin-bottom: 20px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    transition: all 0.3s ease;
}

.payment-card-section:hover,
.bank-account-section:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 206, 209, 0.15);
}

.no-info-message {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    border-radius: 10px;
    border: 2px dashed #ffc107;
}

.no-info-message p {
    color: #856404;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.info-form {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--primary-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 206, 209, 0.1);
}

.save-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 206, 209, 0.3);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 206, 209, 0.4);
}

.withdrawal-details-section {
    margin-top: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px solid var(--primary-color);
}

.balance-display {
    display: flex;
    justify-content: space-between;
    margin: 25px 0;
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.balance-item {
    flex: 1;
    text-align: center;
    padding: 10px;
}

.balance-item span:first-child {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.balance-amount {
    font-size: 22px;
    font-weight: 700;
}

.balance-item.available .balance-amount {
    color: #28a745;
    text-shadow: 0 0 10px rgba(40, 167, 69, 0.2);
}

.balance-item.frozen .balance-amount {
    color: #6c757d;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 206, 209, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 206, 209, 0.4);
}

.no-transactions-message i {
    font-size: 30px; /* Smaller icon */
    margin-bottom: 10px;
    opacity: 0.5;
}

.pagination {
    display: flex;
    justify-content: center;
    padding: 10px; /* Reduced padding */
    border-top: 1px solid var(--medium-gray);
}

#load-more-btn {
    padding: 6px 18px; /* Smaller padding */
    background-color: var(--primary-light);
    margin-top: 0;
    min-width: 48px; /* Touch-friendly size */
    min-height: 36px;
}

#load-more-btn:hover {
    background-color: var(--primary-color);
}

#load-more-btn.loading {
    position: relative;
    color: transparent;
}

#load-more-btn.loading::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin-top: -7px;
    margin-left: -7px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--text-color);
    animation: spin 0.8s linear infinite;
}

/* Transaction Description Popup Styles */
.description-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: auto;
}

.description-popup.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 400px; /* Smaller max-width for mobile */
    position: relative;
    padding: 15px; /* Reduced padding */
    animation: popup-fade-in 0.3s ease;
}

@keyframes popup-fade-in {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 10px; /* Adjusted for mobile */
    font-size: 20px;
    cursor: pointer;
    color: var(--dark-gray);
    transition: var(--transition);
    min-width: 40px; /* Touch-friendly */
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-popup:hover {
    color: var(--text-color);
}

.popup-content h3 {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--medium-gray);
    color: var(--text-color);
    font-size: 16px; /* Smaller for mobile */
}

.popup-body {
    max-height: 250px; /* Reduced height for mobile */
    overflow-y: auto;
    padding: 5px 0;
}

.popup-body p {
    line-height: 1.5;
    color: var(--text-color);
    white-space: pre-line;
}

/* Clickable description styling */
.clickable-description {
    cursor: pointer;
    color: var(--primary-dark);
    transition: var(--transition);
}

.clickable-description:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

.clickable-description i {
    margin-right: 4px;
}

/* Special status styling for rejected transactions */
.status-rejected {
    background-color: #fadbd8;
    color: #c0392b;
}
.status-approved {
    background-color: #d5f5e3;
    color: #27ae60;
}
/* --- Improved Recharge Modal Styles --- */
#recharge-modal {
    /* Keep initial state as display: none */
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: auto;
    /* Flexbox centering */
    align-items: center;
    justify-content: center;
}

/* Remove the #recharge-modal.modal selector that was causing issues */
/* When we want to show the modal, we'll use style.display = 'flex' in JS */

#recharge-modal .modal-content {
    background-color: #e0f7fa;  /* Light cyan background */
    margin: 0;
    position: relative;
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    padding: 30px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    height: auto;
    min-height: unset;
    max-height: unset;
    text-align: center;
}

#recharge-modal .close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
    background-color: #00CED1;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#recharge-modal .modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 0;
    min-height: unset;
    max-height: unset;
    background: transparent;
    box-shadow: none;
}

#recharge-modal .modal-body i.fa-lock {
    font-size: 36px;
    color: #00CED1;
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

#recharge-modal .modal-body p {
    font-size: 16px;
    color: #333;
    margin: 0;
    padding: 0;
}

#recharge-modal .modal-body .close-btn {
    background: #eed132;
    color: #222;
    border: none;
    border-radius: 24px;
    padding: 10px 40px;
    font-weight: 600;
    font-size: 15px;
    margin: 0;
    box-shadow: none;
    transition: background 0.2s;
}

#recharge-modal .modal-body .close-btn:hover {
    background: #00BCD4;
}

#recharge-modal .modal-body .fa-lock {
    animation: bounceIn 0.7s;
}
@keyframes bounceIn {
    0% { transform: scale(0.7); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

#recharge-modal .modal-body {
    background: #e0f7fa;
    border-radius: 14px;
    padding: 18px 10px 10px 10px;
    box-shadow: 0 2px 8px rgba(0, 206, 209, 0.08);
}
#recharge-modal .modal-body .fa-lock {
    margin-bottom: 6px;
}
#recharge-modal .modal-body p {
    margin-bottom: 0;
}
#recharge-modal .modal-body .close-btn {
    margin-top: 18px;
}

/* Responsive styles with strict mobile rules */
@media (max-width: 768px) {
    .container {
        padding: 0 8px; /* Even tighter padding */
    }

    .action-buttons {
        flex-wrap: wrap; /* Allow buttons to wrap if needed */
        gap: 8px;
    }

    .btn {
        min-height: 44px; /* Touch-friendly height */
        font-size: 13px;
        padding: 8px 12px;
    }

    .transaction-table th,
    .transaction-table td {
        padding: 8px 6px; /* Tighter padding */
        font-size: 12px; /* Smaller text for table */
        min-width: 60px; /* Prevent columns from being too narrow */
    }

    .transaction-table th:nth-child(3),
    .transaction-table td:nth-child(3) {
        min-width: 80px; /* Wider for description */
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px;
    }

    .modal-content {
        width: 95%; /* Almost full width on mobile */
        margin-top: 5%;
        height: 94%;
    }
}

@media (max-width: 480px) {
    .total-amount {
        font-size: 24px; /* Further reduced */
    }

    .total-assets h2 {
        font-size: 14px;
    }

    .btn {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 40px; /* Still touch-friendly */
    }

    .balance-details {
        flex-direction: column; /* Stack balance items vertically */
        align-items: center;
    }

    .balance-item {
        border-right: none;
        border-bottom: 1px solid var(--medium-gray);
        padding: 10px;
        width: 100%; /* Full width */
    }

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

    .balance-item .amount {
        font-size: 16px;
    }

    .transaction-table {
        font-size: 11px; /* Even smaller for tiny screens */
    }

    .transaction-status {
        font-size: 10px;
        padding: 2px 6px;
    }

    .no-transactions-message {
        padding: 20px 0;
        font-size: 13px;
    }

    .no-transactions-message i {
        font-size: 24px;
    }
}

.currency-select {
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    margin-left: 4px;
    padding: 2px;
    cursor: pointer;
    outline: none;
    min-width: 50px; /* Touch-friendly */
}

.currency-select option {
    background: #fff;
    color: #333;
}

/* Global Notification */
.global-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 350px;
    padding: 15px 20px;
    background-color: #4CAF50;
    color: white;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    transform: translateX(110%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.global-notification.show {
    transform: translateX(0);
    opacity: 0.95;
    visibility: visible;
    pointer-events: auto;
}

.global-notification.error {
    background-color: #f44336;
}

.notification-content {
    display: flex;
    align-items: center;
}

.notification-message {
    flex: 1;
    font-weight: 500;
}
