/* ============================================
   Image Compressor Pro - Stylesheet
   ============================================ */

/* ---- CSS Custom Properties (Dark Theme Default) ---- */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #293548;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --border: #334155;
    --border-light: #475569;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --radius: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Light Theme ---- */
[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8fafc;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --accent-glow: rgba(59, 130, 246, 0.12);
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left .logo {
    font-size: 1.8rem;
}

.header-left h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.pro-badge {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    font-size: 0.6rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    vertical-align: super;
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: rotate(20deg);
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ============================================
   DROP ZONE
   ============================================ */
.drop-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-secondary);
    position: relative;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: scale(1.01);
    box-shadow: 0 0 40px var(--accent-glow);
}

.drop-zone-content {
    /* no pointer-events override — buttons handle stopPropagation themselves */
}

.drop-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    animation: float 3s ease-in-out infinite;
}

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

.drop-zone h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.drop-zone-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

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

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

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

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

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 50%;
    transition: all var(--transition);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ============================================
   SECTION HEADERS & BADGES
   ============================================ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-weight: 700;
}

/* ============================================
   IMAGE QUEUE
   ============================================ */
.queue-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.image-queue {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.6rem;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.queue-item:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.queue-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.queue-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.queue-name {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ============================================
   SETTINGS PANEL
   ============================================ */
.settings-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.settings-panel > h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 1.25rem;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 0.55rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.mode-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.mode-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Settings Groups */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.setting-row > label {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 130px;
}

.checkbox-row {
    justify-content: flex-start;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-secondary);
    min-width: unset;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ============================================
   QUALITY SLIDER
   ============================================ */
.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    max-width: 300px;
}

.quality-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    transition: background var(--transition);
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 8px var(--accent-glow);
    transition: transform 0.15s ease;
}

.quality-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.quality-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.slider-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 42px;
    text-align: right;
}

/* ============================================
   SELECT & NUMBER INPUTS
   ============================================ */
.select-input,
.number-input {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    max-width: 200px;
    width: 100%;
    transition: border-color var(--transition);
}

.select-input:focus,
.number-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============================================
   ADVANCED SETTINGS
   ============================================ */
.advanced-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.75rem 0;
    margin-top: 0.5rem;
    transition: color var(--transition);
    width: 100%;
    text-align: left;
}

.advanced-toggle:hover {
    color: var(--accent);
}

.advanced-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.advanced-panel.open {
    max-height: 200px;
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
}

/* ============================================
   COMPRESS BUTTON
   ============================================ */
.compress-btn {
    width: 100%;
    margin-top: 1.25rem;
    justify-content: center;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.compress-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.compress-btn:hover:not(:disabled)::after {
    transform: translateX(100%);
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-container {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6, #ec4899);
    background-size: 200% 100%;
    border-radius: 5px;
    width: 0%;
    transition: width 0.4s ease;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: right;
}

/* ============================================
   RESULTS SECTION
   ============================================ */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.results-section > .section-header h2 {
    font-size: 1.15rem;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.stat-item {
    flex: 1;
    min-width: 120px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-label {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

/* Results List */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.result-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    transition: all var(--transition);
    border: 1px solid transparent;
    animation: slideIn 0.3s ease;
}

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

.result-card:hover {
    border-color: var(--border-light);
}

.result-card.error {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.result-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-sizes {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    margin-top: 0.2rem;
    flex-wrap: wrap;
}

.size-original {
    color: var(--text-muted);
    text-decoration: line-through;
}

.size-arrow {
    color: var(--text-muted);
}

.size-compressed {
    color: var(--text-primary);
    font-weight: 600;
}

.size-savings {
    font-weight: 700;
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
}

.size-savings.positive {
    color: var(--success);
    background: var(--success-bg);
}

.size-savings.neutral {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.result-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.result-error {
    color: var(--danger);
    font-size: 0.82rem;
}

.result-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ============================================
   PREVIEW MODAL
   ============================================ */
.preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

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

.preview-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 900px;
    width: 92%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.preview-content h3 {
    text-align: center;
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

.close-preview {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
}

.close-preview:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.preview-item {
    text-align: center;
}

.preview-item h4 {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.preview-item h4 span {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 400;
}

.preview-item img {
    max-width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    .header-left h1 {
        font-size: 1.15rem;
    }
    .container {
        padding: 1rem;
        gap: 1rem;
    }
    .drop-zone {
        padding: 2rem 1rem;
    }
    .drop-icon {
        font-size: 2.5rem;
    }
    .image-queue {
        grid-template-columns: 1fr;
    }
    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }
    .setting-row > label {
        min-width: unset;
    }
    .slider-container {
        max-width: 100%;
        width: 100%;
    }
    .select-input,
    .number-input {
        max-width: 100%;
    }
    .preview-grid {
        grid-template-columns: 1fr;
    }
    .stats-bar {
        gap: 0.5rem;
    }
    .stat-item {
        min-width: 0;
    }
    .result-card {
        flex-wrap: wrap;
    }
    .result-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 0.25rem;
    }
}

@media (max-width: 480px) {
    .drop-zone-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .header-left .logo {
        display: none;
    }
    .stats-bar {
        flex-direction: column;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
