:root {
    --primary: #0052D4;
    --primary-hover: #0041a8;
    --accent: #1EAF5B;
    --accent-hover: #168a47;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; -webkit-font-smoothing: antialiased; }
body {
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    background-image: radial-gradient(at 100% 0%, rgba(0, 82, 212, 0.05) 0px, transparent 50%);
}

/* Header */
header {
    padding: 0.75rem 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}
.navbar { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.logo { text-decoration: none; display: flex; align-items: center; }
.main-logo { height: 40px; width: auto; display: block; }
.mobile-logo { display: none; }

@media (max-width: 600px) {
    .main-logo { display: none; }
    .mobile-logo { display: block; height: 32px; width: auto; }
}

/* Container */
.container { max-width: 900px; margin: 3rem auto; padding: 0 1.5rem; text-align: center; }
.header-section { margin-bottom: 3rem; }
h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-muted); font-size: 1.1rem; }

/* Drop Zone */
.drop-zone {
    background: var(--card-bg);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2.5rem;
}
.drop-zone:hover { border-color: var(--accent); background: #f0fdf4; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.drop-icon { font-size: 3rem; margin-bottom: 1rem; }
.drop-text { font-size: 1.25rem; font-weight: 700; color: var(--text-main); }
#file-input { display: none; }

/* Converter Section */
.converter-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group { text-align: left; }
.group-title { font-weight: 800; font-size: 0.9rem; color: var(--text-main); text-transform: uppercase; margin-bottom: 1rem; display: block; }

.resolution-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.res-option {
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.res-option input { display: none; }
.res-option:hover { border-color: var(--primary); color: var(--primary); }
.res-option.active { background: var(--primary); color: white; border-color: var(--primary); }

.btn-action {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    padding: 1.25rem;
    border-radius: 16px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.btn-action:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 82, 212, 0.4); }
.btn-action:disabled { background: #cbd5e1; cursor: not-allowed; opacity: 0.7; }

/* Preview Area */
.preview-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.preview-title { font-size: 1.2rem; font-weight: 800; color: var(--text-main); }

.selection-actions { display: flex; gap: 1rem; }
.btn-text-action {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.btn-text-action:hover { background: var(--badge-bg); }

.btn-clear-data {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fecdd3;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-clear-data:hover {
    background: #ffe4e6;
    border-color: #fda4af;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.15);
}


.selection-hint {
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.pages-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

.page-thumb-container {
    background: white;
    border: 2px solid var(--border);
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}
.page-thumb-container:hover { border-color: #cbd5e1; transform: translateY(-2px); }
.page-thumb-container.selected {
    border-color: var(--primary);
    background: #f0f7ff;
    box-shadow: 0 4px 12px rgba(0, 82, 212, 0.1);
}

/* Checkbox indicator */
.page-thumb-container::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.page-thumb-container.selected::after { opacity: 1; transform: scale(1); }

.page-thumb-container canvas {
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid #eee;
    margin-bottom: 8px;
    pointer-events: none;
}
.page-label { font-size: 0.8rem; font-weight: 800; color: var(--text-muted); transition: color 0.2s; }
.page-thumb-container.selected .page-label { color: var(--primary); }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    visibility: visible;
    opacity: 1;
}

.spinner-box {
    width: 80px;
    height: 80px;
    position: relative;
    margin-bottom: 2rem;
}

.spinner {
    width: 100%;
    height: 100%;
    border: 6px solid #f1f5f9;
    border-top: 6px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-inner {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border: 4px solid #f1f5f9;
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1.5s linear infinite reverse;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-container {
    width: 300px;
    background: #f1f5f9;
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}
