/**
 * Crypto Price Converter Stylesheet - Chart Above Favorites
 * Version: 1.0.5
 */

/* Container */
.crypto-converter-wrapper {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
}

.converter-container {
    background: linear-gradient(135deg, #f0f9ff 0%, #f0fdf4 100%);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 2px solid #e0f2fe;
}

.converter-container h2 {
    text-align: center;
    color: #1e293b;
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.converter-subtitle {
    text-align: center;
    color: #64748b;
    font-size: 14px;
    margin: 0 0 30px 0;
}

/* Form */
.converter-form {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* Conversion Mode Indicator */
.conversion-mode {
    text-align: center;
    margin-bottom: 20px;
}

.mode-badge {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
    transition: all 0.3s ease;
}

.mode-badge.reverse {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.mode-badge.normal {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.converter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.converter-row:last-child {
    margin-bottom: 0;
}

.converter-col {
    display: flex;
    flex-direction: column;
}

.converter-col label {
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Amount Input */
.amount-input {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.amount-input:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Swap Button */
.swap-row {
    grid-column: 1 / -1;
    margin: -10px 0;
}

.swap-button {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

.btn-swap {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-swap:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
}

.btn-swap::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.3) 0%, rgba(6, 182, 212, 0.3) 100%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-swap:hover::before {
    opacity: 1;
}

.btn-swap.rotating {
    animation: rotateSwap 0.6s ease;
}

@keyframes rotateSwap {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(180deg); }
}

/* Result */
.result-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.amount-output {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    background: #f8fafc;
    color: #0ea5e9;
    font-family: inherit;
}

.amount-output:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: wait;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Copy Button */
.btn-copy {
    padding: 10px 15px;
    background: #f0f9ff;
    border: 2px solid #0ea5e9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.btn-copy:hover {
    background: #0ea5e9;
    color: white;
    transform: translateY(-2px);
}

.btn-copy.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* Converter Info */
.converter-info {
    margin-top: 20px;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 8px;
    border-left: 4px solid #0ea5e9;
}

.exchange-rate {
    font-size: 14px;
    color: #334155;
    margin-bottom: 5px;
    font-weight: 600;
}

.last-updated {
    font-size: 12px;
    color: #94a3b8;
}

/* Price Chart Section - ABOVE FAVORITES */
.price-chart-section {
    margin-top: 30px;
    margin-bottom: 30px;
    padding: 25px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.chart-header h3 {
    color: #1e293b;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chart-period-btn {
    padding: 8px 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chart-period-btn:hover {
    background: #f0f9ff;
    border-color: #0ea5e9;
    color: #0ea5e9;
}

.chart-period-btn.active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
}

.btn-close-chart {
    padding: 6px 12px;
    background: #fee2e2;
    border: 2px solid #fecaca;
    border-radius: 8px;
    font-size: 18px;
    color: #dc2626;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    position: relative;
}

.btn-close-chart:hover {
    background: #dc2626;
    color: white;
}

.btn-close-chart::after {
    content: 'Hide Chart';
    position: absolute;
    bottom: -30px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    font-weight: normal;
}

.btn-close-chart:hover::after {
    opacity: 1;
}

.chart-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.stat-value.positive {
    color: #10b981;
}

.stat-value.negative {
    color: #ef4444;
}

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 10px;
}

.chart-loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid #0ea5e9;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chart-loading p {
    color: #64748b;
    font-size: 14px;
}

/* Favorites Section - BELOW CHART */
.favorites-section {
    margin-top: 0;
    padding-top: 30px;
    border-top: 2px solid #e2e8f0;
}

.favorites-section h3 {
    color: #1e293b;
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 700;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.favorite-item {
    background: white;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.favorite-item:hover {
    border-color: #0ea5e9;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.2);
    transform: translateY(-3px);
}

.favorite-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto 10px;
    border: 2px solid #e2e8f0;
    display: block;
}

.favorite-item:hover .favorite-icon {
    border-color: #0ea5e9;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.favorite-symbol {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
    margin-bottom: 4px;
}

.favorite-name {
    font-size: 12px;
    color: #94a3b8;
}

/* View Chart Button */
.btn-view-chart {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.favorite-item:hover .btn-view-chart {
    opacity: 1;
}

.btn-view-chart:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5);
}

.btn-view-chart .icon {
    font-size: 16px;
}

/* ===================================
   SELECT2 CUSTOM STYLES
   =================================== */

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    height: 48px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 15px;
    background: white;
    transition: all 0.3s ease;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    padding: 0;
    color: #1e293b;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 46px;
    right: 10px;
}

.select2-dropdown {
    border: 2px solid #0ea5e9;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    margin-top: 5px;
}

.select2-container--default .select2-results__option {
    padding: 10px 15px;
    transition: all 0.2s ease;
}

.select2-container--default .select2-results__option--highlighted {
    background: #f0f9ff;
    color: #0ea5e9;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background: #e0f2fe;
    color: #0369a1;
}

.select2-search--dropdown {
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.select2-search--dropdown .select2-search__field {
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: #0ea5e9;
    outline: none;
}

/* Crypto Icon Styles */
.select2-crypto-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    border: 1px solid #e2e8f0;
}

.select2-crypto-icon-sm {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    border: 1px solid #e2e8f0;
}

.select2-crypto-symbol {
    font-weight: 700;
    color: #0ea5e9;
}

.select2-crypto-name {
    color: #64748b;
    font-size: 13px;
}

.select2-flag {
    font-size: 20px;
    margin-right: 8px;
    vertical-align: middle;
}

/* Responsive */
@media (max-width: 768px) {
    .crypto-converter-wrapper {
        padding: 10px;
    }
    
    .converter-container {
        padding: 20px;
    }
    
    .converter-container h2 {
        font-size: 22px;
    }
    
    .converter-form {
        padding: 20px;
    }
    
    .converter-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .result-wrapper {
        flex-direction: column;
    }
    
    .btn-copy {
        width: 100%;
    }
    
    .price-chart-section {
        margin-top: 20px;
        margin-bottom: 20px;
        padding: 20px;
    }
    
    .favorites-section {
        padding-top: 20px;
    }
    
    .favorites-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .select2-container--default .select2-selection--single {
        height: 44px;
        padding: 8px 12px;
    }
    
    .select2-crypto-icon {
        width: 20px;
        height: 20px;
    }
    
    .mode-badge {
        font-size: 12px;
        padding: 6px 16px;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .chart-period-btn {
        flex: 1;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .chart-stats {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .btn-close-chart::after {
        display: none;
    }
}

@media (max-width: 480px) {
    .converter-container {
        padding: 15px;
    }
    
    .converter-container h2 {
        font-size: 20px;
    }
    
    .btn-swap {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .price-chart-section {
        padding: 15px;
    }
    
    .chart-header h3 {
        font-size: 16px;
    }
    
    .chart-period-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .stat-value {
        font-size: 16px;
    }
}

/* Accessibility */
.converter-select:focus,
.amount-input:focus,
.btn-swap:focus,
.btn-copy:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
}
