/* assets/css/components.css */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    transition: all var(--transition-base);
    cursor: pointer;
    border: none;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-brand-secondary) 0%, var(--color-brand-primary) 100%);
    color: var(--color-text-inverted);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--color-brand-primary) 0%, var(--color-brand-primary) 100%);
}

.btn-accent {
    background-color: var(--color-accent);
    color: white;
}

.btn-accent:hover {
    background-color: var(--color-accent-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
}

.btn-outline:hover {
    border-color: var(--color-text-main);
    background-color: var(--color-bg-surface);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-full {
    width: 100%;
}

/* Cards & Glassmorphism */
.card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.glass-panel {
    background: var(--color-bg-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg);
}

/* Form Elements */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-xl);
    padding: var(--spacing-md) 0;
}

@media (max-width: 992px) {
    .docs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .docs-grid {
        grid-template-columns: 1fr;
    }
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text-main);
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--color-text-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.form-hint {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

/* Navbar Components */
.nav-link {
    font-weight: 500;
    color: var(--color-text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-text-main);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Navbar & Header */
.site-header {
    height: var(--header-height);
    background: var(--color-bg-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    position: sticky;
    top: 0;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: transform var(--transition-fast);
}

.site-logo:hover {
    transform: scale(1.02);
}

.site-logo img {
    height: 32px;
    width: auto;
}

.site-logo .logo-text {
    font-size: 1.25rem;
    margin: 0;
    font-family: var(--font-family-display);
    font-weight: 700;
    color: var(--color-brand-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.site-logo .accent {
    color: var(--color-accent);
}

.site-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: normal;
    opacity: 0.8;
}

@media (max-width: 1024px) {
    .site-subtitle {
        display: none;
    }
}

.site-nav-links {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Footer Components */
.footer-link {
    color: var(--color-text-muted);
}

.footer-link:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

/* Misc Utilities */
.btn-clean {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-muted);
    font-weight: 500;
    text-decoration: none;
    font-size: 1rem;
    position: relative;
    padding: 2px 0;
    transition: color 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* 放大图标 (覆盖文字+下划线高度) */
.btn-clean::before {
    content: "";
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.8' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z' /%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: filter 0.2s ease;
}

.btn-clean::after {
    content: "";
    position: absolute;
    bottom: 2px;
    left: 28px;
    /* 图标(22px) + 间距(6px) */
    width: calc(100% - 28px);
    height: 1px;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.btn-clean:hover {
    color: var(--color-accent);
}

.btn-clean:hover::after {
    background-color: var(--color-accent);
}

.btn-clean:hover::before {
    filter: brightness(0) saturate(100%) invert(42%) sepia(51%) saturate(735%) hue-rotate(174deg) brightness(91%) contrast(92%);
}

/* Footer Links Hover */
.footer-links a:hover {
    color: var(--color-accent) !important;
}



/* Documentation Layouts */
.docs-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: var(--spacing-2xl);
    align-items: start;
}

@media(max-width: 768px) {
    .docs-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
        /* Mobile handling needed for drawer later if necessary */
    }
}

.sidebar {
    position: sticky;
    top: 100px;
    padding-right: var(--spacing-md);
    border-right: 1px solid var(--color-border);
    height: calc(100vh - 150px);
    overflow-y: auto;
}

.sidebar-link {
    display: block;
    padding: var(--spacing-xs) 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: var(--color-brand-primary);
    font-weight: 700;
    /* Deeper highlight background for better contrast */
    background-color: #eff6ff;
    border-radius: 4px;
    padding-left: 12px;
}

.sidebar-link.active {
    position: relative;
    color: #003b75;
    /* Deep Blue */
    border-left: 4px solid #003b75;
    /* Left border indicator instead of triangle */
    padding-left: 8px;
    /* Adjust padding: 12px total - 4px border */
    background-color: #e0f2fe;
    /* Even clearer background */
}

.article-content {
    max-width: 800px;
}

.article-content h1 {
    margin-bottom: var(--spacing-sm);
}

.article-content h2 {
    margin-top: var(--spacing-xl);
    color: var(--color-text-main);
    margin-bottom: var(--spacing-md);
}

.article-content p {
    margin-bottom: var(--spacing-md);
    line-height: 1.6;
}

.article-content ul {
    list-style: disc;
    margin-left: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    color: var(--color-text-muted);
}

.article-content li {
    margin-bottom: var(--spacing-xs);
}

/* ==========================================================================
   Accordion & Collapsible Components (Standard for Articles/FAQs)
   ========================================================================== */
.accordion-group {
    margin-top: 0;
}

.accordion-item,
.faq-item {
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-bg-white);
    transition: all 0.3s ease;
}

.accordion-item:hover,
.faq-item:hover {
    border-color: var(--color-brand-primary-light, var(--color-brand-primary));
    box-shadow: var(--shadow-sm);
}

.accordion-item summary,
.faq-item summary {
    padding: var(--spacing-md) var(--spacing-lg);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #003b75;
    /* Deep Blue */
    background: rgba(var(--color-brand-primary-rgb, 59, 130, 246), 0.02);
    outline: none;
}

.accordion-item summary::-webkit-details-marker,
.faq-item summary::-webkit-details-marker {
    display: none;
}

.accordion-item summary::after,
.faq-item summary::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--color-accent);
    transition: transform 0.3s ease;
}

.accordion-item[open] summary::after,
.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.accordion-content,
.faq-content {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    line-height: 1.6;
    background: var(--color-bg-white);
}

.accordion-content ol,
.faq-content ol,
.accordion-content ul,
.faq-content ul {
    padding-left: 2rem;
    margin: var(--spacing-sm) 0;
}

.accordion-content li,
.faq-content li {
    margin-bottom: var(--spacing-xs);
}

/* Page Hero / Content Header */
.page-hero,
.faq-header {
    text-align: center;
    padding: var(--spacing-xl) 0;
    background: linear-gradient(135deg, rgba(var(--color-brand-primary-rgb, 59, 130, 246), 0.05) 0%, rgba(var(--color-brand-primary-rgb, 59, 130, 246), 0) 100%);
    border-bottom: 1px solid var(--color-border);
}

/* Professional Warning Component */
.professional-warning {
    background: #fffbeb;
    border: 2px solid #f59e0b;
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.professional-warning p {
    margin: 0 0 var(--spacing-sm) 0;
    line-height: 1.6;
    color: #78350f;
}

.professional-warning p:last-child {
    margin-bottom: 0;
}

.professional-warning strong {
    font-size: 1.1rem;
    color: #92400e;
}

/* Document Internal Links Upgrade */
.accordion-content a,
.professional-warning a {
    color: var(--color-accent);
    text-decoration: underline;
    font-weight: 600;
}

.accordion-content a:hover,
.professional-warning a:hover {
    color: var(--color-accent-hover);
}

/* ==========================================================================
   PFIC Specific Article Components (Ported from articles.css)
   ========================================================================== */
.step-number {
    background: var(--color-brand-primary);
    color: white;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
    margin-right: 12px;
    vertical-align: middle;
}

.pfic-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 1.5rem 0;
    align-items: start;
}

@media (max-width: 768px) {
    .pfic-two-col {
        grid-template-columns: 1fr;
    }
}

.pfic-table,
.pfic-csv-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.85rem;
}

.pfic-csv-table {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    width: fit-content;
    max-width: 100%;
}

.pfic-table th,
.pfic-table td,
.pfic-csv-table th,
.pfic-csv-table td {
    border: 1px solid var(--color-border);
    padding: 10px;
    text-align: left;
}

.pfic-csv-table th,
.pfic-csv-table td {
    padding: 6px 8px;
    white-space: normal;
    word-wrap: break-word;
    border: 1px solid #ccc;
}

.pfic-table th {
    background-color: var(--color-bg-alt);
    font-weight: 600;
}

.pfic-csv-table th {
    background: #e8e8e8;
    font-weight: 700;
    color: #333;
}

.pfic-csv-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.pfic-note {
    background-color: #f0f9ff;
    border-left: 4px solid var(--color-brand-primary);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
    color: var(--color-text-main);
}

.pfic-warning {
    background-color: #fffbeb;
    border-left: 4px solid var(--color-accent);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
    color: #78350f;
}

.video-intro-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.video-thumb-link {
    display: block;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: transform 0.2s ease;
}

.video-thumb-link:hover {
    transform: scale(1.02);
}

.video-thumb-link img {
    width: 100%;
    display: block;
}

.play-button-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-button-overlay::after {
    content: "";
    border-style: solid;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent #fff;
    margin-left: 5px;
}

.toc-sidebar {
    position: sticky;
    top: 100px;
}

.toc-sidebar ul {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.toc-sidebar li {
    margin-bottom: var(--spacing-xs);
}

.toc-sidebar a {
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.toc-sidebar a:hover {
    color: var(--color-brand-primary);
}

.pfic-img-preview {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.pfic-red {
    color: #c00000;
    font-weight: 600;
}

.pfic-mtm-warning {
    background-color: #fff7ed;
    border: 1px solid #fed7aa;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.highlight-fmv {
    background-color: #fffbeb;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

/* Documentation Footer */
.docs-footer {
    padding: 40px 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
    margin-top: 3rem;
}

.docs-footer p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Global Download Button */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-bg-alt);
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
    color: #0066cc;
    font-weight: 600;
    border: 1px solid var(--color-border);
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-download::before {
    content: "⬇";
    font-size: 1.1em;
    line-height: 1;
    color: #c00000;
    font-weight: bold;
    text-decoration: none;
}

.btn-download:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-brand-primary);
    color: #003b75;
    text-decoration-thickness: 2px;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-download svg {
    flex-shrink: 0;
}