/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* === Header === */
header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 1rem;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none;
}

header nav a {
    color: #555;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s;
}

header nav a:hover {
    background: #f0f0f0;
    color: #333;
}

/* === Main === */
main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* === Tool Page === */
.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.tool-header p {
    color: #666;
    font-size: 1rem;
}

/* === Upload Zone === */
.upload-zone {
    background: linear-gradient(135deg, #f0f5ff 0%, #f8f9ff 100%);
    border: 2px dashed #b0c4f5;
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: #2563eb;
    background: linear-gradient(135deg, #e8efff 0%, #f0f5ff 100%);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
}

.upload-icon {
    color: #5b8def;
    margin-bottom: 1rem;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
    color: #2563eb;
}

.upload-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.25rem;
}

.upload-subtext {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.upload-btn {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border: none;
}

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

.upload-limit {
    color: #aaa;
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

/* === File Info === */
.file-info {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

#file-name {
    font-weight: 500;
    color: #333;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#file-size {
    color: #888;
    white-space: nowrap;
}

.btn-clear {
    background: none;
    border: none;
    color: #999;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.btn-clear:hover {
    color: #e53e3e;
}

/* === Processing === */
.processing {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing p {
    color: #666;
    font-size: 0.95rem;
}

/* === Error === */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* === Result Area === */
.result-area {
    margin-top: 1.5rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.result-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #666;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    background: #fff;
    border: 1px solid #d0d0d0;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    color: #333;
}

.btn-action:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.btn-action.copied {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #065f46;
}

.result-text {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
    color: #333;
}

.result-text:focus {
    outline: none;
    border-color: #2563eb;
}

/* === SEO Content === */
.seo-content {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e0e0e0;
}

.seo-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: #1a1a1a;
}

.seo-content h2:first-child {
    margin-top: 0;
}

.seo-content p,
.seo-content li {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.7;
}

.seo-content ol,
.seo-content ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.seo-content li {
    margin-bottom: 0.5rem;
}

/* === Text Converter (CSV/JSON tools) === */
.text-converter {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.text-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.text-input {
    width: 100%;
    min-height: 280px;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
    color: #333;
    flex: 1;
}

.text-input:focus {
    outline: none;
    border-color: #2563eb;
}

.text-controls {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.result-stats-inline {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #666;
}

/* === Homepage === */
.homepage {
    text-align: center;
}

/* === Hero Section === */
.hero {
    margin-bottom: 2.5rem;
    padding: 2.5rem 1.5rem 2rem;
    background: linear-gradient(135deg, #eef2ff 0%, #f0f5ff 50%, #faf5ff 100%);
    border-radius: 16px;
}

.hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.hero p {
    color: #555;
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.hero .hero-formats {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.hero .hero-formats span {
    display: inline-block;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
}

/* === Section Titles === */
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 1rem;
    margin-top: 0.5rem;
}

/* === Tool Grid === */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.tool-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    position: relative;
    text-align: center;
}

.tool-card:hover {
    border-color: #2563eb;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
    transform: translateY(-2px);
}

.tool-card-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

/* Category icon colors */
.tool-card-doc .tool-card-icon {
    background: #fef2f2;
    color: #dc2626;
}
.tool-card-doc:hover .tool-card-icon {
    background: #fee2e2;
}

.tool-card-data .tool-card-icon {
    background: #ecfdf5;
    color: #059669;
}
.tool-card-data:hover .tool-card-icon {
    background: #d1fae5;
}

.tool-card-encode .tool-card-icon {
    background: #fffbeb;
    color: #d97706;
}
.tool-card-encode:hover .tool-card-icon {
    background: #fef3c7;
}

.tool-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.25rem;
}

.tool-card p {
    font-size: 0.82rem;
    color: #777;
    line-height: 1.4;
}

/* === Trust Signals === */
.trust-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    margin-bottom: 2.5rem;
    text-align: center;
}

.trust-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 1.25rem;
}

.trust-badges {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #555;
    font-weight: 500;
}

.trust-badge svg {
    flex-shrink: 0;
}

/* === Features === */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    text-align: center;
}

.feature {
    padding: 1.25rem 1rem;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #eee;
}

.feature-icon {
    color: #2563eb;
    margin-bottom: 0.75rem;
}

.feature h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.35rem;
}

.feature p {
    font-size: 0.82rem;
    color: #777;
    line-height: 1.5;
}

/* === Ad Slots === */
.ad-slot {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-top {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.ad-placeholder {
    width: 100%;
    max-width: 728px;
    height: 90px;
    background: #f8f8f8;
    border: 1px dashed #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

/* === FAQ Section === */
.faq-section {
    margin-top: 2rem;
}

.faq-section h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

.faq-item {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background: #fff;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: #333;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.faq-question:hover {
    background: #f8f9fa;
}

.faq-question::after {
    content: '+';
    font-size: 1.2rem;
    color: #999;
    font-weight: 400;
    transition: transform 0.2s;
}

.faq-item.open .faq-question::after {
    content: '−';
}

.faq-answer {
    display: none;
    padding: 0 1rem 0.85rem;
    font-size: 0.88rem;
    color: #555;
    line-height: 1.6;
}

.faq-item.open .faq-answer {
    display: block;
}

/* === Related Tools === */
.related-tools {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #e0e0e0;
}

.related-tools h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 1rem;
    text-align: center;
}

.related-tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.related-tool-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.related-tool-card:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.related-tool-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.15rem;
}

.related-tool-card p {
    font-size: 0.78rem;
    color: #888;
}

/* === Legal Pages === */
.legal-page {
    max-width: 700px;
    margin: 0 auto;
}

.legal-page h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.25rem;
}

.legal-updated {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

.legal-page h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 1.5rem 0 0.5rem;
}

.legal-page p,
.legal-page li {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.7;
}

.legal-page ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.legal-page li {
    margin-bottom: 0.35rem;
}

.legal-page a {
    color: #2563eb;
    text-decoration: none;
}

.legal-page a:hover {
    text-decoration: underline;
}

/* === Footer === */
footer {
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 1.25rem 1rem;
    margin-top: auto;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}

.footer-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.75rem;
}

.footer-tools a {
    color: #666;
    text-decoration: none;
    font-size: 0.78rem;
}

.footer-tools a:hover {
    color: #2563eb;
    text-decoration: underline;
}

.footer-links {
    margin-bottom: 0.5rem;
}

.nav-all {
    font-weight: 600;
    color: #2563eb !important;
}

.footer-links a {
    color: #888;
    text-decoration: none;
    font-size: 0.8rem;
    margin: 0 0.75rem;
}

.footer-links a:hover {
    color: #555;
    text-decoration: underline;
}

footer p {
    color: #999;
    font-size: 0.8rem;
}

/* === Header Nav === */
header nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* === Button Helpers === */
.btn-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-secondary {
    background: #fff;
    color: #2563eb;
    border: 1px solid #2563eb;
}

.btn-secondary:hover {
    background: #eff6ff;
}

/* === Responsive === */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 0;
        gap: 0.5rem;
    }

    header nav {
        justify-content: center;
    }

    header nav a {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }

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

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

    .text-converter {
        flex-direction: column;
    }

    .text-controls {
        justify-content: center;
        padding: 0.5rem 0;
    }

    .trust-badges {
        gap: 1rem;
    }

    .related-tools-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .tool-header h1 {
        font-size: 1.35rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero {
        padding: 1.5rem 1rem;
    }

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

    .upload-zone {
        padding: 2rem 1rem;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
    }

    .btn-action {
        flex: 1;
        text-align: center;
    }
}
