/* 全域樣式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基礎樣式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei',
        'PingFang TC', 'Noto Sans TC', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* 主容器 */
.container {
    max-width: 900px;
    margin: 0 auto;
}

/* 頭部區域 */
header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease-out;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* 主要內容區域 */
main {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.6s ease-out;
}

/* 搜尋框區域 */
.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

#drugInput {
    flex: 1;
    padding: 14px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-family: inherit;
}

#drugInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#drugInput::placeholder {
    color: #999;
}

#searchBtn {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

#searchBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#searchBtn:active {
    transform: translateY(0);
}

#searchBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 載入中狀態 */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 結果區域 */
.results {
    animation: fadeIn 0.4s ease-out;
}

.results h2 {
    color: #333;
    margin-bottom: 24px;
    font-size: 1.5rem;
}

/* 交互作用項目 */
.interaction-item {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    animation: slideIn 0.4s ease-out;
}

.interaction-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateX(4px);
}

.interaction-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.index {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.drug-name {
    color: #764ba2;
    font-weight: 600;
    font-size: 16px;
}

.interaction-description {
    color: #555;
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 無結果訊息 */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 18px;
}

/* 錯誤訊息 */
.error {
    background: #fee;
    color: #c33;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #c33;
    margin-bottom: 16px;
}

/* 頁尾 */
footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    opacity: 0.8;
    font-size: 14px;
}

/* 動畫效果 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 響應式設計 - 平板 */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    header .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 24px;
    }

    .search-box {
        flex-direction: column;
    }

    #searchBtn {
        width: 100%;
    }

    .interaction-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 響應式設計 - 手機 */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    main {
        padding: 20px;
    }

    #drugInput,
    #searchBtn {
        font-size: 14px;
        padding: 12px 16px;
    }

    .results h2 {
        font-size: 1.2rem;
    }

    .interaction-item {
        padding: 16px;
    }

    .interaction-description {
        font-size: 14px;
    }
}

/* 列印樣式 */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .search-box,
    footer {
        display: none;
    }

    main {
        box-shadow: none;
        padding: 20px;
    }

    .interaction-item {
        page-break-inside: avoid;
    }
}