/* =========================================
   CSS Variables & Theme
========================================= */
:root {
    --primary-color: #4361EE;
    --primary-dark: #324edb;
    --primary-glow: rgba(67, 97, 238, 0.22);
    --secondary-color: #F72585;
    --success-color: #10B981;
    --danger-color: #ef476f;
    --danger-dark: #d13054;
    --bg-color: #F4F7FE;
    --bg-alt: #EEF2FC;
    --card-bg: #FFFFFF;
    --text-main: #2B2D42;
    --text-muted: #8D99AE;
    --border-color: rgba(141, 153, 174, 0.22);
    --border-radius: 20px;
    --border-radius-sm: 12px;
    --box-shadow: 0 4px 24px rgba(67, 97, 238, 0.08);
    --box-shadow-hover: 0 8px 32px rgba(67, 97, 238, 0.16);
    --transition: 0.25s ease;
}

body.dark-mode {
    --bg-color: #0F172A;
    --bg-alt: #162032;
    --card-bg: #1E293B;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: rgba(148, 163, 184, 0.15);
    --box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --box-shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.65;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* =========================================
   Navbar
========================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5%;
    background: var(--card-bg);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--transition);
}

.logo { font-size: 18px; font-weight: 800; }
.logo a:hover .highlight { text-decoration: underline; }
.highlight { color: var(--primary-color); }

.theme-btn {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s ease, background var(--transition);
}

.theme-btn:hover { transform: scale(1.15) rotate(20deg); }

/* =========================================
   Hero
========================================= */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6C63FF 100%);
    padding: 56px 5% 48px;
    text-align: center;
    color: white;
}

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

.hero-badge {
    display: inline-block;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 100px;
    padding: 4px 16px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 18px;
}

.hero-section h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 14px;
}

.hero-desc {
    font-size: 1.05rem;
    opacity: 0.88;
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.6;
}



/* =========================================
   Tool Container & Card
========================================= */
.tool-container {
    display: flex;
    justify-content: center;
    padding: 32px 5% 16px;
}

.tool-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 740px;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: background-color var(--transition);
}

/* =========================================
   Upload Area
========================================= */
.upload-area {
    border: 2.5px dashed var(--primary-color);
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 52px 20px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, border-color 0.3s ease;
    text-align: center;
    outline: none;
}

.upload-area:hover,
.upload-area:focus,
.upload-area.dragover {
    background: rgba(67, 97, 238, 0.07);
    transform: translateY(-3px);
    border-color: #6C63FF;
}

.upload-area.dragover {
    background: rgba(67, 97, 238, 0.13);
}

.upload-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }

.upload-anim {
    font-size: 56px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.upload-area.dragover .upload-anim { animation: bounce 0.4s ease infinite alternate; }

@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-12px); }
}

.upload-text {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-color);
}

.upload-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.upload-btn-label {
    display: inline-block;
    margin-top: 6px;
    padding: 10px 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 700;
    pointer-events: auto;
    cursor: pointer;
    transition: background var(--transition), transform 0.2s;
}

.upload-btn-label:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* =========================================
   PDF Controls
========================================= */
.pdf-controls { animation: fadeUp 0.4s ease; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: 100px;
    padding: 7px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-pill strong { color: var(--primary-color); }
.stat-icon { font-size: 1rem; }

/* Preview header */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.list-heading {
    font-size: 1.05rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-count-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 100px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 800;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

.add-more-btn {
    background: var(--bg-color);
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: background var(--transition), color var(--transition);
}

.add-more-btn:hover { background: var(--primary-color); color: white; }

.clear-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: background var(--transition);
}

.clear-btn:hover { background: var(--danger-dark); }

/* =========================================
   File List (Drag-sortable)
========================================= */
.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px 2px;
    margin-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.file-list::-webkit-scrollbar { width: 4px; }
.file-list::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 4px; }

.file-item {
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: grab;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
    user-select: none;
}

.file-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--box-shadow-hover);
}

.file-item.dragging {
    opacity: 0.45;
    transform: scale(0.98);
    cursor: grabbing;
}

.file-item.drag-over {
    border-color: var(--primary-color);
    background: rgba(67, 97, 238, 0.06);
}

/* Drag handle */
.drag-handle {
    font-size: 1rem;
    color: var(--text-muted);
    cursor: grab;
    flex-shrink: 0;
    line-height: 1;
}

.file-pdf-icon { font-size: 1.5rem; flex-shrink: 0; }

.file-info { flex: 1; overflow: hidden; }

.file-name {
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.file-meta span { display: flex; align-items: center; gap: 3px; }

.remove-btn {
    background: none;
    border: 1.5px solid var(--border-color);
    color: var(--text-muted);
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    line-height: 1;
}

.remove-btn:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* =========================================
   Error Message
========================================= */
.error-msg {
    background: rgba(239, 71, 111, 0.1);
    border: 1.5px solid rgba(239, 71, 111, 0.4);
    color: var(--danger-color);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 14px;
}

/* =========================================
   Action Button (Merge)
========================================= */
.action-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--primary-color), #6C63FF);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--primary-glow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(67, 97, 238, 0.38);
    filter: brightness(1.05);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.action-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    filter: none;
    transform: none;
}

.secondary-btn {
    background: var(--bg-color);
    color: var(--primary-color);
    box-shadow: none;
    border: 2px solid var(--primary-color);
    margin-top: 10px;
}

.secondary-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

/* Loading Spinner */
.loader {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

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

/* =========================================
   Progress Bar
========================================= */
.progress-wrap { margin-top: 16px; }

.progress-bar-track {
    background: var(--bg-alt);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #6C63FF);
    border-radius: 100px;
    transition: width 0.3s ease;
}

.progress-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
}

/* =========================================
   Result Card
========================================= */
.result-card {
    text-align: center;
    padding: 36px 28px;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.06), rgba(108, 99, 255, 0.08));
    border: 1.5px solid rgba(67, 97, 238, 0.2);
    border-radius: var(--border-radius);
    animation: fadeUp 0.5s ease;
}

.result-icon { font-size: 52px; margin-bottom: 10px; }

.result-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 24px;
}

.result-meta {
    display: flex;
    justify-content: center;
    gap: 1px;
    background: var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: 24px;
}

.result-meta-item {
    flex: 1;
    background: var(--card-bg);
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.result-meta-item span {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.result-meta-item strong {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--primary-color);
    word-break: break-all;
}

.result-dl-btn { margin-bottom: 0; }

/* =========================================
   Content Sections
========================================= */
.content-section {
    max-width: 800px;
    margin: 0 auto 28px;
    padding: 36px 40px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: background-color var(--transition);
}

.content-section h2 {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.content-section p {
    color: var(--text-muted);
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.content-section ol {
    padding-left: 22px;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 14px;
}

.content-section ol li,
.content-section .prose-list li { margin-bottom: 10px; }
.content-section ol li strong { color: var(--text-main); }

.content-section a { color: var(--primary-color); font-weight: 700; }
.content-section a:hover { text-decoration: underline; }

.prose-list {
    padding-left: 22px;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 14px;
}

/* Feature list */
.feature-list { list-style: none; padding: 0; }
.feature-list li {
    padding: 9px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    color: var(--text-muted);
}
.feature-list li:last-child { border-bottom: none; }
.feature-list li strong { color: var(--text-main); }

/* Privacy note */
.privacy-note { border-left: 4px solid var(--primary-color); }

/* Device grid */
.device-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.device-chip {
    background: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: 100px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Related tools grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.tool-link-card {
    background: var(--bg-color);
    border: 1.5px solid transparent;
    border-radius: var(--border-radius-sm);
    padding: 20px 14px;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    display: block;
}

.tool-link-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-hover);
    border-color: var(--primary-color);
}

.tool-link-card span { font-size: 1.8rem; display: block; margin-bottom: 8px; }
.tool-link-card strong { display: block; font-size: 0.88rem; font-weight: 800; color: var(--text-main); margin-bottom: 4px; }
.tool-link-card p { font-size: 0.72rem; color: var(--text-muted); margin: 0; }

/* =========================================
   FAQ Accordion
========================================= */
.faq-item { border-bottom: 1px solid var(--border-color); }
.faq-item:last-child { border-bottom: none; }

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 18px 0;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color var(--transition);
}

.faq-question::after {
    content: '＋';
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.faq-question[aria-expanded="true"] { color: var(--primary-color); }
.faq-question[aria-expanded="true"]::after { content: '－'; }

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.3s ease;
}

.faq-answer.open { max-height: 300px; padding-bottom: 16px; }
.faq-answer p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }

/* =========================================
   Rich Footer
========================================= */
footer { 
    background: #1A1A2E; 
    color: #E2E8F0; 
    padding: 60px 5% 20px; 
    margin-top: 60px; 
}

.footer-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 30px;
}

.footer-brand p { 
    color: #9AA5C4; 
    font-size: 0.95rem; 
    margin-top: 14px; 
    max-width: 280px; 
    text-align: left;
    line-height: 1.6;
}

.footer-logo { 
    color: #fff; 
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-col h4 { 
    font-family: 'Nunito', sans-serif; 
    font-size: 1.1rem; 
    font-weight: 800; 
    margin-bottom: 18px; 
    color: #fff; 
    text-align: left;
}

.footer-col ul { 
    list-style: none; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    padding: 0; 
    align-items: flex-start;
}

.footer-col ul a { 
    color: #9AA5C4; 
    font-size: 0.92rem; 
    font-weight: 600;
    transition: color 0.3s ease, transform 0.3s ease; 
    text-decoration: none; 
    display: inline-block;
}

.footer-col ul a:hover { 
    color: var(--secondary-color); 
    text-decoration: none;
    transform: translateX(4px);
}

.footer-bottom {
    max-width: 1200px;
    margin: 50px auto 0;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
    color: #8D99AE;
    font-size: 0.9rem;
    font-weight: 600;
}

/* =========================================
   Footer Responsive (Mobile & Tablet)
========================================= */
@media (max-width: 1024px) {
    .footer-grid { 
        grid-template-columns: repeat(3, 1fr); 
        gap: 40px 20px; 
    }
    .footer-brand { 
        grid-column: 1 / -1; 
    }
    .footer-brand p {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .footer-grid { 
        grid-template-columns: repeat(2, 1fr); 
    }
}

@media (max-width: 500px) {
    footer {
        padding: 50px 6% 20px;
    }
    .footer-grid { 
        grid-template-columns: 1fr; 
        text-align: center; 
        gap: 36px;
    }
    .footer-logo { 
        justify-content: center; 
    }
    .footer-brand p { 
        margin: 14px auto 0; 
        text-align: center; 
    }
    .footer-col h4 { 
        text-align: center; 
    }
    .footer-col ul { 
        align-items: center; 
    }
    .footer-col ul a:hover {
        transform: translateY(-2px); /* Vertical hover for mobile instead of horizontal */
    }
}

/* =========================================
   Cookie Banner
========================================= */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 9999;
    border: 2px solid var(--primary-color);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
}

.cookie-banner.hidden {
    transform: translate(-50%, 150px);
    opacity: 0;
    pointer-events: none;
}

.cookie-content { display: flex; align-items: center; gap: 15px; }
.cookie-icon { font-size: 35px; }
.cookie-content p { margin: 0; font-size: 0.95rem; color: var(--text-main); line-height: 1.5; }
.cookie-content a { color: var(--primary-color); font-weight: 800; text-decoration: underline; }

.cookie-btn {
    background: linear-gradient(135deg, var(--primary-color), #6C63FF);
    padding: 12px 25px;
    font-size: 1.05rem;
    width: auto;
    white-space: nowrap;
    margin-left: 20px;
}

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

/* =========================================
   Responsive
========================================= */
@media (max-width: 700px) {
    .hero-section { padding: 40px 5% 32px; }
    .tool-card { padding: 24px 16px; }
    .content-section { padding: 24px 20px; }
    .file-name { max-width: 180px; }
    .result-meta { flex-direction: column; gap: 1px; }
    .tools-grid { grid-template-columns: repeat(2, 1fr); }

    .cookie-banner {
        flex-direction: column;
        gap: 6px;
        padding: 10px 14px;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        width: 100%;
    }
    .cookie-content { flex-direction: row; align-items: flex-start; gap: 8px; }
    .cookie-icon { font-size: 18px; margin-top: 2px; }
    .cookie-content p { font-size: 0.75rem; line-height: 1.2; }
    .cookie-btn { width: 100%; margin-left: 0; padding: 8px; font-size: 0.88rem; }
}

@media (max-width: 480px) {
    .stats-bar { gap: 6px; }
    .stat-pill { padding: 5px 12px; font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
