@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ==========================================================================
   JPEG Optimizer — Progressive Refresh + Dark Mode
   Layer on top of style.css — overrides visuals only, keeps layout intact
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root,
[data-theme="light"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F6F8FA;
    --bg-tertiary: #EFF2F5;
    --bg-card: #FFFFFF;
    --bg-upload: #F6F8FA;
    --text-primary: #1F2328;
    --text-secondary: #656D76;
    --text-muted: #8B949E;
    --text-heading: #1F2328;
    --text-on-accent: #FFFFFF;
    --border-default: #D0D7DE;
    --border-muted: #E8ECEF;
    --accent: #0969DA;
    --accent-hover: #0550AE;
    --accent-subtle: rgba(9, 105, 218, 0.08);
    --accent-fg: #0550AE;
    --cta-bg: linear-gradient(135deg, #0969DA, #1F6FEB);
    --cta-hover: linear-gradient(135deg, #0550AE, #0969DA);
    --success: #1A7F37;
    --danger: #CF222E;
    --warning: #9A6700;
    --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.04);
    --shadow-md: 0 3px 12px rgba(31, 35, 40, 0.06);
    --shadow-lg: 0 8px 24px rgba(31, 35, 40, 0.08);
    --shadow-card: 0 1px 3px rgba(31, 35, 40, 0.04), 0 1px 2px rgba(31, 35, 40, 0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-body: 'Inter', 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg-primary: #313338;
    --bg-secondary: #2B2D31;
    --bg-tertiary: #1E1F22;
    --bg-card: #2B2D31;
    --bg-upload: #2B2D31;
    --text-primary: #F2F3F5;
    --text-secondary: #B5BAC1;
    --text-muted: #949BA4;
    --text-heading: #F2F3F5;
    --text-on-accent: #FFFFFF;
    --border-default: #3F4147;
    --border-muted: #383A40;
    --accent: #5865F2;
    --accent-hover: #7289DA;
    --accent-subtle: rgba(88, 101, 242, 0.12);
    --accent-fg: #7289DA;
    --cta-bg: linear-gradient(135deg, #5865F2, #7289DA);
    --cta-hover: linear-gradient(135deg, #7289DA, #99AAF5);
    --success: #23A55A;
    --danger: #F23F43;
    --warning: #F0B132;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 3px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.12);
    color-scheme: dark;
}

/* ---------- Theme: Minimal (Teal + Clean) ---------- */
[data-theme="minimal"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F7FAFA;
    --bg-tertiary: #EDF5F3;
    --bg-card: #FFFFFF;
    --bg-upload: #F7FAFA;
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;
    --text-heading: #2D3436;
    --text-on-accent: #FFFFFF;
    --border-default: #DFE6E9;
    --border-muted: #EDF2F0;
    --accent: #00B894;
    --accent-hover: #00A381;
    --accent-subtle: rgba(0, 184, 148, 0.08);
    --accent-fg: #00A381;
    --cta-bg: #00B894;
    --cta-hover: #00A381;
    --success: #00B894;
    --danger: #D63031;
    --warning: #FDCB6E;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.03);
    color-scheme: light;
}

/* ---------- Theme: Vibrant (Gradient + Colorful) ---------- */
[data-theme="vibrant"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #FFF5F5;
    --bg-tertiary: #FFEDED;
    --bg-card: #FFFFFF;
    --bg-upload: #FFF8F6;
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;
    --text-heading: #2D3436;
    --text-on-accent: #FFFFFF;
    --border-default: #FFE0DB;
    --border-muted: #FFEFED;
    --accent: #E84393;
    --accent-hover: #D63384;
    --accent-subtle: rgba(232, 67, 147, 0.08);
    --accent-fg: #D63384;
    --cta-bg: linear-gradient(135deg, #FF6B6B, #EE5A24);
    --cta-hover: linear-gradient(135deg, #EE5A24, #FF6B6B);
    --success: #00B894;
    --danger: #FF6B6B;
    --warning: #FDCB6E;
    --shadow-sm: 0 1px 3px rgba(238, 90, 36, 0.08);
    --shadow-md: 0 4px 14px rgba(238, 90, 36, 0.1);
    --shadow-lg: 0 8px 28px rgba(238, 90, 36, 0.12);
    --shadow-card: 0 2px 8px rgba(238, 90, 36, 0.06);
    color-scheme: light;
}

/* Vibrant extras */
[data-theme="vibrant"] .file.is-boxed .file-cta {
    background: linear-gradient(135deg, #FF6B6B, #EE5A24, #E84393) !important;
    background-size: 200% 200% !important;
    animation: gradientShift 4s ease infinite !important;
}

[data-theme="vibrant"] .button.is-primary {
    background: linear-gradient(135deg, #FF6B6B, #EE5A24) !important;
    background-size: 200% 200% !important;
    animation: gradientShift 4s ease infinite !important;
}

[data-theme="vibrant"] .sidebar-links a:hover {
    background: linear-gradient(135deg, #FF6B6B, #E84393) !important;
}

[data-theme="vibrant"] .button-grid a:hover {
    background: linear-gradient(135deg, #E84393, #EE5A24) !important;
    border-color: transparent !important;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ---------- Transitions ---------- */
body,
#wrapper,
#header,
#header-wrap,
#content,
#footer,
#copyrights,
.sidebar-links,
.sidebar-links a,
.menu-function-image > a > div,
.conversion-tools,
.button-grid a,
.kb-map,
h1, h2, h3, h4, h5, h6,
a,
p, span, li,
.file-cta,
.section,
.progress,
input, select, textarea,
.form-control {
    transition: background-color var(--transition),
                color var(--transition),
                border-color var(--transition),
                box-shadow var(--transition);
}

/* ---------- Base ---------- */
body {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#wrapper {
    background: var(--bg-primary) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading) !important;
    font-family: var(--font-heading) !important;
}

h1 {
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
}

h2 {
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
}

p, span, li {
    color: var(--text-secondary);
}

a {
    color: var(--accent) !important;
}

a:hover {
    color: var(--accent-hover) !important;
}

::selection {
    background: var(--accent) !important;
    color: var(--text-on-accent) !important;
}

/* ---------- Header ---------- */
#header {
    background: var(--bg-primary) !important;
    border-bottom: 1px solid var(--border-muted) !important;
}

#header-wrap {
    background-color: var(--bg-primary) !important;
}

.primary-menu .menu-link {
    color: var(--text-primary) !important;
    font-weight: 500 !important;
    padding: 8px 16px !important;
    border-radius: var(--radius-sm) !important;
}

.primary-menu .menu-link:hover {
    background: var(--accent-subtle) !important;
    color: var(--accent) !important;
}

/* ---------- Content ---------- */
#content {
    background-color: var(--bg-primary) !important;
}

.content-wrap {
    background-color: var(--bg-primary) !important;
}

.section {
    background-color: var(--bg-primary) !important;
}

/* ---------- Upload Area (CTA) ---------- */
.file.is-boxed .file-cta {
    background: var(--cta-bg) !important;
    border: 2px dashed transparent !important;
    border-radius: var(--radius-lg) !important;
    color: var(--text-on-accent) !important;
    text-shadow: none !important;
    padding: 2.5rem 2rem !important;
    box-shadow: var(--shadow-md) !important;
}

.file.is-boxed .file-cta:hover {
    background: var(--cta-hover) !important;
    box-shadow: var(--shadow-lg) !important;
    transform: translateY(-1px);
}

.file.is-boxed .file-cta:active {
    transform: translateY(0);
}

.file-label {
    font-weight: 600 !important;
    font-size: 1.05rem !important;
}

/* ---------- Buttons ---------- */
.button.is-primary {
    background: var(--cta-bg) !important;
    border: none !important;
    color: var(--text-on-accent) !important;
    text-shadow: none !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
    padding: 10px 24px !important;
    box-shadow: var(--shadow-sm) !important;
}

.button.is-primary:hover {
    background: var(--cta-hover) !important;
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-1px);
}

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

.button.is-link.is-outlined {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
    background: transparent !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
}

.button.is-link.is-outlined:hover {
    background: var(--accent-subtle) !important;
    color: var(--accent-hover) !important;
}

.resetND {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-md) !important;
    text-shadow: none !important;
}

.resetND:hover {
    background: var(--bg-secondary) !important;
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

/* ---------- Progress Bar ---------- */
.progress {
    background-color: var(--bg-tertiary) !important;
    border-radius: var(--radius-lg) !important;
    overflow: hidden !important;
    height: 0.6rem !important;
}

.progress::-webkit-progress-bar {
    background-color: var(--bg-tertiary) !important;
}

.progress::-webkit-progress-value {
    background: var(--cta-bg) !important;
    border-radius: var(--radius-lg) !important;
}

.progress::-moz-progress-bar {
    background: var(--accent) !important;
    border-radius: var(--radius-lg) !important;
}

/* ---------- Sidebar Links ---------- */
.sidebar-links {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-muted) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 16px !important;
}

.sidebar-links a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-muted) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: none !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
}

.sidebar-links a:hover {
    background: var(--accent) !important;
    color: var(--text-on-accent) !important;
    border-color: var(--accent) !important;
    transform: translateY(-1px) !important;
    box-shadow: var(--shadow-md) !important;
}

.sidebar-links a::before {
    background: var(--accent) !important;
}

/* ---------- Tool Grid (Sidebar) ---------- */
.menu-function-image > a > div {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-muted) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-card) !important;
}

.menu-function-image > a > div:hover {
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-2px);
}

.menu-text-title {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
}

/* ---------- Conversion Tools Grid ---------- */
.conversion-tools {
    background: var(--bg-secondary) !important;
    border-radius: var(--radius-lg) !important;
    padding: 2rem !important;
    border: 1px solid var(--border-muted) !important;
}

.conversion-tools h2 {
    margin-bottom: 1.2rem !important;
}

.button-grid a {
    border: 1px solid var(--border-default) !important;
    color: var(--accent) !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
    background: var(--bg-card) !important;
}

.button-grid a:hover {
    background: var(--accent) !important;
    color: var(--text-on-accent) !important;
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* ---------- KB Map ---------- */
.kb-map {
    background: var(--bg-secondary) !important;
    border-radius: var(--radius-lg) !important;
    padding: 1.5rem !important;
    border: 1px solid var(--border-muted) !important;
    margin-top: 24px !important;
}

.kb-map h3 {
    color: var(--text-heading) !important;
    margin-bottom: 1rem !important;
}

.kb-map a {
    color: var(--accent) !important;
    font-weight: 500 !important;
}

.kb-map a:hover {
    color: var(--accent-hover) !important;
}

.kb-map li {
    color: var(--text-secondary) !important;
}

/* ---------- Form Controls ---------- */
.input,
.form-control,
input[type="text"],
input[type="number"],
select,
textarea {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-sm) !important;
}

.input:focus,
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-subtle) !important;
    outline: none !important;
}

/* ---------- Footer ---------- */
#footer {
    background-color: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-muted) !important;
}

#copyrights {
    background-color: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
}

#copyrights a {
    color: var(--text-secondary) !important;
}

#copyrights a:hover {
    color: var(--accent) !important;
}

.copyright-links a {
    color: var(--text-secondary) !important;
    font-weight: 500 !important;
}

/* ---------- Dark Mode Image Adjustments ---------- */
[data-theme="dark"] img {
    opacity: 0.92;
}

[data-theme="dark"] img:hover {
    opacity: 1;
}

[data-theme="dark"] #logo img {
    filter: brightness(1.15);
    opacity: 1;
}

/* ---------- Theme Toggle Button ---------- */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    margin-left: 12px;
    flex-shrink: 0;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    transform: scale(1.08);
}

.theme-icon {
    display: inline;
    pointer-events: none;
}

/* ---------- Scrollbar (Dark Mode) ---------- */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
}
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 5px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- Ads Placeholder Cleanup ---------- */
[data-theme="dark"] .ad-placeholder,
[data-theme="dark"] [id*="ezoic"],
[data-theme="dark"] ins.adsbygoogle {
    border-radius: var(--radius-md);
}

/* ---------- Reduce Image Nav Pills ---------- */
.nav-pills .nav-link {
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm) !important;
}

.nav-pills .nav-link.active,
.nav-pills .nav-link:hover {
    background: var(--accent-subtle) !important;
    color: var(--accent) !important;
}

/* ---------- Print: force light ---------- */
@media print {
    :root {
        --bg-primary: #fff !important;
        --text-primary: #000 !important;
    }
}
