/* ==========================================================================
   PDF to Image Converter - Modern CSS Styling
   ========================================================================== */

:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #24344d;
    --bg-input: #0f172a;
    --border-color: #334155;
    --border-focus: #3b82f6;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.15);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-light: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 24px 16px;
    min-height: 100vh;
}

.app-container {
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    flex-shrink: 0;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.privacy-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    color: #a7f3d0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

/* Card */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

/* Upload Dropzone */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.6);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
}

.drop-zone.dragover {
    border-style: solid;
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 12px;
    display: inline-flex;
}

.drop-zone h3 {
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.drop-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.browse-link {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 600;
}

.file-limits {
    display: inline-block;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Selected File Box */
.file-info-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    text-align: left;
    margin-top: 10px;
}

.file-info-details {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pdf-icon {
    background: #dc2626;
    color: #fff;
    font-weight: 800;
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.05em;
}

.file-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-all;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.15);
}

/* Settings */
.settings-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Format Chips */
.format-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.chip-option {
    cursor: pointer;
}

.chip-option input {
    display: none;
}

.chip-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition);
}

.chip-label strong {
    font-size: 0.95rem;
}

.chip-label small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chip-option input:checked + .chip-label {
    background: var(--primary-light);
    border-color: var(--primary);
    color: #93c5fd;
}

.chip-option input:checked + .chip-label small {
    color: #bfdbfe;
}

/* Form Controls */
.form-select {
    width: 100%;
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.form-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.form-range {
    width: 100%;
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 4px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.mode-option input {
    margin-top: 4px;
    accent-color: var(--primary);
}

.mode-option div {
    display: flex;
    flex-direction: column;
}

.mode-option strong {
    font-size: 0.88rem;
}

.mode-option small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mode-option.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
}

/* Progress */
.progress-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Results & Gallery */
.results-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border-color);
}

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

.subtitle-small {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.page-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.page-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.page-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 140%; /* A4 proportion */
    background: #000;
    cursor: pointer;
    overflow: hidden;
}

.page-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111;
    transition: transform 0.2s ease;
}

.page-thumb-wrap:hover .page-thumb-img {
    transform: scale(1.03);
}

.page-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.page-card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-card);
}

.page-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-card-download {
    width: 100%;
    padding: 8px 12px;
    background: var(--primary-light);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-card-download:hover {
    background: var(--primary);
    color: #fff;
}

/* Info Section Accordion */
.info-section {
    padding: 16px 20px;
}

.info-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    color: var(--text-primary);
}

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

.chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.info-details[open] .chevron {
    transform: rotate(180deg);
}

.details-body {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.info-item h4 {
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: #93c5fd;
}

.info-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.server-stat-bar {
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.server-stat-bar strong {
    color: var(--text-secondary);
}

/* Footer */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 16px 0;
}

/* Lightbox Modal */
.lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
}

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

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    background: #111;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.lightbox-caption {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .card {
        padding: 20px 16px;
    }
    
    .format-chips {
        grid-template-columns: 1fr;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-success {
        width: 100%;
        justify-content: center;
    }
}
