/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #dc3545;
    --text-color: #1a1a1a;
    --text-muted: #6b6b6b;
    --bg-color: #f5f1ed;
    --card-bg: #ffffff;
    --border-color: #e5ddd5;
    --spacing-unit: 1rem;
    --border-radius: 12px;
    --section-spacing: 4rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    padding: 0.5rem;
    font-size: 0.9375rem;
}

/* API Dropdown */
.api-dropdown {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
}

.api-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e5ddd5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.api-toggle-btn:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
    transform: scale(1.05);
}

.api-panel {
    position: absolute;
    top: 48px;
    right: 0;
    width: 300px;
    background: #ffffff;
    border: 1px solid #e5ddd5;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.api-panel .input-group {
    margin-bottom: 0;
}

.api-panel .keys-note {
    color: #6b6b6b;
    font-size: 0.75rem;
    line-height: 1.4;
}

.btn-save {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-save:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(220, 53, 69, 0.2);
}

/* Container */
.container {
    max-width: 1680px;
    margin: 0 auto;
    background: #f5f1ed;
    padding: 0;
}

/* Hero Section Wrapper */
.hero-section {
    padding: 0 var(--spacing-unit);
    margin-bottom: var(--section-spacing);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
}

header .logo-icon {
    font-size: 2.5rem;
    color: #dc3545;
    margin-bottom: 8px;
}

header h1 {
    font-size: 1.25rem;
    color: #1a1a1a;
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: -0.025em;
}

header p {
    color: #6b6b6b;
    font-size: 0.8125rem;
    font-weight: 400;
}

/* Section Headings */
.container h2 {
    font-size: 1rem;
    margin: 8px 0 10px 0;
    color: #1a1a1a;
    font-weight: 600;
}

/* Floating Label Input Group */
.input-group {
    position: relative;
    display: flex;
    flex-direction: column;
}

.input-group label {
    position: absolute;
    left: 0;
    top: 12px;
    color: #9b9b9b;
    font-size: 0.875rem;
    font-weight: 400;
    pointer-events: none;
    transition: all 0.2s ease;
}

.input-group input,
.input-group textarea {
    padding: 12px 0;
    border: none;
    border-bottom: 1.5px solid #e5ddd5;
    font-size: 0.875rem;
    background-color: transparent;
    color: #1a1a1a;
    transition: border-color 0.2s ease;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group input:not(:placeholder-shown),
.input-group textarea:not(:placeholder-shown) {
    outline: none;
    border-bottom-color: #dc3545;
}

.input-group input:focus ~ label,
.input-group textarea:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label,
.input-group textarea:not(:placeholder-shown) ~ label {
    top: -8px;
    font-size: 0.75rem;
    color: #dc3545;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    transition: padding 0.3s ease, gap 0.3s ease;
    padding: 0 1%;
    width: 100%;
    box-sizing: border-box;
}

.main-content.initial .text-input,
.main-content.initial .links-verification {
    width: 100%;
    max-width: 1500px;
}

.main-content.expanded {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 28px;
    padding: 0 1%;
}

.main-content.expanded .text-input {
    flex: 0 0 30%;
    width: auto;
    max-width: none;
    min-width: 0;
}

.main-content.expanded .links-verification {
    flex: 0 0 70%;
    width: auto;
    max-width: none;
    min-width: 0;
}

.text-input,
.links-verification {
    transition: width 0.35s ease, flex-basis 0.35s ease, transform 0.35s ease, opacity 0.35s ease;
}

/* Button Row Container */
.button-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
}

/* Sample Text Buttons */
.sample-buttons {
    display: flex;
    gap: 12px;
}

.btn-sample {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-sample:hover {
    background: #dc3545;
    color: white;
}

/* Text Input Section */
.text-input {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e5ddd5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.text-input .input-group {
    flex: 1;
    margin-bottom: 12px;
}

.text-input textarea {
    width: 100%;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

/* Links Verification Section */
.links-verification {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e5ddd5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(12px);
}

.links-verification.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Links Output */
#links-output {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
}

/* Info Card / FAQ */
.info-card {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e5ddd5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-top: 16px;
}

.faq-section {
    width: 60%;
    max-width: 900px;
    margin: var(--section-spacing) auto 0 auto;
    padding: 0 calc(var(--spacing-unit) * 2);
}

.faq-section .faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.faq-item {
    border: 1px dashed #eadfd6;
    border-radius: 6px;
    background: #fffdfb;
}

.faq-item summary {
    cursor: pointer;
    padding: 10px 12px;
    list-style: none;
    font-weight: 600;
    color: #1a1a1a;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item[open] summary { color: #8b4513; }
.faq-item p, .faq-item code { padding: 0 12px 12px 12px; }
.faq-item code { background: #f5f1ed; padding: 2px 4px; border-radius: 4px; }

/* Inline Spinner for Status */
.status-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e5ddd5;
    border-top: 2px solid #dc3545;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* Buttons */
.btn-primary {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(220, 53, 69, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #d4bfb8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Tables */
table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

table th {
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #e5ddd5;
    font-weight: 600;
    color: #1a1a1a;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

table th:nth-child(1) { /* # */
    width: 40px;
}

table th:nth-child(2) { /* Link */
    width: 55%;
}

table th:nth-child(3) { /* Type */
    width: 80px;
}

table th:nth-child(4) { /* Status */
    width: 140px;
}

table th:nth-child(5) { /* Explanation */
    width: auto;
}

table td {
    padding: 14px 12px;
    border-bottom: 1px solid #f5f1ed;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}

table td:nth-child(3) { /* Type column */
    white-space: normal;
}

table td:nth-child(4) { /* Status column */
    white-space: normal;
}

table td:nth-child(5) { /* Explanation column */
    white-space: normal;
    position: relative;
    line-height: 1.6;
}

table td:nth-child(5) .explanation-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

table td.expanded .explanation-text {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
}

table td .expand-btn {
    color: #dc3545;
    cursor: pointer;
    font-size: 0.75rem;
    text-decoration: underline;
    display: inline-block;
    margin-top: 4px;
}

table td .expand-btn:hover {
    color: #c82333;
}

table tbody tr {
    transition: background-color 0.15s ease;
}

table tbody tr:hover {
    background-color: #faf8f6;
}

table td a {
    color: #1a1a1a;
    text-decoration: none;
    transition: color 0.15s ease;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

table td a:hover {
    color: #dc3545;
}

/* Footer */
.site-footer {
    margin-top: 24px;
    padding: 20px 12px;
    color: #5a5a5a;
    text-align: center;
}
.site-footer .footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    align-items: center;
    font-size: 0.8125rem;
    width: 100%;
}
.site-footer a { color: #1a1a1a; text-decoration: none; }
.site-footer a:hover { color: #dc3545; text-decoration: underline; }
.site-footer .dot { color: #b6aca4; }

/* Link Type Badges */
.link-type {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.link-type.citation {
    color: #8b4513;
    background: #fef3e8;
    border: 1px solid #f4e8d8;
}

.link-type.regular {
    color: #5a5a5a;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
}

/* Status Badges */
.status {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.status.pending {
    color: #6b6b6b;
    background: #e5ddd5;
}

.status.fetching {
    color: #5a5a5a;
    background: #d4c9bf;
}

.status.checking {
    color: #8b4513;
    background: #f4e8d8;
}

.status.verified {
    color: #1a1a1a;
    background: #d4e8d4;
}

.status.invalid {
    color: #ffffff;
    background: #dc3545;
}

.status.inaccurate {
    color: #ffffff;
    background: #e67e22;
}

/* Utility Classes */
.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 968px) {
    .main-content {
        flex-direction: column;
        padding: 16px; /* equal spacing around on mobile */
        gap: 16px;     /* equal spacing between sections */
    }

    /* Ensure stack order explicitly on mobile */
    .main-content .text-input { order: 1; }
    .main-content .links-verification { order: 2; }

    .button-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .sample-buttons {
        justify-content: center;
    }

    .btn-primary {
        width: 100%;
    }

    .main-content.initial .text-input,
    .main-content.initial .links-verification,
    .main-content.expanded .text-input,
    .main-content.expanded .links-verification {
        width: 100%;
        max-width: none;
    }

    .api-inputs {
        grid-template-columns: 1fr;
    }

    body {
        padding: 12px;
    }

    .hero-section {
        padding: 0 var(--spacing-unit);
    }

    .how-it-works {
        padding: calc(var(--spacing-unit) * 3) var(--spacing-unit);
    }

    .stats-section {
        flex-direction: column;
        gap: 1rem;
        margin: calc(var(--section-spacing) * 0.75) var(--spacing-unit);
    }

    .stat-card {
        width: 100%;
    }

    .faq-section {
        width: 100%;
        margin-top: calc(var(--section-spacing) * 0.75);
        padding: 0 var(--spacing-unit);
    }

    header h1 {
        font-size: 1.5rem;
    }

    .steps {
        flex-direction: column;
    }

    .step {
        max-width: 100%;
    }
}

/* Trust Indicators */
.trust-indicators {
    display: flex;
    justify-content: center;
    gap: calc(var(--spacing-unit) * 2);
    margin-top: calc(var(--spacing-unit) * 1.5);
    padding: calc(var(--spacing-unit) * 0.75) var(--spacing-unit);
    border-radius: calc(var(--border-radius) * 0.5);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.5);
}

.trust-item {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.trust-item i {
    font-size: 1rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* How It Works Section - Full Width */
.how-it-works {
    margin: 0 calc(-1 * (100vw - 100%) / 2);
    padding: calc(var(--spacing-unit) * 4) calc(var(--spacing-unit) * 2);
    background: var(--bg-color);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.how-it-works h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: calc(var(--spacing-unit) * 2.5);
    color: var(--text-color);
    font-weight: 700;
}

.steps {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.step {
    flex: 1;
    text-align: center;
    position: relative;
}

.step-number {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.step-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin: calc(var(--spacing-unit) * 1.5) 0 var(--spacing-unit) 0;
}

.step h3 {
    font-size: 1.125rem;
    color: var(--text-color);
    margin-bottom: calc(var(--spacing-unit) * 0.75);
    font-weight: 600;
}

.step p {
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* Stats Section */
.stats-section {
    display: flex;
    justify-content: center;
    gap: calc(var(--spacing-unit) * 1.5);
    margin: var(--section-spacing) calc(var(--spacing-unit) * 2);
    flex-wrap: wrap;
}

.stat-card {
    background: var(--card-bg);
    padding: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
    line-height: 1;
}

.stat-label {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 600;
    margin-bottom: calc(var(--spacing-unit) * 0.25);
}

.stat-description {
    font-size: 0.875rem;
    color: var(--text-muted);
}
