/* استایل‌های حرفه‌ای و ریسپانسیو */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    font-size: clamp(0.7rem, 2vw, 0.8rem); /* فونت کوچکتر */
    padding: clamp(0.5rem, 1.5vw, 0.75rem);
}

/* پس‌زمینه پارالاکس */
#wave-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.3;
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.2), transparent 70%);
}

/* غیرفعال کردن پارالاکس در موبایل */
@media (max-width: 768px) {
    #wave-canvas {
        display: none;
    }
}

/* کانتینر جدول */
.table-container {
    width: 100%;
    max-width: 100%;
    max-height: 55vh; /* کاهش ارتفاع */
    overflow-y: auto;
    overflow-x: hidden; /* حذف اسکرول افقی در کانتینر */
    border-radius: 8px;
    background: rgba(20, 20, 20, 0.4);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(59, 130, 246, 0.2);
    margin: clamp(0.5rem, 1.5vw, 0.75rem) 0;
    padding: clamp(4px, 1vw, 6px);
}

/* جدول */
table {
    border-collapse: collapse;
    width: 100%;
    font-family: 'Inter', sans-serif;
    text-align: center;
}

/* استایل کلی th و td */
th, td {
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: clamp(4px, 1vw, 6px);
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    white-space: normal; /* اجازه شکستن متن */
}

/* استایل اختصاصی برای بالانس و توتال پروفیت */
td.profit-positive, td.profit-negative {
    font-size: clamp(0.6rem, 1.4vw, 0.7rem); /* فونت کوچکتر برای بالانس و توتال پروفیت */
    padding: clamp(3px, 0.8vw, 5px);
}

.profit-positive { color: #34d399; }
.profit-negative { color: #f87171; }

/* مودال */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: clamp(0.5rem, 1.5vw, 0.75rem);
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 80vw; /* عرض کوچکتر */
    max-height: 70vh;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    text-align: center;
    padding: clamp(8px, 2vw, 10px);
}

/* ورودی‌ها */
input {
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    font-family: 'Inter', sans-serif;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    color: #e0e0e0;
    padding: clamp(5px, 1.2vw, 7px);
    width: 100%;
    text-align: center;
}

input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

/* دکمه‌ها */
.button-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(4px, 1vw, 6px);
    margin: clamp(0.5rem, 1.5vw, 0.75rem) 0;
}

button {
    font-family: 'Inter', sans-serif;
    border-radius: 6px;
    padding: clamp(5px, 1.2vw, 7px) clamp(10px, 2.5vw, 12px);
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #e0e0e0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    flex: 0 1 auto;
}

/* کارت‌ها */
.card {
    width: 100%;
    max-width: 100%;
    background: rgba(20, 20, 20, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    margin: clamp(0.5rem, 1.5vw, 0.75rem) 0;
    padding: clamp(6px, 1.5vw, 8px);
    text-align: center;
}

.card h3 {
    font-size: clamp(0.7rem, 1.6vw, 0.8rem);
    margin: 0.5rem 0;
}

.card p {
    font-size: clamp(0.8rem, 1.8vw, 0.9rem);
    margin: 0.5rem 0;
}

.card.no-blur {
    background: rgba(20, 20, 20, 0.7);
}

/* پیام خطا */
.error-message {
    color: #f87171;
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    text-align: center;
    margin: 0.5rem 0;
}

/* انیمیشن ردیف‌های جدول */
tr {
    transition: background 0.3s ease;
}

tr:hover {
    background: rgba(59, 130, 246, 0.15);
}

/* انیمیشن ورود */
@keyframes slide-in {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* تبدیل جدول به فرمت کارت در موبایل */
@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
        padding: 0;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead {
        display: none; /* مخفی کردن هدر */
    }

    tr {
        margin-bottom: 0.5rem;
        border-bottom: 1px solid rgba(59, 130, 246, 0.2);
        padding: clamp(4px, 1vw, 6px);
    }

    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: clamp(3px, 0.8vw, 5px);
        font-size: clamp(0.6rem, 1.4vw, 0.7rem);
        text-align: right;
        border: none;
    }

    td:before {
        content: attr(data-label);
        font-weight: bold;
        width: 40%;
        text-align: left;
    }

    /* بالانس و توتال پروفیت در موبایل */
    td.profit-positive, td.profit-negative {
        font-size: clamp(0.55rem, 1.3vw, 0.65rem);
        padding: clamp(2px, 0.6vw, 4px);
    }

    .modal-content {
        max-width: 90vw;
        padding: clamp(6px, 1.5vw, 8px);
    }

    .button-container {
        gap: clamp(3px, 0.8vw, 5px);
    }

    button {
        padding: clamp(4px, 1vw, 5px) clamp(8px, 2vw, 10px);
        font-size: clamp(0.6rem, 1.4vw, 0.7rem);
    }

    .card {
        padding: clamp(4px, 1vw, 6px);
    }
}

/* موبایل‌های خیلی کوچک */
@media (max-width: 480px) {
    body {
        padding: clamp(0.2rem, 0.8vw, 0.3rem);
        font-size: clamp(0.6rem, 1.4vw, 0.7rem);
    }

    .table-container {
        margin: clamp(0.2rem, 0.8vw, 0.3rem) 0;
    }

    .modal-content {
        max-width: 95vw;
        padding: clamp(4px, 1vw, 6px);
    }

    td {
        font-size: clamp(0.55rem, 1.3vw, 0.65rem);
        padding: clamp(2px, 0.6vw, 4px);
    }

    td.profit-positive, td.profit-negative {
        font-size: clamp(0.5rem, 1.2vw, 0.6rem);
    }

    .button-container {
        gap: clamp(2px, 0.6vw, 4px);
    }

    button {
        padding: clamp(3px, 0.8vw, 4px) clamp(6px, 1.5vw, 8px);
        font-size: clamp(0.55rem, 1.3vw, 0.65rem);
    }

    .card h3 {
        font-size: clamp(0.6rem, 1.4vw, 0.7rem);
    }

    .card p {
        font-size: clamp(0.7rem, 1.6vw, 0.8rem);
    }
}