/* exchange/resources/static/css/exchangeRate.css */
/* CSS 클래스 충돌 방지를 위한 네임스페이스 적용 */

/* 로딩 페이드 인/아웃 효과 추가 */
.exchange-module .main-content {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.exchange-module .visually-hidden {
    display: none;
}

.exchange-module .title-container {
    text-align: center; /* 제목 컨테이너 중앙 정렬 */
    margin: 1rem 0;
}

.exchange-module .calculator-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--theme-color);
    display: inline-block; /* 인라인 블록으로 변경 */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    position: relative; /* 상대 위치 설정 */
}

.exchange-module .cursor {
    display: inline-block;
    width: 2px;
    height: 2rem;
    background-color: var(--theme-color);
    margin-left: 2px; /* 커서와 텍스트 사이 간격 */
    position: relative; /* 상대 위치 설정 */
    top: 4px; /* 커서 위치 미세 조정 */
    animation: blink 0.7s infinite; /* 애니메이션 수정 */
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

.exchange-module .main-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.exchange-module .container-fluid {
    padding: 2rem;
}

.exchange-module .calculator-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

.exchange-module .card {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    margin-bottom: 2rem;
}

.exchange-module .card-content {
    padding: 1.5rem;
    overflow: hidden;
}

/* 통화 선택 버튼 wrapper */
.exchange-module .currency-select-wrapper {
    margin-bottom: 1.5rem;
}

.exchange-module .btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 0.25rem;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.exchange-module .btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-primary-hover);
    color: var(--theme-color);
}

.chevron-down {
    font-size: 0.75rem;
}

.input-group {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 0.25rem;
    flex-wrap: nowrap; /* 줄바꿈 방지 */
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.currency-code,
.currency-info {
    color: var(--text-primary);
}

.currency-btn {
    width: 100px;
    background-color: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    cursor: move;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-right: 1px solid var(--border-primary);
}

.currency-input-wrapper {
    position: relative;
    flex: 1;
    padding: 0.75rem 1rem;
    text-align: right;
    font-size: 1rem;
    font-family: Arial, sans-serif;
}

.currency-input {
    width: 100%;
    background: transparent;
    border: none;
    color: transparent;
    caret-color: var(--text-primary); /* 커서 색상을 흰색으로 설정 */
    text-align: right;
}

.currency-input:focus {
    outline: none;
}

.currency-input::selection {
    background-color: rgba(var(--theme-color-rgb), 0.3); /* 선택 영역 배경색 */
    color: transparent; /* 선택된 텍스트는 여전히 투명하게 */
}

.display-text {
    position: absolute;
    top: 0;
    right: 1rem;
    bottom: 0;
    left: 1rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    pointer-events: none; /* 텍스트가 input 이벤트를 방해하지 않도록 */
}

.integer-part {
    color: var(--text-primary);
}

.decimal-separator {
    color: var(--theme-color);
    margin: 0 1px;
    font-weight: bold;
}

.decimal-part {
    color: var(--theme-color);
    min-width: 2ch;
    display: inline-block;
    font-size: 0.8rem;
}

.dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.dialog-content {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.dialog-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-tertiary);
}

.close-btn {
    background-color: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.dialog-body {
    padding: 1rem;
}

.currency-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-primary);
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.currency-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-primary-hover);
}

.currency-item:hover .currency-code {
    color: var(--theme-color);
    font-weight: bold;
}

.currency-item:hover .currency-name {
    color: var(--text-primary);
}

.currency-item input[type="checkbox"] {
    margin-right: 0.75rem;
}

.currency-item .currency-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-grow: 1;
}

.currency-item .currency-code {
    font-weight: bold;
    margin-right: 0.5rem;
}

.currency-item .currency-name {
    color: var(--text-tertiary);
}

.chart-section {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
}

.exchange-module .period-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.exchange-module .period-btn {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 80px;
    text-align: center;
}

.exchange-module .period-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--theme-color);
    color: var(--theme-color);
}

.exchange-module .period-btn.selected {
    background-color: var(--theme-color);
    border-color: var(--theme-color);
    color: var(--text-selected);
}

.exchange-module .chart-container {
    position: relative;
    height: 50vh;
    min-height: 300px;
    width: 100%;
}

.exchange-module #customDays {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 0.25rem;
    color: var(--text-primary);
}

/* 반응형 스타일 */
@media (min-width: 768px) {
    .calculator-wrapper {
        display: flex;
        flex-wrap: wrap;
        gap: 2rem;
    }

    .calculator-card {
        min-width: 300px;
        max-width: 400px;
    }

    .chart-card {
        flex: 2;
        min-width: 500px;
    }
}

@media (max-width: 767px) {
    .container-fluid {
        padding: 1rem;
    }

    .card-content {
        padding: 1rem;
    }

    .chart-container {
        height: 40vh;
    }

    .period-btn {
        font-size: 0.875rem;
        padding: 0.4rem 0.8rem;
    }
}

.currency-pair-selector select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 0.4rem;
    border-radius: 0.25rem;
    cursor: pointer;
}

.currency-pair-selector select:hover {
    border-color: var(--theme-color);
}

.form-check-input {
    margin-top: 0.75rem;
}

.currency-pairs {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .currency-pairs {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* 통화 선택 스타일 수정 */
.currency-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.currency-option {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    justify-content: center;
}

@media (max-width: 500px) {
    .currency-selector {
        grid-template-columns: repeat(3, 1fr); /* 500 이하일 때 3개 */
        gap: 0.5rem;
    }

    .currency-option {
        padding: 0.5rem; /* 버튼 크기 조정 */
    }
}

.currency-option:hover {
    background: var(--bg-hover);
}

.currency-option.selected {
    background: var(--bg-secondary);
    border-color: var(--theme-color);
}

.currency-option.selected .currency-code {
    color: var(--theme-color);
}

.currency-flag {
    font-size: 1.2rem;
}

.select-all-wrapper {
    padding: 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.select-all-wrapper .currency-item {
    margin: 0;
}

.base-currency-title {
    font-size: 0.9rem;
    color: var(--theme-color);
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: rgba(var(--theme-color-rgb), 0.1);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.base-currency-title .currency-flag {
    font-size: 1.2rem;
}

#calculatorTitle {
    font-weight: 1000;
}

.chart-type-selector .btn-group {
    display: flex;
    gap: 0.5rem;
}

.chart-type-btn {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    border-radius: 4px;
}

.chart-type-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--theme-color);
    color: var(--theme-color);
}

.chart-type-btn.active {
    background-color: var(--theme-color);
    border-color: var(--theme-color);
    color: var(--text-selected);
}

.currency-pair-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-select {
    width: 100%;
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 4px;
}

.form-select:focus {
    border-color: var(--theme-color);
    outline: none;
}

.settings-group {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-group:last-child {
    border-bottom: none;
}

.settings-title {
    color: var(--text-tertiary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-group {
    display: flex;
    width: 100%;
    gap: 8px;
}

.btn-group .chart-type-btn {
    flex: 1;
    padding: 8px 16px;
    text-align: center;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.btn-group .chart-type-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--theme-color);
    color: var(--theme-color);
}

.btn-group .chart-type-btn.active {
    background-color: var(--theme-color);
    border-color: var(--theme-color);
    color: var(--text-selected);
}

.drag-handle {
    padding: 0.75rem 0.5rem;
    cursor: move;
    display: flex;
    align-items: center;
    color: var(--text-tertiary);
    font-size: 1.2rem;
}

.drag-handle::before {
    font-size: 1.5rem;
    content: "✥";
}

.currency-info {
    display: flex;
    align-items: center;
    width: 95px; /* 고정 너비 설정 */
    padding: 0.75rem 1rem;
    border-right: 1px solid var(--border-primary);
}

.currency-flag {
    margin-right: 0.5rem;
}

@media (max-width: 576px) {
    .currency-info {
        width: 100px; /* 모바일에서는 좀 더 좁게 */
    }
}

/* 차트 관련 CSS */
.charts-container {
    width: 100%;
    margin-top: 1rem;
}

.chart-grid {
    display: grid;
    gap: 1rem;
    width: 100%;
}

.chart-grid.single-chart {
    grid-template-columns: 1fr;
}

.exchange-module .chart-wrapper {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    position: relative;
    width: 100%;
    /* 고정된 높이 비율 설정 */
    /*aspect-ratio: 16/9;*/
    /* 최소/최대 높이 제한 */
    min-height: 250px;
    max-height: 400px;
}

/* PC 화면 - 2개 이상일 때 2x2 그리드 */
@media (min-width: 1024px) {
    .chart-grid:not(.single-chart) {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 태블릿 화면 */
@media (min-width: 768px) and (max-width: 1023px) {
    .chart-grid:not(.single-chart) {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* 모바일 화면 */
@media (max-width: 767px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        /*aspect-ratio: 4/3; !* 모바일에서는 더 정사각형에 가깝게 *!*/
    }
}

/* 차트 캔버스 크기 제어 */
.exchange-module .chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* 차트 선택 UI */
.currency-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.currency-option {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg-tertiary);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.currency-option:hover {
    background-color: var(--bg-hover);
}

.currency-option.selected {
    color: var(--text-selected);
}

.last-update-time {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    text-align: right;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.realtime-indicator {
    background: rgba(var(--theme-color-rgb), 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--theme-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

.realtime-dot {
    width: 6px;
    height: 6px;
    background-color: var(--theme-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(0.95);
        opacity: 0.5;
    }
}

.loading-bar-container {
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: rgba(74, 74, 74, 0.3);
    overflow: hidden;
    border-radius: 1.5px;
}

.loading-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg,
    rgba(var(--theme-color-rgb), 0.3) 0%,
    rgba(var(--theme-color-rgb), 1) 50%,
    rgba(var(--theme-color-rgb), 0.3) 100%
    );
    transition: width 1s linear;
    position: absolute;
    left: 0;
    top: 0;
    box-shadow: 0 0 8px rgba(var(--theme-color-rgb), 0.5);
    animation: glow 2s infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(var(--theme-color-rgb), 0.5);
    }
    50% {
        box-shadow: 0 0 12px rgba(var(--theme-color-rgb), 0.8);
    }
}