:root {
    --primary-color: #2563eb; /* Modern Blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #f8fafc; /* Slate 50 */
    --text-color: #1e293b; /* Slate 800 */
    --light-text-color: #64748b; /* Slate 500 */
    --border-color: #e2e8f0; /* Slate 200 */
    --card-bg: #ffffff;
    --accent-color: #f59e0b; /* Amber 500 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
    background-color: var(--secondary-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Hero */
#header {
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    padding: 4rem 1rem 5rem;
    text-align: center;
    margin-bottom: -2.5rem;
}

#header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.025em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#header p {
    color: rgba(255,255,255,0.9);
    margin-top: 0.75rem;
    font-size: 1.1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Main Container */
#search-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
    flex: 1;
    position: relative;
    z-index: 10;
}

/* Search Box */
.search-wrapper {
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.search-wrapper:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    border-color: var(--primary-color);
}

#search-box {
    flex-grow: 1;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-color);
    width: 100%;
}

#search-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    margin-right: 0.25rem;
}

#search-button:hover {
    background-color: var(--primary-hover);
}

/* Suggestions */
#search-suggestions {
    position: absolute;
    top: 100%;
    left: 1rem;
    right: 1rem;
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-top: 0.5rem;
    overflow: hidden;
    z-index: 100;
    display: none;
    border: 1px solid var(--border-color);
}

.suggestion-item {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid var(--secondary-color);
    transition: background-color 0.1s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover, .suggestion-item.highlighted {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

/* Results */
#results {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 1rem;
}

#results li {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
}

#results li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.medicine-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: block;
}

.medicine-description {
    color: var(--light-text-color);
    font-size: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
}

/* Details */
.details-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: none;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.detail-section {
    background: var(--secondary-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.detail-title {
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: none;
    padding-bottom: 0;
}

.detail-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.2em;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.detail-content {
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.7;
}

.detail-content ul,
.detail-content ol {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.detail-content li {
    padding-left: 0;
    margin-bottom: 0.5rem;
}

.detail-content li:last-child {
    margin-bottom: 0;
}

.detail-content.hidden {
    display: none;
}

.show-more-icon {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-left: 0.5rem;
    font-weight: bold;
    padding: 2px 8px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
    transition: all 0.2s;
}

.show-more-icon:hover {
    background: rgba(37, 99, 235, 0.2);
}

/* Footer */
footer {
    margin-top: auto;
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 3rem 1rem;
    text-align: center;
}

.disclaimer {
    max-width: 800px;
    margin: 0 auto;
    font-size: 0.875rem;
    color: var(--light-text-color);
    line-height: 1.8;
}

.disclaimer strong {
    color: var(--text-color);
}

/* Loading & Modal */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loader {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

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

.error-message {
    color: #ef4444;
    text-align: center;
    margin-bottom: 1rem;
    font-weight: 500;
    background: #fef2f2;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid #fee2e2;
}

/* Highlight */
.highlight {
    background-color: rgba(245, 158, 11, 0.2);
    color: #b45309;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 640px) {
    #header { padding-bottom: 4rem; }
    #header h1 { font-size: 1.75rem; }
    .search-wrapper { padding: 0.25rem; }
    #search-button { width: 3rem; height: 3rem; }
    #results li { padding: 1.25rem; }
}

/* Modal Styles (Preserved but modernized) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    position: relative;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--light-text-color);
    transition: color 0.2s;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--secondary-color);
}

.close-button:hover {
    color: var(--text-color);
    background: var(--border-color);
}
