* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --success: #10b981;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "微軟正黑體", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--surface);
    font-size: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.main-nav {
    background: var(--text-primary);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.nav-menu a:hover {
    opacity: 0.8;
}

/* Breadcrumbs */
.breadcrumbs {
    background: var(--background);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.breadcrumbs a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 4px 6px var(--shadow);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

/* Main Content */
main {
    padding: 2rem 0;
}

/* Search Section */
.search-section {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

.filter-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-section input,
.filter-section select {
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.3s ease;
    background: var(--background);
}

.filter-section input:focus,
.filter-section select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}

.view-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-view {
    padding: 0.5rem 1rem;
    background: var(--background);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.btn-view:hover {
    border-color: var(--primary-color);
    background: var(--surface);
}

.btn-view.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#resultsCount {
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Table */
.table-container {
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    font-size: 0.95rem;
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    position: relative;
}

th.sortable:hover {
    background: #f1f5f9;
}

.sort-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    opacity: 0.5;
    font-size: 0.8rem;
}

th.sortable[data-sort-direction="asc"] .sort-indicator::after {
    content: " ▲";
    opacity: 1;
}

th.sortable[data-sort-direction="desc"] .sort-indicator::after {
    content: " ▼";
    opacity: 1;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: var(--surface);
}

tbody tr:last-child td {
    border-bottom: none;
}

.loading {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-secondary);
}

.no-results {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-secondary);
}

/* Active Ingredients */
.active-ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ingredient-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #dbeafe;
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Grid View */
.grid-container {
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.drug-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1.5rem;
    }
    
    .detail-info {
        grid-template-columns: 1fr;
    }

.drug-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.drug-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow-lg);
    border-color: var(--primary-color);
}

.drug-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.drug-card-holder {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.drug-card-permit {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
    display: inline-block;
}

.drug-card-ingredients {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.drug-card-ingredients-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Modal / Detail Page */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--background);
    margin: 2% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
    z-index: 10;
}

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

.detail-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    line-height: 1.3;
}

.detail-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-info-item {
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
}

.detail-info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-info-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.other-drugs-list {
    display: grid;
    gap: 1rem;
}

.other-drug-item {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.other-drug-item:hover {
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: 0 4px 8px var(--shadow);
}

.other-drug-name {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.other-drug-permit {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

#pageInfo {
    color: var(--text-secondary);
    font-weight: 500;
}

/* SEO Description Section */
.seo-description {
    background: var(--background);
    padding: 3rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--border);
}

.seo-description h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.seo-description p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1rem;
}

/* Contextual Intro */
.contextual-intro {
    background: var(--background);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.contextual-intro h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.contextual-intro p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* User Guide & FAQ */
.user-guide {
    background: var(--background);
    padding: 3rem 0;
    margin-top: 3rem;
}

.user-guide h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-size: 1.75rem;
}

.faq-section h3 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.faq-section p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 1rem;
}

/* Latest Articles */
.latest-articles {
    background: var(--background);
    padding: 3rem 0;
    margin-top: 2rem;
}

.latest-articles h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-size: 1.75rem;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.article-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow-lg);
    border-color: var(--primary-color);
}

.article-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.article-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.article-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

.view-all {
    text-align: center;
    margin-top: 2rem;
}

.btn-primary {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: white;
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.footer-section a:hover {
    opacity: 1;
}

.footer-section p {
    opacity: 0.9;
    line-height: 1.6;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1.5rem;
    text-align: center;
}

.footer-bottom p {
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.disclaimer {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 1rem !important;
}

/* Clickable table rows */
tbody tr {
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        flex-direction: column;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .filter-section {
        grid-template-columns: 1fr;
    }

    .drug-grid {
        grid-template-columns: 1fr;
    }
    
    @media (min-width: 768px) and (max-width: 1024px) {
        .drug-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }
    
    @media (min-width: 1025px) {
        .drug-grid {
            grid-template-columns: repeat(3, 1fr);
        }
    }

    .articles-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 800px;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .results-info {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .btn-secondary {
        width: 100%;
    }

    .pagination {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    header {
        padding: 1.5rem 0;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .search-section {
        padding: 1rem;
    }

    .seo-description {
        padding: 2rem 0;
    }

    .seo-description h2 {
        font-size: 1.5rem;
    }
}

/* Blog Post Styles */
.blog-post {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.blog-post article {
    line-height: 1.8;
}

.blog-post h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.blog-post .article-meta {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.blog-post h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.blog-post h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.blog-post p {
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: justify;
}

.blog-post a {
    color: var(--primary-color);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.blog-post a:hover {
    color: var(--primary-hover);
}

.blog-post ul,
.blog-post ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
}

.blog-post li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
    font-size: 1.1rem;
}

.blog-post strong {
    font-weight: 600;
    color: var(--text-primary);
}

.blog-post code {
    background: var(--surface);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.blog-post blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

.blog-post img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2rem 0;
    box-shadow: 0 4px 12px var(--shadow);
}

.blog-post .article-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.blog-post .article-navigation {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.blog-post .article-navigation a {
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-weight: 500;
}

.blog-post .article-navigation a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

/* Print Styles */
@media print {
    .search-section,
    .pagination,
    footer,
    .main-nav {
        display: none;
    }

    .table-container {
        box-shadow: none;
    }
    
    .blog-post {
        box-shadow: none;
        padding: 0;
    }
}

