/* ===========================
   Additional Components
   =========================== */

/* Loading Knowledge Cards */
.loading-knowledge {
    margin-top: 40px;
    max-width: 400px;
}

.knowledge-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.knowledge-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.knowledge-card p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.knowledge-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.knowledge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-light);
    cursor: pointer;
    transition: background 0.2s;
}

.knowledge-dot.active {
    background: var(--color-brand);
}

/* Close Type Selector */
.close-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: 4px;
}

.close-type-tab {
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-type-tab:hover {
    color: var(--text-primary);
}

.close-type-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Close Amount Section */
.close-amount-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-label-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.percentage-selector {
    display: flex;
    gap: 8px;
}

.percentage-btn {
    flex: 1;
    padding: 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.percentage-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}

.percentage-btn.active {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

/* Expected PNL Section */
.expected-pnl-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.expected-pnl-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.expected-pnl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.expected-pnl-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.expected-pnl-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.expected-pnl-value {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.expected-pnl-amount {
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.expected-pnl-amount.positive {
    color: var(--color-buy);
}

.expected-pnl-amount.negative {
    color: var(--color-sell);
}

.expected-pnl-percent {
    font-size: 13px;
    color: var(--text-secondary);
}

.expected-margin-amount,
.expected-total-amount {
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Pagination */
.mobile-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--border-light);
    color: var(--text-primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Position Close Modal - 개선된 스타일 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 520px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 200px);
}

/* 포지션 정보 섹션 */
#modal-position-info {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.position-info-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.position-info-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.position-info-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
    text-align: right;
}

.position-info-value.long {
    color: var(--color-buy);
}

.position-info-value.short {
    color: var(--color-sell);
}

.position-info-value.cross {
    color: var(--color-sell);
}

.position-info-value.single {
    color: var(--color-buy);
}

.position-info-value.entry-price {
    color: var(--text-secondary);
}

.position-info-value.pnl-positive {
    color: var(--color-buy);
}

.position-info-value.pnl-negative {
    color: var(--color-sell);
}

/* 종료 타입 선택 */
.close-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.close-type-tab {
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-type-tab:hover {
    color: var(--text-primary);
}

.close-type-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 종료 수량 섹션 */
.close-amount-section {
    margin-bottom: 20px;
}

.input-label-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.input-label-with-button span {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.max-button,
.price-button {
    padding: 4px 12px;
    font-size: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.max-button:hover,
.price-button:hover {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

/* 퍼센트 선택 버튼 */
.percentage-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.percentage-btn {
    padding: 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.percentage-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.percentage-btn.active {
    border-color: var(--color-brand);
    color: var(--color-brand);
    background: rgba(240, 185, 11, 0.1);
}

/* 가격 입력 섹션 */
.price-input-section {
    margin-bottom: 20px;
    display: none;
}

.price-input-section.show {
    display: block;
}

/* 예상 결과 섹션 - 개선 */
.expected-pnl-section {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-top: 24px;
}

.expected-pnl-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.expected-pnl-section h3::before {
    content: "📊";
    font-size: 18px;
}

.expected-pnl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.expected-pnl-row:not(:last-child) {
    border-bottom: 1px solid rgba(43, 49, 57, 0.5);
}

.expected-pnl-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.expected-pnl-value {
    display: flex;
    align-items: baseline;
    gap: 8px;
    text-align: right;
}

.expected-pnl-amount {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.expected-pnl-amount.positive {
    color: var(--color-buy);
}

.expected-pnl-amount.negative {
    color: var(--color-sell);
}

.expected-pnl-percent {
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.expected-pnl-percent.positive {
    background: rgba(14, 203, 129, 0.15);
    color: var(--color-buy);
}

.expected-pnl-percent.negative {
    background: rgba(246, 70, 93, 0.15);
    color: var(--color-sell);
}

.expected-margin-amount,
.expected-total-amount {
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.expected-total-amount.positive {
    color: var(--color-buy);
}

.expected-total-amount.negative {
    color: var(--color-sell);
}

/* 모달 푸터 */
.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.modal-footer button {
    flex: 1;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#cancel-close-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

#cancel-close-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-light);
}

#confirm-close-btn {
    background: var(--color-sell);
    border: none;
    color: #fff;
}

#confirm-close-btn:hover {
    background: #d73451;
    box-shadow: 0 4px 12px rgba(246, 70, 93, 0.3);
}

#confirm-close-btn:active {
    transform: translateY(1px);
}

/* 입력 필드 스타일 개선 */
.modal-body .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.modal-body .input-wrapper input {
    width: 100%;
    padding: 12px;
    padding-right: 50px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-mono);
    transition: all 0.2s;
}

.modal-body .input-wrapper input:focus {
    outline: none;
    border-color: var(--color-brand);
    background: var(--bg-tertiary);
}

.modal-body .input-suffix {
    position: absolute;
    right: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    pointer-events: none;
}

/* 반응형 */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .modal-body {
        max-height: calc(100vh - 140px);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection Styling */
::selection {
    background: rgba(240, 185, 11, 0.3);
    color: var(--text-primary);
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 1;
    }
}

.loading-pulse {
    animation: pulse 1.5s infinite;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--color-buy);
}

.text-danger {
    color: var(--color-sell);
}

.text-warning {
    color: var(--color-brand);
}

.font-mono {
    font-family: var(--font-mono);
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}