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

:root {
    --bg-primary: #0d0d1a;
    --bg-secondary: #14142b;
    --bg-card: #1c1c3a;
    --bg-card-hover: #252550;
    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #6b6b8d;
    --accent: #7c5cfc;
    --accent-glow: rgba(124, 92, 252, 0.35);
    --accent2: #00d4ff;
    --success: #00e676;
    --warning: #ffab00;
    --danger: #ff5252;
    --border: #2a2a50;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

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

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
}

.logo i {
    font-size: 1.6rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

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

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
}

/* ===== ADS ===== */
.ad-container {
    display: flex;
    justify-content: center;
    padding: 12px;
    background: rgba(28, 28, 58, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 16px auto;
    max-width: 100%;
    overflow: hidden;
    transition: var(--transition);
}

.ad-container:hover {
    border-color: var(--accent-glow);
}

.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 60px;
    text-align: center;
}

.ad-header,
.ad-footer {
    max-width: 1200px;
}

.ad-sidebar {
    width: 100%;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-sidebar-2 {
    min-height: 600px;
}

.ad-content-bottom {
    background: transparent;
    border: none;
    padding: 20px 0;
}

/* ===== MAIN LAYOUT ===== */
.main-layout {
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 20px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 92px;
}

.content {
    flex: 1;
    min-width: 0;
}

/* ===== TOOL SECTIONS ===== */
.tool-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tool-section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 24px;
}

.section-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.section-header h1 i {
    color: var(--accent);
}

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

/* ===== UPLOAD ZONE ===== */
.upload-zone {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    box-shadow: 0 0 40px var(--accent-glow);
}

.upload-zone i {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 12px;
    opacity: 0.7;
}

.upload-zone h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.upload-zone input[type="file"] {
    display: none;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    background: #8f6fff;
    box-shadow: 0 6px 24px var(--accent-glow);
}

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

.btn-outline:hover {
    background: var(--accent);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #000;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
    width: 100%;
    justify-content: center;
}

/* ===== TOOL OPTIONS ===== */
.tool-options {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: end;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-group label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.option-group select,
.option-group input[type="number"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.option-group select:focus,
.option-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.option-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-primary);
    height: 6px;
    border-radius: 3px;
    outline: none;
    border: none;
    padding: 0;
}

.option-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ===== PREVIEW GRID ===== */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.preview-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.preview-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.preview-item img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.preview-item .info {
    padding: 8px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-item .info .size {
    color: var(--accent2);
}

.preview-item .remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,82,82,0.85);
    color: #fff;
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-item .remove-btn:hover {
    background: var(--danger);
    transform: scale(1.15);
}

.preview-item .badge {
    position: absolute;
    bottom: 40px;
    right: 6px;
    background: var(--accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

/* ===== STATUS MESSAGE ===== */
.status-msg {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    display: none;
}

.status-msg.show {
    display: block;
}

.status-msg.success {
    background: rgba(0,230,118,0.12);
    border: 1px solid var(--success);
    color: var(--success);
}

.status-msg.error {
    background: rgba(255,82,82,0.12);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.status-msg.info {
    background: rgba(0,212,255,0.12);
    border: 1px solid var(--accent2);
    color: var(--accent2);
}

/* ===== PROGRESS ===== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 16px;
    display: none;
}

.progress-bar.show { display: block; }

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

/* ===== COMPARISON TABLE (Compress) ===== */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.85rem;
}

.comparison-table th,
.comparison-table td {
    padding: 10px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.comparison-table th {
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--bg-card);
}

.comparison-table tr:hover td {
    background: var(--bg-card-hover);
}

.saved-badge {
    background: rgba(0,230,118,0.15);
    color: var(--success);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    margin-top: 40px;
    padding: 24px 20px;
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-brand {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.footer-brand i {
    color: var(--accent);
}

.footer-tagline {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar { width: 260px; }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 68px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 8px;
        gap: 2px;
    }
    .nav-links.open { display: flex; }
    .menu-toggle { display: block; }
    .main-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar .ad-container { flex: 1; min-width: 200px; }
    .ad-sidebar { min-height: 200px; }
    .ad-sidebar-2 { min-height: 200px; }
    .tool-options { grid-template-columns: 1fr; }
    .section-header h1 { font-size: 1.3rem; }
    .preview-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
    .header-inner { padding: 0 12px; }
    .upload-zone { padding: 32px 16px; }
    .preview-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .preview-item img { height: 110px; }
}
