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

:root {
    /* Custom Palette: Space Cadet, English Violet, Viridian, Bone, Champagne Pink */
    --primary-color: #417b5a;
    /* Viridian - links, accents */
    --secondary-color: #1f2041;
    /* Space Cadet - headings/dark accents */
    --accent-color: #4b3f72;
    /* English Violet - toggles/active states */

    --text-color: #1f2041;
    /* Space Cadet text */
    --text-light: #67579e;
    /* English Violet 600 */
    --border-color: #d9d8c7;
    /* Bone 600 */
    --bg-light: #f5f5f1;
    /* Bone 900 */
    --bg-white: #faf6f2;
    /* Champagne Pink 900 */
    --hover-bg: #f1e3d9;
    /* Champagne Pink 700 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-light);
}

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

/* Header */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Data Update Banner */
.data-update-banner {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-bottom: 1px solid #c8e6c9;
    padding: 0.5rem 0;
}

.data-update-banner .container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.update-icon {
    font-size: 1.25rem;
}

.update-text {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

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

@media (max-width: 768px) {
    .data-update-banner .container {
        font-size: 0.85rem;
    }

    .update-icon {
        font-size: 1rem;
    }
}

/* Main Content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    line-height: 1.2;
}

h2 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    color: var(--text-color);
}

/* Breadcrumbs */
.breadcrumbs {
    margin-bottom: 1.5rem;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.breadcrumbs li::after {
    content: '›';
    margin-left: 0.5rem;
    color: var(--text-light);
}

.breadcrumbs li:last-child::after {
    content: '';
}

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

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

.breadcrumbs li[aria-current="page"] {
    color: var(--text-color);
    font-weight: 500;
}

/* Program Links */
.program-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s, color 0.2s;
}

.program-link:hover {
    background-color: var(--hover-bg);
    text-decoration: underline;
}

/* Country List (for program pages and Special Rate of Duty) */
.country-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.country-item {
    padding: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-color);
    text-decoration: none;
}

.country-item a {
    color: var(--text-color);
    text-decoration: none;
    pointer-events: none;
}

.country-item .flag {
    font-size: 1.5em;
}

/* Override any link styles when country list is inside tables */
table .country-list,
table .country-item {
    color: var(--text-color);
}

table .country-item a,
table .country-list a {
    color: var(--text-color) !important;
    text-decoration: none !important;
    pointer-events: none;
}

/* Sections */
section {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* AI Summary Section */
.ai-summary {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
}

.ai-summary h2 {
    color: white;
    margin-top: 0;
}

.ai-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 0.375rem;
    backdrop-filter: blur(10px);
}

.ai-content em {
    opacity: 0.8;
}

/* Tree Header */
.tree-header {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 1rem;
    color: var(--text-light);
    font-weight: 600;
}

.tree-header .tree-code {
    width: 180px;
}

.tree-header .tree-description {
    flex: 1;
}

/* Tree View - Simple Indented List */
.tree-list,
.tree-view {
    /* keep legacy class for compatibility */
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.tree-node {
    margin: 0;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.tree-node:hover {
    background: var(--hover-bg);
}

.tree-node:last-child {
    border-bottom: 1px solid var(--border-color);
}

/* Commodity Code Column */
.tree-code {
    width: 180px;
    font-weight: 600;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
}

/* Description Column */
.tree-description {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.tree-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.tree-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Disabled links for heading-only items */
.tree-link.disabled {
    color: var(--text-color);
    text-decoration: none;
    cursor: default;
    pointer-events: none;
}

/* Back links */
.back-links {
    margin-top: 1rem;
}

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

.back-links a:hover {
    text-decoration: underline;
}

/* Small icon for back links */
.back-links a::before {
    content: "⤴️ ";
    display: inline-block;
    transform: translateY(1px);
    font-size: 0.95em;
}

/* Caret toggle inside description */
.tree-caret.tree-toggle {
    background: #f5f5f1;
    /* Bone 900 */
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
    width: 26px;
    height: 26px;
    min-width: 26px;
    /* Prevent squishing */
    min-height: 26px;
    /* Prevent squishing */
    flex-shrink: 0;
    /* Prevent squishing */
    border-radius: 50%;
    /* Ensure perfect circle */
    cursor: pointer;
    font-weight: 700;
    transition: all 0.15s ease-in-out;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 0.6rem;
    box-shadow: 0 0 0 2px #faf6f2, 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tree-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    transform: scale(1.05);
}

.tree-toggle.expanded {
    background: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
    transform: rotate(90deg) scale(1.05);
}

/* spacer no longer needed, keep for compatibility */
.tree-toggle-spacer {
    display: none;
}

/* Children Container */
.tree-children {
    display: none;
    margin-left: 1rem;
    /* small indentation per level */
    border-left: 1px dashed var(--border-color);
    padding-left: 0.5rem;
}

.tree-children .tree-item {
    border-bottom: 1px solid var(--border-color);
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

/* flag inline */
.flag {
    margin: 0 2px;
    font-size: 1.05em;
}

/* Program flags block */
.programs-block {
    margin-top: 0.5rem;
}

.program-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.15rem 0;
}

.program-code {
    background: var(--border-color);
    color: var(--secondary-color);
    border-radius: 9999px;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.program-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table thead th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-color);
}

.data-table tbody tr:hover {
    background: var(--hover-bg);
}

.data-table td:first-child {
    font-weight: 500;
    color: var(--text-color);
    width: 30%;
}

.data-table td:last-child {
    color: var(--text-light);
}

.data-table em {
    color: var(--text-light);
    font-style: italic;
}

/* Footer */
.site-footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    color: var(--text-light);
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .site-header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .main-nav {
        width: 100%;
        justify-content: center;
    }

    section {
        padding: 1rem;
    }

    .tree-header .tree-code {
        width: 140px;
    }

    .tree-code {
        width: 140px;
        font-size: 0.85rem;
    }

    .tree-item {
        padding: 0.5rem;
        font-size: 0.95rem;
    }

    .data-table {
        font-size: 0.875rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}

/* Loading Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

section {
    animation: fadeIn 0.3s ease-out;
}

/* About Page Styles */
.about-hero {
    text-align: center;
    padding: 3rem 1rem;
    background: transparent;
    border: none;
    margin-bottom: 0;
}

.headline {
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.sub-headline {
    font-size: 1.25rem;
    color: var(--text-light);
    max-width: 800px;
    margin: 0 auto;
}

.about-content h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.about-content ul {
    list-style: none;
    padding-left: 0;
    margin: 1.5rem 0;
}

.about-content li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.about-content li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Newsletter Section */
.newsletter-section {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    color: white;
    text-align: center;
    padding: 4rem 2rem;
    border: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    margin-top: 3rem;
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
}

/* Decorative circle background */
.newsletter-section::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.newsletter-section::after {
    content: "";
    position: absolute;
    bottom: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.newsletter-section h2 {
    color: white;
    font-size: 2.25rem;
    margin-bottom: 1rem;
    margin-top: 0;
    position: relative;
    z-index: 1;
}

.newsletter-section p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
}

.newsletter-form {
    display: flex;
    gap: 1rem;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.newsletter-form input[type="email"] {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.newsletter-form input[type="email"]:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(65, 123, 90, 0.5);
}

.newsletter-form button {
    padding: 0.875rem 2rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.newsletter-form button:hover {
    background-color: #2d5a40;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.newsletter-form button:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-form button {
        width: 100%;
    }

    .headline {
        font-size: 2rem;
    }
}

/* Home Page Hero Section */
.home-hero {
    background: linear-gradient(135deg, #1f2041 0%, #4b3f72 100%);
    color: white;
    text-align: center;
    padding: 4rem 2rem;
    border: none;
    border-radius: 1rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.home-hero::before {
    content: "";
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: white;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    max-width: 800px;
    margin: 0 auto 3rem;
    line-height: 1.6;
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.feature-item {
    text-align: center;
    padding: 1.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.feature-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.feature-item h3 {
    color: var(--secondary-color);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.feature-item p {
    color: var(--text-light);
    font-size: 0.95rem;
    margin: 0;
}

/* Waitlist Section */
.waitlist-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2d5a40 100%);
    color: white;
    text-align: center;
    padding: 3.5rem 2rem;
    border: none;
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

.waitlist-content h2 {
    color: white;
    font-size: 2.25rem;
    margin-bottom: 1rem;
    margin-top: 0;
}

.waitlist-content>p {
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.1rem;
    max-width: 650px;
    margin: 0 auto 2rem;
}

.waitlist-form {
    display: flex;
    gap: 1rem;
    justify-content: center;
    max-width: 550px;
    margin: 0 auto 1.5rem;
}

.waitlist-form input[type="email"] {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    font-size: 1rem;
    background: white;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.waitlist-form input[type="email"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(31, 32, 65, 0.3);
}

.btn-primary {
    padding: 1rem 2.5rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background-color: #161730;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

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

.waitlist-note {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

/* Explore Preview Section */
.explore-preview {
    text-align: center;
    padding: 3rem 2rem;
}

.explore-preview h2 {
    color: var(--secondary-color);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1rem;
}

.explore-preview p {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 700px;
    margin: 0 auto 2rem;
}

.btn-secondary {
    display: inline-block;
    padding: 0.875rem 2.5rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background-color: #2d5a40;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

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

/* Page intro text */
.page-intro {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 800px;
    margin: 0 auto 2rem;
    text-align: center;
}

/* Responsive adjustments for homepage */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .hero-features {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .waitlist-form {
        flex-direction: column;
    }

    .waitlist-form button,
    .btn-primary {
        width: 100%;
    }

    .waitlist-content h2 {
        font-size: 1.75rem;
    }

    .explore-preview h2 {
        font-size: 1.5rem;
    }
}

/* Netlify Forms - Hide honeypot spam protection */
.hidden {
    display: none;
}

/* Header Button */
.btn-header {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    margin-left: 1rem;
}

.btn-header:hover {
    background-color: #2d5a40;
    color: white;
}

@media (max-width: 768px) {
    .btn-header {
        margin-left: 0;
        margin-top: 0.5rem;
        display: inline-block;
    }
}