/* ============================================
   pdf2png.ru - Styles
   ============================================ */

/* ============================================
   CSS Variables & Theme System
   ============================================ */
:root {
    /* Light theme */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #e63946;
    --accent-hover: #d62836;
    --accent-light: rgba(230, 57, 70, 0.08);
    --border: #e5e5e5;
    --border-hover: #d0d0d0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: 0.2s ease;
    --font-display: 'Onest', system-ui, sans-serif;
    --font-body: 'Onest', system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #ff6b6b;
    --accent-hover: #ff5252;
    --accent-light: rgba(255, 107, 107, 0.12);
    --border: #2a2a2a;
    --border-hover: #3a3a3a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

/* ============================================
   Font Import
   ============================================ */
@font-face {
    font-family: 'Onest';
    src: url('https://fonts.cdnfonts.com/s/93339/Onest-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Onest';
    src: url('https://fonts.cdnfonts.com/s/93339/Onest-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Onest';
    src: url('https://fonts.cdnfonts.com/s/93339/Onest-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
}

/* ============================================
   Layout
   ============================================ */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

main {
    flex: 1;
    padding: 40px 0 80px;
}

/* ============================================
   Header
   ============================================ */
header {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
}

.logo-text {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--accent);
}

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

.theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.icon-sun, [data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ============================================
   Hero Section
   ============================================ */
.hero {
    text-align: center;
    margin-bottom: 48px;
}

.hero h1 {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 16px;
    line-height: 1.2;
}

.hero p {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto;
}

/* ============================================
   Privacy Badge
   ============================================ */
.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-light);
    border-radius: 100px;
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 24px;
    font-weight: 500;
}

.privacy-badge svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   Drop Zone
   ============================================ */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    border-style: solid;
}

.drop-zone.drag-over::before {
    opacity: 0.04;
}

.drop-zone-content {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.drop-zone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--text-muted);
    transition: color var(--transition), transform var(--transition);
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
    color: var(--accent);
    transform: scale(1.05);
}

.drop-zone h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.drop-zone p {
    color: var(--text-secondary);
    font-size: 15px;
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.browse-link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================
   Settings Panel
   ============================================ */
.settings-panel {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-top: 24px;
}

.settings-panel.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.settings-title {
    font-weight: 600;
    font-size: 16px;
}

.file-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.setting-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.setting-group select:hover,
.setting-group select:focus {
    border-color: var(--accent);
    outline: none;
}

/* ============================================
   Preview Grid
   ============================================ */
.preview-section {
    margin-top: 24px;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.preview-title {
    font-weight: 600;
}

.select-all-btn {
    font-size: 14px;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.select-all-btn:hover {
    text-decoration: underline;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.preview-item {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-tertiary);
}

.preview-item:hover {
    border-color: var(--border-hover);
}

.preview-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.preview-item canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.preview-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-zoom-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    opacity: 0;
}

.preview-item:hover .preview-zoom-btn {
    opacity: 1;
}

.preview-zoom-btn:hover {
    background: rgba(255,255,255,0.3);
}

.preview-zoom-btn svg {
    width: 16px;
    height: 16px;
}

.preview-item-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.preview-item.selected .preview-item-check {
    background: var(--accent);
    border-color: var(--accent);
}

.preview-item-check svg {
    width: 14px;
    height: 14px;
    color: white;
    opacity: 0;
    transition: opacity var(--transition);
}

.preview-item.selected .preview-item-check svg {
    opacity: 1;
}

/* ============================================
   Action Buttons
   ============================================ */
.actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-reset {
    background: none;
    color: var(--text-secondary);
    padding: 14px 20px;
}

.btn-reset:hover {
    color: var(--text-primary);
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-container {
    display: none;
    margin-top: 24px;
}

.progress-container.visible {
    display: block;
}

.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: center;
}

/* ============================================
   Preview Modal
   ============================================ */
.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.preview-modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-image {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    color: white;
}

.modal-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-nav-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
}

.modal-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-nav-btn svg {
    width: 20px;
    height: 20px;
}

.modal-page-num {
    font-size: 14px;
    min-width: 120px;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Features Section
   ============================================ */
.features {
    margin-top: 80px;
    padding-top: 60px;
    border-top: 1px solid var(--border);
}

.features h2 {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 48px;
    letter-spacing: -0.5px;
}

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

.feature {
    text-align: center;
    padding: 24px;
}

.feature-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--accent);
}

.feature h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================
   FAQ Section
   ============================================ */
.faq {
    margin-top: 80px;
    padding-top: 60px;
    border-top: 1px solid var(--border);
}

.faq h2 {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 48px;
    letter-spacing: -0.5px;
}

.faq-list {
    max-width: 700px;
    margin: 0 auto;
}

.faq-item {
    border-bottom: 1px solid var(--border);
}

.faq-question {
    width: 100%;
    padding: 20px 0;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.faq-question:hover {
    color: var(--accent);
}

.faq-question svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform var(--transition);
    color: var(--text-muted);
}

.faq-item.open .faq-question svg {
    transform: rotate(180deg);
}

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

.faq-item.open .faq-answer {
    max-height: 300px;
}

.faq-answer p {
    padding-bottom: 20px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ============================================
   Ad Placeholder
   ============================================ */
.ad-container {
    margin-top: 48px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    min-height: 90px;
    display: none;
}

.ad-container.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   Footer
   ============================================ */
footer {
    padding: 32px 0;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-left {
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
    main {
        padding: 24px 0 60px;
    }
    
    .container {
        padding: 0 16px;
    }
    
    .drop-zone {
        padding: 40px 24px;
    }
    
    .drop-zone-icon {
        width: 48px;
        height: 48px;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
    
    .features-grid {
        gap: 24px;
    }
    
    .feature {
        padding: 16px;
    }
    
    .modal-close {
        top: 10px;
        right: 10px;
    }
}

/* ============================================
   Utilities
   ============================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
