/*
Buying Crypto Main Page Styles
Only for the main /buy page, not child pages
Template: page-buying-crypto.php
*/

/* Header Section Styles */
.buying-crypto-header {
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.buying-crypto-title {
    font-size: 2.8em;
    font-weight: 700;
    color: var(--text-heading, #1a1a1a);
    margin-bottom: 25px;
    line-height: 1.3;
}

.buying-crypto-description {
    font-size: 1.2em;
    line-height: 1.9;
    color: var(--text-body, #4a4a4a);
    max-width: 900px;
    margin: 0 auto;
    text-align: justify;
}

/* Responsive Styles for Header */
@media (max-width: 768px) {
    .buying-crypto-header {
        margin-bottom: 40px;
        padding-bottom: 25px;
    }
    
    .buying-crypto-title {
        font-size: 2.2em;
        margin-bottom: 20px;
    }
    
    .buying-crypto-description {
        font-size: 1.1em;
        line-height: 1.8;
        text-align: right;
    }
}

@media (max-width: 480px) {
    .buying-crypto-title {
        font-size: 1.8em;
        margin-bottom: 15px;
    }
    
    .buying-crypto-description {
        font-size: 1em;
        line-height: 1.7;
    }
}

/* ============================================
   Crypto Table Styles - Essential styles from homepage.css
   ============================================ */

/* Crypto Section Base Styles */
.buying-crypto-content .crypto-section {
    direction: rtl;
    font-family: "IRANSansWeb", sans-serif;
    background: transparent;
    color: #1e1e2f;
    margin-bottom: 40px;
    padding: 0 !important;
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Tabs and Search Container */
.buying-crypto-content .tabsAndSearchContainer {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #9f9f9f;
    width: 100%;
    margin: 0;
}

.buying-crypto-content .tabs {
    display: flex;
    justify-content: flex-start;
    font-family: "IRANSansWeb", sans-serif;
    width: 30%;
}

.buying-crypto-content .tab {
    padding: 10px 20px;
    background: #f1f5ff;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #555;
    transition: all 0.3s ease;
    width: 50%;
    font-family: "IRANSansWeb", sans-serif;
}

.buying-crypto-content .tab.active {
    background: #ffffff;
    border-top: 3px solid #3b82f6;
    color: #111;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.buying-crypto-content .searchBox {
    flex-grow: 1;
    display: flex;
    justify-content: flex-end;
}

.buying-crypto-content .searchInput {
    border: 1px dashed #3b82f6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    font-family: "IRANSansWeb", sans-serif;
    background: transparent;
    transition: all 0.3s ease;
}

.buying-crypto-content .searchInput:focus {
    outline: none;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    font-family: "IRANSansWeb", sans-serif;
    background: transparent;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Table Container */
.buying-crypto-content .table-container {
    overflow-x: auto;
    position: relative;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-card, rgba(0, 0, 0, 0.1));
    height: auto !important; /* Override homepage.css fixed height */
    min-height: 400px;
    width: 100%;
    border: 1px solid var(--border-color, #ddd);
}

/* Crypto Table */
.buying-crypto-content .crypto-table {
    width: 100%;
    border-collapse: collapse;
    display: none;
}

.buying-crypto-content .crypto-table.active {
    display: table;
}

.buying-crypto-content .crypto-table thead {
    position: sticky;
    top: 0;
    background: #fafafa;
    z-index: 2;
}

.buying-crypto-content .crypto-table tbody {
    max-height: none !important; /* Remove max-height limitation */
    overflow-y: visible !important; /* Remove scroll */
    display: table-row-group;
}

.buying-crypto-content .crypto-table th,
.buying-crypto-content .crypto-table td {
    padding: 16px;
    text-align: right;
    border-bottom: 1px solid #ddd;
    font-family: "IRANSansWeb", sans-serif;
    vertical-align: middle;
}

/* Center align all columns except first column (coin name) */
.buying-crypto-content .crypto-table th:not(:first-child),
.buying-crypto-content .crypto-table td:not(:first-child) {
    text-align: center;
}

.buying-crypto-content .crypto-table th {
    background: #fafafa;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.buying-crypto-content .crypto-table tr:hover {
    background-color: #f1f5ff;
}

.buying-crypto-content .crypto-table tr {
    width: 100%;
}

/* Coin Name Cell */
.buying-crypto-content .coin-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: center;
    margin-top: 12px;
    border-bottom: 1px solid #ddd;
    font-family: "IRANSansWeb", sans-serif;
    vertical-align: middle;
}

.buying-crypto-content .coin-name-cell img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.buying-crypto-content .coin-name {
    font-weight: 500;
    color: #1e1e2f;
}

/* Trade Button */
.buying-crypto-content .trade-btn {
    background: white;
    border: double 2px transparent;
    background-image: linear-gradient(white, white),
                      linear-gradient(to left, #3b82f6, #ef4444);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "IRANSansWeb", sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    box-shadow: var(--shadow-subtle, 0 1px 3px rgba(0, 0, 0, 0.1));
}

.buying-crypto-content .trade-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover, 0 4px 6px rgba(0, 0, 0, 0.1));
    text-decoration: none;
}

.buying-crypto-content .trade-btn .buy {
    color: #3b82f6;
}

.buying-crypto-content .trade-btn .sale {
    color: #ef4444;
}

.buying-crypto-content .trade-btn .separator {
    color: #555;
    margin: 0 2px;
}

/* Price Change Indicators */
.buying-crypto-content .up {
    color: #16a34a;
    font-weight: 600;
    direction: ltr;
}

.buying-crypto-content .down {
    color: #dc2626;
    font-weight: 600;
    direction: ltr;
}

/* Loading Spinner */
.buying-crypto-content .table-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.buying-crypto-content .spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.buying-crypto-content .table-container {
    height: auto !important; /* Remove fixed height */
    min-height: 400px; /* Minimum height for better UX */
    width: 100%;
}

.buying-crypto-content .crypto-table tbody {
    max-height: none !important; /* Remove max-height limitation */
    overflow-y: visible !important; /* Remove scroll */
    display: table-row-group;
}

/* Hide symbol column (نماد) in buy page tables */
.buying-crypto-content .crypto-table th:nth-child(2),
.buying-crypto-content .crypto-table td:nth-child(2) {
    display: none;
}

/* Fix tabs and search container to maintain proper spacing */
.buying-crypto-content .tabsAndSearchContainer {
    width: 100%;
    margin: 0;
}

/* Ensure table container doesn't break layout */
.buying-crypto-content .crypto-section .table-container {
    margin: 0;
    width: 100%;
}

/* Keep RTL for table content but not for section wrapper */
.buying-crypto-content .crypto-section .tabsAndSearchContainer,
.buying-crypto-content .crypto-section .table-container,
.buying-crypto-content .crypto-section .crypto-table {
    direction: rtl; /* Keep RTL for table elements */
}

/* Vertical alignment for all table cells */
.buying-crypto-content .crypto-table td,
.buying-crypto-content .crypto-table th {
    vertical-align: middle;
}

/* Coin name and symbol styling for buy page */
.buying-crypto-content .coin-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    vertical-align: middle;
}

.buying-crypto-content .coin-name-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.buying-crypto-content .coin-name {
    font-weight: 500;
    color: var(--text-heading, #1e1e2f);
    line-height: 1.4;
}

.buying-crypto-content .coin-symbol {
    font-size: 0.85em;
    color: #888;
    font-weight: 400;
    line-height: 1.2;
}

/* Dark theme support for coin symbol */
[data-theme="dark"] .buying-crypto-content .coin-symbol {
    color: #aaa;
}

[data-theme="dark"] .buying-crypto-content .coin-name {
    color: var(--text-primary, #fff);
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .buying-crypto-content .tabsAndSearchContainer {
        flex-direction: column;
        align-items: stretch;
    }

    .buying-crypto-content .tabs {
        width: 100%;
        gap: 5px;
    }

    .buying-crypto-content .tab {
        width: 50%;
        font-size: 0.9rem;
        padding: 12px 0;
        border-radius: 8px;
    }

    .buying-crypto-content .tab.active {
        border-radius: 8px;
    }

    .buying-crypto-content .searchBox {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }

    .buying-crypto-content .searchInput {
        width: 100%;
        box-sizing: border-box;
    }

    /* Hide unnecessary columns on mobile for buy page */
    /* Show: name (1), last price (4), changes (5), trade (6) */
    /* Hide: buy price (2), sell price (3) */
    .buying-crypto-content .crypto-table th:nth-child(2),
    .buying-crypto-content .crypto-table th:nth-child(3),
    .buying-crypto-content .crypto-table td:nth-child(2),
    .buying-crypto-content .crypto-table td:nth-child(3) {
        display: none;
    }
    
    /* Show last price (4) and trade (6) columns on mobile */
    .buying-crypto-content .crypto-table th:nth-child(4),
    .buying-crypto-content .crypto-table th:nth-child(6),
    .buying-crypto-content .crypto-table td:nth-child(4),
    .buying-crypto-content .crypto-table td:nth-child(6) {
        display: table-cell;
    }

    .buying-crypto-content .crypto-table th,
    .buying-crypto-content .crypto-table td {
        font-size: 0.85rem;
        padding: 8px 4px;
    }

    .buying-crypto-content .trade-btn {
        padding: 5px 8px;
        font-size: 0.8rem;
        min-width: auto;
    }

    .buying-crypto-content .coin-name-cell {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 4px;
        text-align: center;
        margin-top: 0;
    }

    .buying-crypto-content .coin-name-cell img {
        width: 30px;
        height: 30px;
        flex-shrink: 0;
    }

    .buying-crypto-content .coin-name {
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .buying-crypto-content .coin-symbol {
        font-size: 0.75em;
    }

    /* Spacing between columns - reduced for mobile */
    .buying-crypto-content .crypto-table td:not(:last-child),
    .buying-crypto-content .crypto-table th:not(:last-child) {
        padding-left: 3px;
        padding-right: 3px;
    }

    .buying-crypto-content .crypto-table td:last-child,
    .buying-crypto-content .crypto-table th:last-child {
        padding-left: 3px;
        padding-right: 3px;
        width: auto;
    }
    
    /* Reduce font size for price change indicators */
    .buying-crypto-content .crypto-table .up,
    .buying-crypto-content .crypto-table .down {
        font-size: 0.85rem;
    }
}

/* Extra small mobile devices (480px and below) */
@media (max-width: 480px) {
    .buying-crypto-content .crypto-table th,
    .buying-crypto-content .crypto-table td {
        font-size: 0.8rem;
        padding: 6px 3px;
    }

    .buying-crypto-content .trade-btn {
        padding: 4px 7px;
        font-size: 0.75rem;
    }

    .buying-crypto-content .coin-name-cell {
        gap: 5px;
        padding: 6px 3px;
    }

    .buying-crypto-content .coin-name-cell img {
        width: 26px;
        height: 26px;
    }

    .buying-crypto-content .coin-name {
        font-size: 0.8rem;
    }

    .buying-crypto-content .coin-symbol {
        font-size: 0.7em;
    }

    .buying-crypto-content .crypto-table .up,
    .buying-crypto-content .crypto-table .down {
        font-size: 0.8rem;
    }
    
    /* Further reduce spacing on very small screens */
    .buying-crypto-content .crypto-table td:not(:last-child),
    .buying-crypto-content .crypto-table th:not(:last-child) {
        padding-left: 2px;
        padding-right: 2px;
    }

    .buying-crypto-content .crypto-table td:last-child,
    .buying-crypto-content .crypto-table th:last-child {
        padding-left: 2px;
        padding-right: 2px;
    }
}

/* Dark theme styles for crypto table */
[data-theme="dark"] .buying-crypto-content .crypto-section {
    background: transparent;
    color: var(--text-body);
}

[data-theme="dark"] .buying-crypto-content .tab {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .buying-crypto-content .tab.active {
    background: var(--card-bg);
    border-top: 3px solid var(--accent-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .buying-crypto-content .searchInput {
    background: var(--card-bg);
    color: var(--text-body);
    border: 1px dashed var(--accent-primary);
}

[data-theme="dark"] .buying-crypto-content .searchInput:focus {
    background: var(--card-bg);
    border: 1px solid var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(61, 114, 254, 0.2);
}

[data-theme="dark"] .buying-crypto-content .table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .buying-crypto-content .crypto-table thead {
    background: var(--header-bg);
}

[data-theme="dark"] .buying-crypto-content .crypto-table th {
    background: var(--header-bg);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .buying-crypto-content .crypto-table {
    background: var(--card-bg);
    color: var(--text-body);
}

[data-theme="dark"] .buying-crypto-content .crypto-table td {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-body);
}

[data-theme="dark"] .buying-crypto-content .crypto-table tr:hover {
    background-color: rgba(61, 114, 254, 0.1);
}

[data-theme="dark"] .buying-crypto-content .coin-name {
    color: var(--text-primary);
}

[data-theme="dark"] .buying-crypto-content .trade-btn {
    background: var(--card-bg);
    border: double 2px transparent;
    background-image: linear-gradient(var(--card-bg), var(--card-bg)),
                      linear-gradient(to left, #3b82f6, #ef4444);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    color: var(--text-body);
}

[data-theme="dark"] .buying-crypto-content .trade-btn:hover {
    background: var(--card-bg);
    background-image: linear-gradient(var(--card-bg), var(--card-bg)),
                      linear-gradient(to left, #3b82f6, #ef4444);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

[data-theme="dark"] .buying-crypto-content .trade-btn .buy {
    color: var(--accent-primary);
}

[data-theme="dark"] .buying-crypto-content .trade-btn .sale {
    color: #ef4444;
}

[data-theme="dark"] .buying-crypto-content .trade-btn .separator {
    color: var(--text-secondary);
}

[data-theme="dark"] .buying-crypto-content .crypto-table .up {
    color: #16a34a !important;
    font-weight: 600;
    direction: ltr;
}

[data-theme="dark"] .buying-crypto-content .crypto-table .down {
    color: #dc2626 !important;
    font-weight: 600;
    direction: ltr;
}