/**
 * RDKit SMILES Visualization Styles
 * SMILES 분자 구조 시각화를 위한 CSS 스타일
 */

/* ========================================
   SMILES 구조 기본 스타일
   ======================================== */
.smiles-structure {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border: 1px solid #81C784;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #2E7D32;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    vertical-align: middle;
}

.smiles-structure:hover {
    background: linear-gradient(135deg, #C8E6C9 0%, #A5D6A7 100%);
    border-color: #66BB6A;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    transform: translateY(-1px);
}

.smiles-structure:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(76, 175, 80, 0.2);
}

/* 분자 아이콘 */
.smiles-structure .ico-molecule {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232E7D32' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Ccircle cx='19' cy='5' r='2'/%3E%3Ccircle cx='5' cy='5' r='2'/%3E%3Ccircle cx='19' cy='19' r='2'/%3E%3Ccircle cx='5' cy='19' r='2'/%3E%3Cline x1='12' y1='9' x2='12' y2='5'/%3E%3Cline x1='9.5' y1='13.5' x2='6' y2='17'/%3E%3Cline x1='14.5' y1='13.5' x2='18' y2='17'/%3E%3Cline x1='9.5' y1='10.5' x2='6' y2='7'/%3E%3Cline x1='14.5' y1='10.5' x2='18' y2='7'/%3E%3C/svg%3E") no-repeat center center;
    background-size: contain;
    flex-shrink: 0;
}

/* ========================================
   SMILES 툴팁 스타일
   ======================================== */
.smiles-tooltip {
    position: absolute;
    z-index: 10003;
    display: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 220px;
    animation: smilestooltipFadeIn 0.2s ease;
}

.smiles-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
}

.smiles-tooltip.smiles-tooltip-up::before {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid #fff;
}

@keyframes smilestooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.smiles-tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.smiles-tooltip-svg {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #FAFAFA;
    border-radius: 4px;
    padding: 8px;
    min-height: 100px;
}

.smiles-tooltip-svg svg {
    max-width: 100%;
    height: auto;
}

.smiles-tooltip-text {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    color: #666;
    text-align: center;
    word-break: break-all;
    padding: 4px 8px;
    background: #F5F5F5;
    border-radius: 4px;
}

/* ========================================
   SMILES 모달 스타일
   ======================================== */
.smiles-modal-wrap {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.smiles-modal-wrap.smiles-modal-active {
    opacity: 1;
}

.smiles-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.smiles-modal {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: smilesModalSlideIn 0.3s ease;
}

@keyframes smilesModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.smiles-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E8E8E8;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
}

.smiles-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2E7D32;
    display: flex;
    align-items: center;
    gap: 8px;
}

.smiles-modal-header h3::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232E7D32' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Ccircle cx='19' cy='5' r='2'/%3E%3Ccircle cx='5' cy='5' r='2'/%3E%3Ccircle cx='19' cy='19' r='2'/%3E%3Ccircle cx='5' cy='19' r='2'/%3E%3Cline x1='12' y1='9' x2='12' y2='5'/%3E%3Cline x1='9.5' y1='13.5' x2='6' y2='17'/%3E%3Cline x1='14.5' y1='13.5' x2='18' y2='17'/%3E%3Cline x1='9.5' y1='10.5' x2='6' y2='7'/%3E%3Cline x1='14.5' y1='10.5' x2='18' y2='7'/%3E%3C/svg%3E") no-repeat center center;
    background-size: contain;
}

.smiles-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.smiles-modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

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

.smiles-modal-svg {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #FAFAFA;
    border: 1px solid #E8E8E8;
    border-radius: 8px;
    padding: 20px;
    min-height: 200px;
    margin-bottom: 16px;
}

.smiles-modal-svg svg {
    max-width: 100%;
    height: auto;
}

.smiles-modal-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.smiles-info-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    background: #F5F5F5;
    border-radius: 6px;
}

.smiles-info-label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
    flex-shrink: 0;
    min-width: 70px;
}

.smiles-info-value {
    color: #333;
    font-size: 14px;
    word-break: break-all;
}

.smiles-info-value.smiles-code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: #E8F5E9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #2E7D32;
}

.smiles-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #E8E8E8;
    background: #FAFAFA;
}

.smiles-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.smiles-btn-copy {
    background: #4CAF50;
    color: #fff;
}

.smiles-btn-copy:hover {
    background: #43A047;
}

.smiles-btn-close {
    background: #E8E8E8;
    color: #333;
}

.smiles-btn-close:hover {
    background: #D0D0D0;
}

/* ========================================
   반응형 스타일
   ======================================== */
@media screen and (max-width: 768px) {
    .smiles-structure {
        font-size: 12px;
        padding: 2px 6px;
    }

    .smiles-structure .ico-molecule {
        width: 14px;
        height: 14px;
    }

    .smiles-tooltip {
        min-width: 180px;
        padding: 10px;
    }

    .smiles-modal {
        width: 95%;
        max-height: 85vh;
    }

    .smiles-modal-header {
        padding: 12px 16px;
    }

    .smiles-modal-header h3 {
        font-size: 16px;
    }

    .smiles-modal-body {
        padding: 16px;
    }

    .smiles-modal-svg {
        padding: 16px;
        min-height: 150px;
    }

    .smiles-modal-footer {
        padding: 12px 16px;
    }
}

/* ========================================
   다크 모드 지원 (선택 사항)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .smiles-structure {
        background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%);
        border-color: #43A047;
        color: #E8F5E9;
    }

    .smiles-structure:hover {
        background: linear-gradient(135deg, #2E7D32 0%, #388E3C 100%);
        border-color: #66BB6A;
    }

    .smiles-structure .ico-molecule {
        filter: brightness(2);
    }
}

/* ========================================
   화학식 (Chemical Formula) 스타일
   ======================================== */
.chemical-formula {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border: 1px solid #64B5F6;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #1565C0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    vertical-align: middle;
}

.chemical-formula:hover {
    background: linear-gradient(135deg, #BBDEFB 0%, #90CAF9 100%);
    border-color: #42A5F5;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
    transform: translateY(-1px);
}

.chemical-formula:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(33, 150, 243, 0.2);
}

/* 화학식 아래첨자 스타일 */
.chemical-formula sub {
    font-size: 0.75em;
    vertical-align: sub;
}

/* 화학식 아이콘 */
.chemical-formula .ico-formula {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231565C0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5z'/%3E%3Cpath d='M2 17l10 5 10-5'/%3E%3Cpath d='M2 12l10 5 10-5'/%3E%3C/svg%3E") no-repeat center center;
    background-size: contain;
    flex-shrink: 0;
}

/* ========================================
   화학식 툴팁 스타일
   ======================================== */
.formula-tooltip {
    position: absolute;
    z-index: 10003;
    display: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 220px;
    animation: formulaTooltipFadeIn 0.2s ease;
}

.formula-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
}

.formula-tooltip.formula-tooltip-up::before {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid #fff;
}

@keyframes formulaTooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.formula-tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.formula-tooltip-svg {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #FAFAFA;
    border-radius: 4px;
    padding: 8px;
    min-height: 100px;
}

.formula-tooltip-svg svg {
    max-width: 100%;
    height: auto;
}

.formula-tooltip-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.formula-tooltip-formula {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    color: #1565C0;
    text-align: center;
    padding: 4px;
    background: #E3F2FD;
    border-radius: 4px;
}

.formula-tooltip-smiles {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    color: #666;
    text-align: center;
    word-break: break-all;
    padding: 2px 4px;
    background: #F5F5F5;
    border-radius: 4px;
}

.formula-tooltip-name {
    font-size: 11px;
    color: #888;
    text-align: center;
    font-style: italic;
}

/* 로딩 상태 */
.formula-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: #666;
    font-size: 13px;
}

.formula-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #E0E0E0;
    border-top-color: #1565C0;
    border-radius: 50%;
    animation: formulaSpin 0.8s linear infinite;
}

@keyframes formulaSpin {
    to {
        transform: rotate(360deg);
    }
}

/* 에러 상태 */
.formula-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    color: #E53935;
    font-size: 13px;
    background: #FFEBEE;
    border-radius: 4px;
}

/* ========================================
   화학식 모달 스타일 (SMILES 모달 확장)
   ======================================== */
.formula-modal-header {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%) !important;
}

.formula-modal-header h3 {
    color: #1565C0 !important;
}

.formula-modal-header h3::before {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231565C0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5z'/%3E%3Cpath d='M2 17l10 5 10-5'/%3E%3Cpath d='M2 12l10 5 10-5'/%3E%3C/svg%3E") no-repeat center center !important;
}

/* 화학식 표시 스타일 */
.formula-display {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: #E3F2FD !important;
    color: #1565C0 !important;
    padding: 2px 6px;
    border-radius: 4px;
}

/* 로딩 모달 */
.formula-loading-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
    text-align: center;
}

.formula-spinner-large {
    width: 40px;
    height: 40px;
    border: 3px solid #E0E0E0;
    border-top-color: #1565C0;
    border-radius: 50%;
    animation: formulaSpin 0.8s linear infinite;
}

.formula-loading-large p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.formula-loading-large strong {
    color: #1565C0;
}

/* 에러 모달 */
.formula-error-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
}

.formula-error-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFEBEE;
    color: #E53935;
    font-size: 24px;
    font-weight: bold;
    border-radius: 50%;
}

.formula-error-large p {
    margin: 0;
    color: #333;
    font-size: 14px;
}

.formula-error-hint {
    color: #888 !important;
    font-size: 12px !important;
}

/* PubChem 링크 스타일 */
.smiles-info-value a {
    color: #1565C0;
    text-decoration: none;
    transition: color 0.2s;
}

.smiles-info-value a:hover {
    color: #0D47A1;
    text-decoration: underline;
}

/* ========================================
   반응형 스타일 (화학식)
   ======================================== */
@media screen and (max-width: 768px) {
    .chemical-formula {
        font-size: 12px;
        padding: 2px 6px;
    }

    .chemical-formula .ico-formula {
        width: 14px;
        height: 14px;
    }

    .formula-tooltip {
        min-width: 180px;
        padding: 10px;
    }
}
