/* =========================================
   1. CORE VARIABLES & RESET
   ========================================= */
:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --secondary: #0F172A;
    --accent: #06B6D4;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: var(--font-sans); 
    background-color: var(--bg); 
    color: var(--text-main); 
    line-height: 1.6; 
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* =========================================
   2. NAVIGATION & HEADER
   ========================================= */
.glass-header { 
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1000;
}

.nav-container { display: flex; justify-content: space-between; align-items: center; height: 70px; }

.logo { font-size: 1.4rem; font-weight: 800; text-decoration: none; color: var(--secondary); letter-spacing: -0.5px; }
.logo span { color: var(--primary); }

.nav-links { display: flex; list-style: none; gap: 24px; align-items: center; }
.nav-links a { 
    text-decoration: none; color: var(--text-muted); font-weight: 500; 
    transition: all 0.2s ease; font-size: 0.9rem; white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }

.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--secondary); }

/* =========================================
   3. HERO SECTION
   ========================================= */
.hero { 
    text-align: center; padding: 80px 20px 60px; 
    background: linear-gradient(180deg, #EFF6FF 0%, var(--bg) 100%);
}
.hero h1 { 
    font-size: 3rem; font-weight: 800; margin-bottom: 16px; letter-spacing: -1px; 
    color: var(--secondary); line-height: 1.1;
}
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 650px; margin: 0 auto 32px; }

.btn { 
    display: inline-flex; align-items: center; justify-content: center; 
    padding: 12px 24px; border-radius: var(--radius-sm); font-weight: 600; 
    text-decoration: none; cursor: pointer; border: none; transition: all 0.2s ease; font-size: 0.95rem; 
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: white; color: var(--primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #F8FAFC; border-color: var(--primary); }
.full-width { width: 100%; margin-top: 16px; }

/* =========================================
   4. TOOL GRID & CARDS
   ========================================= */
.category-group { margin-bottom: 60px; }
.category-title { 
    font-size: 1.25rem; font-weight: 700; margin-bottom: 24px; 
    display: flex; align-items: center; gap: 12px; color: var(--secondary); 
    text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.85rem;
}
.category-title::before { content: ''; display: block; width: 3px; height: 16px; background: var(--primary); border-radius: 2px; }

.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

.tool-card { 
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); 
    padding: 24px; text-decoration: none; color: inherit; transition: all 0.2s ease; 
    display: flex; flex-direction: column; align-items: flex-start; position: relative;
}
.tool-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.tool-icon { 
    width: 48px; height: 48px; background: #EFF6FF; color: var(--primary);
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; 
    font-size: 1.5rem; margin-bottom: 16px;
}
.tool-card h4 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; color: var(--secondary); }
.tool-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.tool-badge { 
    position: absolute; top: 16px; right: 16px; background: var(--accent); color: white; 
    font-size: 0.65rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; 
}

/* =========================================
   5. TOOL INTERFACE (CONVERTER BOXES)
   ========================================= */
.tool-header { text-align: center; margin: 60px 0 40px; }
.tool-header h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 12px; color: var(--secondary); }
.tool-header p { color: var(--text-muted); font-size: 1.05rem; max-width: 600px; margin: 0 auto; }

.mode-switcher { 
    display: flex; background: #F1F5F9; padding: 4px; border-radius: var(--radius-sm); 
    margin: 0 auto 32px; max-width: 380px; 
}
.mode-btn { 
    flex: 1; padding: 10px; border: none; background: transparent; border-radius: 6px; 
    font-weight: 600; cursor: pointer; transition: all 0.2s; color: var(--text-muted); font-size: 0.9rem;
}
.mode-btn.active { background: white; color: var(--primary); box-shadow: var(--shadow-sm); }

.converter-box { 
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); 
    padding: 40px; max-width: 650px; margin: 0 auto; box-shadow: var(--shadow-md);
}

.drop-zone { 
    border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 48px 20px; 
    text-align: center; background: #F8FAFC; transition: all 0.2s; cursor: pointer; 
}
.drop-zone.dragover { border-color: var(--primary); background: #EFF6FF; }
.drop-zone p { font-size: 1rem; color: var(--text-muted); margin-bottom: 16px; }

.settings-panel { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.85rem; color: var(--secondary); }
.form-group select, .form-group input[type="range"], .form-group input[type="text"] { 
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); 
    font-size: 0.95rem; background: white; outline: none; transition: border-color 0.2s;
}
.form-group select:focus, .form-group input:focus { border-color: var(--primary); }

input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; background: var(--border); border-radius: 3px; padding: 0; border: none; }
input[type=range]::-webkit-slider-thumb { 
    -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; 
    background: var(--primary); cursor: pointer; box-shadow: var(--shadow-sm); 
}

.loading-indicator { text-align: center; padding: 32px; }
.spinner { 
    width: 32px; height: 32px; border: 3px solid #EFF6FF; border-top-color: var(--primary); 
    border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; 
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-area { 
    text-align: center; padding: 32px; background: #ECFDF5; border-radius: var(--radius-md); 
    margin-top: 24px; border: 1px solid #A7F3D0; 
}
.hidden { display: none !important; }

/* PREVIEW FIXES - Constrained & Responsive */
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 24px; }
.preview-item { 
    position: relative; border-radius: var(--radius-sm); overflow: hidden; 
    background: white; border: 1px solid var(--border); aspect-ratio: 3/4;
}
.preview-item img { width: 100%; height: 100%; object-fit: contain; display: block; background: #F8FAFC; }
.preview-item .page-num { 
    position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15,23,42,0.8); 
    color: white; text-align: center; padding: 4px; font-size: 0.75rem; font-weight: 600;
}

.file-list-container { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; min-height: 50px; }
.sortable-item { 
    padding: 10px 14px; background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); 
    cursor: grab; display: flex; align-items: center; gap: 8px; font-size: 0.9rem;
}
.sortable-ghost { opacity: 0.4; background: var(--primary); color: white; border-color: var(--primary); }

/* =========================================
   6. SEO CONTENT SECTION (EDITORIAL STYLE)
   ========================================= */
.seo-content { max-width: 720px; margin: 80px auto; padding: 0 24px; }
.seo-content h2 { font-size: 1.8rem; font-weight: 800; margin: 48px 0 20px; color: var(--secondary); letter-spacing: -0.5px; }
.seo-content h3 { font-size: 1.2rem; font-weight: 700; margin: 32px 0 12px; color: var(--secondary); }
.seo-content p { margin-bottom: 16px; color: var(--text-main); font-size: 1.05rem; line-height: 1.75; }
.seo-content ul, .seo-content ol { margin-bottom: 20px; padding-left: 24px; }
.seo-content li { margin-bottom: 8px; color: var(--text-main); line-height: 1.7; font-size: 1.05rem; }
.seo-content code { background: #F1F5F9; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; color: var(--primary); font-family: monospace; }

.seo-content details { 
    background: white; padding: 20px; border-radius: var(--radius-md); margin-bottom: 12px; 
    border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.seo-content details[open] { border-color: var(--primary); background: #F8FAFC; }
.seo-content summary { font-weight: 600; color: var(--secondary); outline: none; font-size: 1rem; }
.seo-content details[open] summary { margin-bottom: 12px; color: var(--primary); }
.seo-content details p { margin-bottom: 0; font-size: 0.95rem; color: var(--text-muted); }

/* Homepage Specific SEO Section */
.seo-home-content { margin-top: 80px; max-width: 900px; }
.seo-home-content h2 { font-size: 2rem; font-weight: 800; margin-bottom: 32px; text-align: center; color: var(--secondary); }
.seo-home-content > div > div > h3 { color: var(--primary); margin-bottom: 12px; font-size: 1.1rem; }

/* =========================================
   7. FOOTER
   ========================================= */
.glass-footer { margin-top: 100px; padding: 48px 0; border-top: 1px solid var(--border); background: white; }
.footer-content { text-align: center; }
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.footer-links a:hover { color: var(--primary); }
.copyright { color: var(--text-muted); font-size: 0.85rem; }

/* =========================================
   8. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 900px) {
    .nav-links { 
        display: none; position: absolute; top: 70px; left: 0; right: 0; 
        background: white; flex-direction: column; padding: 24px; 
        box-shadow: var(--shadow-lg); gap: 16px; align-items: flex-start; border-bottom: 1px solid var(--border);
    }
    .nav-links.active { display: flex; }
    .mobile-menu-btn { display: block; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .hero h1 { font-size: 2rem; }
    .hero { padding: 60px 20px 40px; }
    .grid-4 { grid-template-columns: 1fr; }
    .converter-box { padding: 24px; }
    .tool-header h1 { font-size: 1.8rem; }
    .mode-switcher { flex-direction: column; }
    .seo-content { margin: 60px auto; }
    .seo-content h2 { font-size: 1.5rem; }
}