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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #fafafa;
    color: #222;
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* Prevent horizontal overflow on mobile */
img, video, iframe, canvas { max-width: 100%; height: auto; }

/* Ensure tap targets are accessible */
button, a, input, select, textarea { -webkit-tap-highlight-color: rgba(0,0,0,0.05); }

/* ========== NAVBAR ========== */
.navbar {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
}

.logo i {
    color: #e74c3c;
    margin-right: 4px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex-shrink: 1;
    min-width: 0;
}

.nav-tool {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.nav-tool:hover {
    background: #f0f0f0;
    color: #111;
}

.nav-tool.active {
    background: #111;
    color: #fff;
}

/* ========== NAV DROPDOWNS ========== */
.nav-dropdown {
    position: relative;
}
.nav-dropdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}
.dd-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}
.nav-dropdown:hover .dd-arrow,
.nav-dropdown.open .dd-arrow {
    transform: rotate(180deg);
}
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 6px;
    min-width: 170px;
    z-index: 200;
    list-style: none;
}
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
    display: block;
}
.dropdown-menu li { width: 100%; }
.dropdown-menu .nav-tool {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border-radius: 6px;
    white-space: nowrap;
}
.dropdown-menu .nav-tool:hover {
    background: #f0f0f0;
}
.dropdown-menu .nav-tool.active {
    background: #111;
    color: #fff;
}
.nav-dropdown-toggle.has-active {
    background: #111;
    color: #fff;
}

/* ========== PAGES ========== */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ========== HERO ========== */
.page-hero {
    padding: 48px 20px 40px;
    text-align: center;
}

.hero-inner {
    max-width: 600px;
    margin: 0 auto;
}

.hero-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.hero-icon i {
    font-size: 1.4rem;
    color: #fff;
}

.page-hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111;
    margin-bottom: 10px;
}

.page-hero p {
    font-size: 1rem;
    color: #555;
    line-height: 1.7;
}

/* ========== TOOL BODY ========== */
.tool-body {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* ========== UPLOAD BOX ========== */
.upload-box {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #fff;
    margin-bottom: 20px;
}

.upload-box:hover,
.upload-box.dragover {
    border-color: #999;
    background: #fafafa;
}

.upload-icon {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 12px;
}

.upload-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
}

.upload-sub {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 16px;
}

.pick-btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.pick-btn:hover {
    opacity: 0.85;
}

/* ========== FILE INFO ========== */
.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    flex-wrap: wrap;
}

.file-info i { color: #888; }

.file-info .file-name {
    flex: 1;
    font-weight: 500;
    color: #222;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info .file-size {
    color: #888;
}

.file-info .file-remove {
    color: #c0392b;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 0.95rem;
    padding: 2px 4px;
}

/* ========== PROGRESS ========== */
.progress-wrap {
    margin-bottom: 20px;
}

.pbar {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.pfill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.ptext {
    font-size: 0.82rem;
    color: #888;
    margin-top: 6px;
    text-align: center;
}

/* ========== RESULT AREA ========== */
.result-area {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.result-area h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #222;
}

/* Table */
.table-scroll {
    max-height: 380px;
    overflow: auto;
    border: 1px solid #eee;
    border-radius: 8px;
}

.table-scroll table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.table-scroll th,
.table-scroll td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.table-scroll th {
    background: #f7f7f7;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.table-scroll tr:hover td {
    background: #fafafa;
}

/* OCR */
.ocr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.ocr-grid h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.ocr-img {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #eee;
    background: #f9f9f9;
}

.ocr-textarea {
    width: 100%;
    height: 320px;
    padding: 12px;
    font-size: 0.88rem;
    line-height: 1.7;
    border: 1px solid #eee;
    border-radius: 8px;
    resize: vertical;
    background: #f9f9f9;
    color: #222;
    font-family: inherit;
}

.ocr-stats {
    display: flex;
    gap: 20px;
    padding: 8px 0;
    font-size: 0.82rem;
    color: #888;
}

.ocr-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Image grid */
.img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.img-card {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}

.img-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.img-card-foot {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.img-card-foot .img-name {
    font-size: 0.78rem;
    color: #444;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 110px;
}

.img-card-foot .dl-one {
    color: #333;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 0.9rem;
    padding: 2px;
}

.img-card-foot .dl-one:hover {
    color: #000;
}

/* Download btn */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 26px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
    transition: opacity 0.2s;
}

.download-btn:hover {
    opacity: 0.85;
}

/* ========== HOW IT WORKS ========== */
.how-section {
    margin-top: 48px;
    margin-bottom: 36px;
}

.how-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #111;
    margin-bottom: 20px;
    text-align: center;
}

.steps-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.step-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.step-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 6px;
}

.step-card p {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
}

/* ========== FAQ ========== */
.faq-section {
    margin-bottom: 24px;
}

.faq-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #111;
    margin-bottom: 14px;
}

details {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

details summary {
    padding: 14px 18px;
    font-size: 0.92rem;
    font-weight: 500;
    color: #222;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

details summary::-webkit-details-marker { display: none; }

details summary::after {
    content: "+";
    font-size: 1.1rem;
    font-weight: 400;
    color: #999;
    transition: transform 0.2s;
}

details[open] summary::after {
    content: "-";
}

details p {
    padding: 0 18px 14px;
    font-size: 0.88rem;
    color: #555;
    line-height: 1.6;
}

/* ========== SEO DETAILS SECTION ========== */
.seo-details {
    max-width: 800px;
    margin: 48px auto 0;
    padding: 0 20px;
}
.seo-details h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 14px;
}
.seo-details h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    margin-top: 24px;
    margin-bottom: 8px;
}
.seo-details p {
    font-size: 0.92rem;
    color: #555;
    line-height: 1.75;
    margin-bottom: 10px;
}
.seo-details strong {
    color: #333;
}
.seo-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 16px;
}
.seo-list li {
    position: relative;
    padding: 8px 0 8px 26px;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}
.seo-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #27ae60;
    font-weight: 700;
    font-size: 0.95rem;
}

/* ========== FOOTER ========== */
.site-footer {
    background: #fff;
    border-top: 1px solid #e5e5e5;
    padding: 24px 20px;
    text-align: center;
}

.footer-inner p {
    font-size: 0.82rem;
    color: #888;
    margin-bottom: 4px;
}

.footer-inner .footer-copy {
    color: #bbb;
    font-size: 0.78rem;
}

.footer-links {
    display: flex;
    gap: 18px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 10px 0;
}
.footer-tool-link {
    color: #999;
    font-size: 0.82rem;
    text-decoration: none;
    transition: color 0.2s;
}
.footer-tool-link:hover {
    color: #555;
    text-decoration: underline;
}

.footer-inner i {
    margin-right: 4px;
    color: #27ae60;
}

/* ========== FONT DETECTED INFO ========== */
.font-detected {
    padding: 10px 14px;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #444;
    margin-bottom: 14px;
    line-height: 1.6;
}

.font-detected i {
    color: #2980b9;
    margin-right: 4px;
}

.font-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 6px;
}

.font-tag.converted {
    background: #d4edda;
    color: #155724;
}

/* ========== FONT PICKER (PDF) ========== */
.font-picker {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 16px;
}

.font-picker label {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 10px;
}

.font-picker label i {
    color: #e74c3c;
    margin-right: 6px;
}

.font-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.font-radio {
    cursor: pointer;
}

.font-radio input[type="radio"] {
    display: none;
}

.font-chip {
    display: inline-block;
    padding: 8px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #444;
    background: #fafafa;
    transition: all 0.2s;
}

.font-radio input[type="radio"]:checked + .font-chip {
    border-color: #e74c3c;
    background: #fff5f5;
    color: #e74c3c;
    font-weight: 600;
}

.font-chip:hover {
    border-color: #ccc;
    background: #f5f5f5;
}

.font-hint {
    font-size: 0.78rem;
    color: #999;
    margin-top: 10px;
}

/* ========== LANGUAGE PICKER ========== */
.lang-picker {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 16px;
}

.lang-picker label {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 10px;
}

.lang-picker label i {
    color: #2980b9;
    margin-right: 6px;
}

.lang-group {
    margin-bottom: 12px;
}

.lang-group-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.lang-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lang-chip-label {
    cursor: pointer;
}

.lang-chip-label input[type="checkbox"] {
    display: none;
}

.lang-chip {
    display: inline-block;
    padding: 6px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    font-size: 0.82rem;
    color: #555;
    background: #fafafa;
    transition: all 0.15s;
    user-select: none;
}

.lang-chip:hover {
    border-color: #bbb;
    background: #f0f0f0;
}

.lang-chip-label input[type="checkbox"]:checked + .lang-chip {
    border-color: #2980b9;
    background: #eef5ff;
    color: #2980b9;
    font-weight: 600;
}

.more-langs {
    background: none;
    border: none;
    margin-top: 4px;
}

.more-langs summary {
    font-size: 0.82rem;
    color: #2980b9;
    cursor: pointer;
    padding: 6px 0;
    font-weight: 500;
    border: none;
}

.more-langs summary::after {
    content: none;
}

.more-langs[open] summary {
    margin-bottom: 10px;
}

.lang-hint {
    font-size: 0.78rem;
    color: #999;
    margin-top: 8px;
}

/* ========== HELPERS ========== */
.hidden { display: none !important; }

/* ========== TEXT / WORD PREVIEW ========== */
.text-preview-box {
    max-height: 400px;
    overflow: auto;
    padding: 16px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.7;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    margin-bottom: 8px;
}

.word-preview-box {
    max-height: 500px;
    overflow: auto;
    padding: 24px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.7;
    color: #222;
    margin-bottom: 8px;
}

.word-preview-box h1, .word-preview-box h2, .word-preview-box h3 {
    margin: 16px 0 8px;
    color: #111;
}

.word-preview-box p {
    margin-bottom: 10px;
}

.word-preview-box table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.word-preview-box td, .word-preview-box th {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}

.word-preview-box img {
    max-width: 100%;
    height: auto;
}

/* ========== MERGE PDF FILE LIST ========== */
.merge-file-list { margin-top: 24px; }
.merge-file-list h3 { font-size: 1.1rem; margin-bottom: 4px; }
.merge-hint { font-size: 0.85rem; color: #888; margin-bottom: 12px; }
.merge-hint i { margin-right: 4px; }
#mpdf-sortable { list-style: none; padding: 0; margin: 0 0 16px; }
.merge-file-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: #f9f9f9; border: 1px solid #e0e0e0;
    border-radius: 8px; margin-bottom: 6px; cursor: grab;
    transition: box-shadow 0.15s, background 0.15s;
}
.merge-file-item:hover { background: #f1f1f1; }
.merge-file-item.dragging { opacity: 0.4; }
.merge-file-item.drag-over { box-shadow: 0 0 0 2px #2c3e50; background: #eaf2f8; }
.merge-grip { color: #bbb; cursor: grab; }
.merge-file-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merge-file-size { color: #999; font-size: 0.85rem; white-space: nowrap; }
.merge-remove-btn {
    background: none; border: none; color: #e74c3c; cursor: pointer;
    font-size: 1rem; padding: 4px 8px; border-radius: 4px;
    transition: background 0.15s;
}
.merge-remove-btn:hover { background: #fde8e8; }
.merge-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ========== RESPONSIVE ========== */

/* ------- Tablet & small desktop ------- */
@media (max-width: 900px) {
    .nav-inner { gap: 20px; }
    .seo-details { padding: 0 16px; }
}

/* ------- Mobile ------- */
@media (max-width: 700px) {
    .nav-inner {
        flex-direction: column;
        height: auto;
        padding: 10px 16px;
        gap: 8px;
    }
    .nav-links {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
        overflow-x: visible;
    }
    .nav-tool { padding: 7px 12px; font-size: 0.82rem; }

    /* Dropdowns center-align on mobile */
    .nav-dropdown { position: static; }
    .dropdown-menu {
        position: absolute;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        min-width: 180px;
    }

    .page-hero { padding: 28px 16px 24px; }
    .page-hero h1 { font-size: 1.3rem; }
    .page-hero p { font-size: 0.92rem; }

    .tool-body { padding: 0 14px 36px; }
    .upload-box { padding: 28px 14px; }
    .upload-icon { font-size: 1.8rem; }
    .upload-title { font-size: 0.95rem; }
    .pick-btn { padding: 11px 20px; font-size: 0.88rem; min-height: 44px; }

    .result-area { padding: 16px; }
    .download-btn { padding: 12px 20px; font-size: 0.88rem; min-height: 44px; width: 100%; justify-content: center; }

    .steps-row { grid-template-columns: 1fr; gap: 10px; }
    .step-card { padding: 16px; }

    .ocr-grid { grid-template-columns: 1fr; }
    .ocr-textarea { height: 220px; }

    .img-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

    .table-scroll { max-height: 300px; -webkit-overflow-scrolling: touch; }
    .table-scroll th, .table-scroll td { padding: 6px 8px; font-size: 0.78rem; }

    .seo-details { margin-top: 32px; padding: 0 4px; }
    .seo-details h2 { font-size: 1.15rem; }
    .seo-details h3 { font-size: 0.95rem; }
    .seo-details p { font-size: 0.88rem; }

    .faq-section h2 { font-size: 1.05rem; }
    details summary { padding: 12px 14px; font-size: 0.88rem; }
    details p { padding: 0 14px 12px; font-size: 0.85rem; }

    .footer-links { gap: 10px; }
    .footer-tool-link { font-size: 0.78rem; }

    .font-picker, .lang-picker { padding: 14px 14px; }
    .font-chip { padding: 7px 12px; font-size: 0.82rem; }
    .lang-chip { padding: 5px 10px; font-size: 0.78rem; }

    .merge-file-item { gap: 8px; padding: 8px 10px; }
    .merge-file-name { font-size: 0.85rem; }
    .merge-file-size { font-size: 0.78rem; }
    .merge-actions { flex-direction: column; }
    .merge-actions .pick-btn,
    .merge-actions .download-btn { width: 100%; justify-content: center; text-align: center; min-height: 44px; }

    .how-section { margin-top: 32px; margin-bottom: 24px; }

    .text-preview-box { max-height: 300px; padding: 12px; font-size: 0.85rem; }
    .word-preview-box { max-height: 350px; padding: 16px; font-size: 0.88rem; }
}

/* ------- Small phones ------- */
@media (max-width: 400px) {
    .nav-inner { padding: 8px 10px; }
    .nav-tool { padding: 6px 9px; font-size: 0.75rem; }
    .page-hero h1 { font-size: 1.15rem; }
    .page-hero p { font-size: 0.85rem; }
    .upload-box { padding: 24px 10px; }
    .upload-title { font-size: 0.88rem; }
    .upload-sub { font-size: 0.78rem; }
    .pick-btn { padding: 10px 16px; font-size: 0.82rem; }
    .result-area { padding: 12px; }
    .tool-body { padding: 0 10px 30px; }
    .footer-links { gap: 8px; }
    .footer-tool-link { font-size: 0.72rem; }
    .img-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .img-card img { height: 100px; }
    .dropdown-menu { min-width: 150px; }
}
