/**
 * Currency Converter Styles
 * Matching the design from finance.kapital.kz/converter
 */

/* Reset and Base Styles */
.currency-converter-wrapper * {
    box-sizing: border-box;
}

.currency-converter-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #333;
    line-height: 1.5;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Container */
.currency-converter-container {
    background: #ffffff;
    border-radius: 0;
    padding: 40px 0;
}

/* Title */
.converter-title {
    font-size: 32px;
    font-weight: 600;
    margin: 0 0 30px 0;
    color: #1a1a1a;
}

/* Tabs */
.converter-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 40px;
    border-bottom: 1px solid #e5e5e5;
}

.converter-tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    outline: none;
}

.converter-tab:hover {
    color: #1a1a1a;
}

.converter-tab.active {
    color: #1a1a1a;
}

.converter-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #1a1a1a;
}

/* Converter Content */
.converter-content {
    padding: 20px 0;
}

.converter-columns {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 40px;
    align-items: start;
}

/* Column Styles */
.converter-column {
    display: flex;
    flex-direction: column;
}

.column-title {
    font-size: 16px;
    font-weight: 500;
    color: #666;
    margin: 0 0 20px 0;
}

/* Currency Buttons */
.currency-buttons-wrapper {
    position: relative;
    margin-bottom: 24px;
}

/* Keep relative positioning for desktop */
@media (min-width: 769px) {
    .currency-buttons-wrapper {
        position: relative;
    }
}

/* Remove relative positioning on mobile to allow fixed dropdown */
@media (max-width: 768px) {
    .currency-buttons-wrapper {
        position: static !important;
    }
}

.currency-buttons {
    display: flex;
    gap: 8px;
}

.currency-btn {
    background: #f5f5f5;
    border: 1px solid transparent;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    outline: none;
}

.currency-btn:hover {
    background: #ebebeb;
}

.currency-btn.active {
    background: #00a651;
    color: #ffffff;
    border-color: #00a651;
}

.currency-btn.more-btn {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.currency-btn.more-btn svg {
    width: 12px;
    height: 8px;
}

/* Amount Input */
.amount-input-wrapper {
    position: relative;
}

.amount-input {
    width: 100%;
    font-size: 48px;
    font-weight: 300;
    color: #1a1a1a;
    border: none;
    outline: none;
    padding: 0;
    background: transparent;
    margin-bottom: 12px;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.amount-input[type=number] {
    -moz-appearance: textfield;
}

.currency-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.exchange-rate {
    font-size: 13px;
    color: #999;
}

/* Swap Button */
.swap-arrow-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
}

.swap-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    color: #666;
    transition: color 0.2s ease;
    outline: none;
}

.swap-btn:hover {
    color: #00a651;
}

.swap-btn svg {
    width: 40px;
    height: 16px;
}

/* Hidden Data Container */
.converter-data {
    display: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .currency-converter-wrapper {
        padding: 15px;
    }

    .currency-converter-container {
        padding: 20px 0;
    }

    .converter-columns {
        gap: 30px;
    }

    .currency-dropdown {
        min-width: 600px;
    }

    .currency-dropdown-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .currency-converter-wrapper {
        padding: 10px;
    }

    .currency-converter-container {
        padding: 15px 0;
    }

    .converter-columns {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .swap-arrow-wrapper {
        padding-top: 0;
        padding-bottom: 0;
        order: 2;
    }

    .from-column {
        order: 1;
    }

    .to-column {
        order: 3;
    }

    .swap-btn {
        transform: rotate(90deg);
    }

    .converter-title {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .column-title {
        font-size: 14px;
        margin-bottom: 15px;
    }

    .amount-input {
        font-size: 32px;
    }

    .currency-buttons {
        flex-wrap: wrap;
    }

    .currency-btn {
        font-size: 13px;
        padding: 8px 16px;
    }

    .currency-btn.more-btn {
        padding: 8px 12px;
    }

    .currency-dropdown {
        /* Compact dropdown with scroll for mobile */
        position: fixed !important;
        bottom: auto !important;
        top: calc(100% + 8px) !important;
        left: 0 !important;
        right: 0 !important;
        min-width: auto;
        /* Show exactly 2 rows + scrollbar hint */
        max-height: 180px;
        padding: 12px;
        padding-bottom: 8px;
        margin: 0 !important;
        overflow-y: auto;
        overflow-x: hidden;
        z-index: 99999 !important;
        /* Smooth scrolling */
        -webkit-overflow-scrolling: touch;
        /* Better shadow */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        /* Gradient to show scroll */
        background:
            linear-gradient(white 30%, rgba(255,255,255,0)),
            linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
            radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.2), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
        background-color: white;
        background-repeat: no-repeat;
        background-attachment: local, local, scroll, scroll;
        background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
    }

    .currency-dropdown-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .currency-dropdown-item {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 4px;
    }

    .currency-dropdown-item .currency-code {
        min-width: 40px;
        font-size: 13px;
        font-weight: 600;
    }

    .currency-dropdown-item .currency-name {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .converter-tabs {
        margin-bottom: 25px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .converter-tab {
        padding: 10px 18px;
        font-size: 14px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .currency-converter-wrapper {
        padding: 5px;
    }

    .converter-title {
        font-size: 20px;
    }

    .amount-input {
        font-size: 28px;
    }

    .currency-buttons {
        gap: 6px;
    }

    .currency-btn {
        font-size: 12px;
        padding: 7px 12px;
    }

    .currency-dropdown {
        /* Slightly taller on very small screens */
        max-height: 200px;
        padding: 10px;
    }

    .currency-dropdown-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .currency-dropdown-item {
        padding: 12px;
        font-size: 14px;
    }

    .currency-dropdown-item .currency-code {
        font-size: 14px;
        min-width: 45px;
    }

    .currency-dropdown-item .currency-name {
        font-size: 12px;
    }

    .converter-tab {
        padding: 8px 15px;
        font-size: 13px;
    }
}

/* Loading State */
.currency-converter-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error Message */
.converter-error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px 16px;
    border-radius: 4px;
    margin-top: 20px;
    font-size: 14px;
}

/* Currency Dropdown (for "More" button) */
.currency-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 8px;
    z-index: 1000;
    display: none;
    min-width: 800px;
}

.currency-dropdown.active {
    display: block;
}

/* Scrollbar styling for dropdown */
.currency-dropdown::-webkit-scrollbar {
    width: 8px;
}

.currency-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.currency-dropdown::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.currency-dropdown::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.currency-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px 12px;
}

.currency-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: background 0.2s ease;
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.currency-dropdown-item:hover {
    background: #f5f5f5;
}

.currency-dropdown-item .currency-code {
    font-weight: 600;
    color: #1a1a1a;
    min-width: 40px;
}

.currency-dropdown-item .currency-name {
    color: #666;
    font-size: 12px;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.converter-content {
    animation: fadeIn 0.3s ease;
}
