/*
   QR CODE GENERATOR - EXPERT WEB TOOLS
   Version 4 (Global Theme Integration)
*/

@font-face { font-family: 'Inter';       src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Orbitron';    src: url('/fonts/orbitron-v35-latin-700.woff2')  format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Roboto Mono'; src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    /* Dark Theme Variables (Default) */
    --bg-main:          #0a0a0f;
    --primary-accent:   #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main:        #ffffff;
    --text-muted:       #94a3b8;
    --card-bg:          rgba(25, 25, 35, 0.6);
    --card-border:      rgba(255, 255, 255, 0.08);
    --input-bg:         rgba(255, 255, 255, 0.05);
    --hover-bg:         rgba(255, 255, 255, 0.1);
    --font-heading:     'Orbitron', sans-serif;
    --font-body:        'Inter', sans-serif;
    --font-code:        'Roboto Mono', monospace;
}

/* Light Theme Variables (Synchronized Architecture) */
html.light-theme {
    --bg-main:          #f8fafc;
    --primary-accent:   #2563eb;
    --secondary-accent: #7c3aed;
    --text-main:        #0f172a;
    --text-muted:       #475569;
    --card-bg:          #ffffff;
    --card-border:      #cbd5e1;
    --input-bg:         #f1f5f9;
    --hover-bg:         rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* STRICT CHROMIUM BUG FIX: transition background-color only */
html, body {
    background-color: var(--bg-main);
    transition: background-color 0.2s ease;
}

body {
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Accessibility --- */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* Custom Scrollbars */
::-webkit-scrollbar        { width: 8px; height: 8px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--card-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-accent); }

/* Dynamic Glow */
.background-glow {
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59,130,246,0.08) 0%, transparent 50%);
    z-index: -1; pointer-events: none;
    transition: background 0.3s ease;
}
html.light-theme .background-glow {
    background: radial-gradient(circle at center, rgba(37,99,235,0.05) 0%, transparent 50%);
}

/* --- Header --- */
.tool-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 5%; max-width: 1400px; margin: 0 auto; width: 100%;
    flex-wrap: wrap; gap: 10px;
}
.back-btn {
    color: var(--text-muted); text-decoration: none; display: flex; align-items: center; gap: 8px;
    transition: color 0.3s; border-radius: 4px; padding: 2px 4px; font-weight: 500;
}
.back-btn:hover { color: var(--primary-accent); }
.back-btn:focus-visible { outline: 2px solid var(--primary-accent); color: var(--primary-accent); }
.logo { font-family: var(--font-heading); font-size: 1.2rem; margin: 0 auto; }
.logo span { color: var(--primary-accent); }

/* Sync'd Theme Toggle Button */
.theme-toggle-btn { 
    background: transparent; border: 1px solid var(--card-border); 
    color: var(--text-muted); width: 36px; height: 36px; border-radius: 8px; 
    cursor: pointer; display: flex; align-items: center; justify-content: center; 
    transition: all 0.2s ease;
}
.theme-toggle-btn:hover { border-color: var(--primary-accent); color: var(--primary-accent); background: var(--hover-bg); }
.theme-toggle-btn:focus-visible { outline: 2px solid var(--primary-accent); }

/* --- Intro --- */
.tool-intro { text-align: center; margin-bottom: 2rem; padding: 0 5%; }
.tool-intro h1 { font-family: var(--font-heading); font-size: 2rem; margin-bottom: 0.5rem; line-height: 1.2; }
.tool-intro p { color: var(--text-muted); }

/* --- Main Layout --- */
.main-content { flex-grow: 1; padding: 2rem 5%; max-width: 1200px; margin: 0 auto; width: 100%; }

.tool-layout {
    display: grid; grid-template-columns: 1fr 400px; gap: 2rem; align-items: start; width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 1.5rem; margin-bottom: 1.5rem;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); width: 100%; transition: background 0.3s ease, border-color 0.3s ease;
}
.card h3 { font-family: var(--font-heading); font-size: 1rem; color: var(--text-muted); margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: 1px; }
.card h3 i { color: var(--primary-accent); }

/* Options Panel */
.options-panel { display: flex; flex-direction: column; width: 100%; min-width: 0; }

/* Tabs */
.qr-type-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; border-radius: 8px; }
.qr-type-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 1; min-width: 0; background: transparent; border: 1px solid var(--card-border); color: var(--text-muted);
    padding: 10px 8px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; white-space: nowrap; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--font-body); min-height: 44px;
}
.tab-btn:hover { background: var(--hover-bg); color: var(--text-main); }
.tab-btn:focus-visible { outline: 2px solid var(--primary-accent); }
.tab-btn.active { background: var(--primary-accent); color: #fff; border-color: var(--primary-accent); }

/* Inputs */
.input-group { display: flex; flex-direction: column; }
.input-group label { display: block; margin-bottom: 6px; margin-top: 12px; color: var(--text-muted); font-size: 0.9rem; }
.input-group label:first-child { margin-top: 0; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.qr-input {
    width: 100%; background: var(--input-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 12px;
    color: var(--text-main); font-family: var(--font-body); font-size: 1rem; outline: none; margin-bottom: 0;
    transition: border-color 0.2s; -webkit-appearance: none; appearance: none;
}
.qr-input:focus { border-color: var(--primary-accent); }
.qr-input:focus-visible { outline: none; }
select.qr-input { cursor: pointer; }
select.qr-input option { background: var(--card-bg); color: var(--text-main); }
html.light-theme select.qr-input option { background: #ffffff; color: #0f172a; }
textarea.qr-input { resize: vertical; min-height: 100px; }

/* Customization */
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.color-option label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 0.9rem; }

.color-input {
    width: 100%; height: 48px; padding: 0; border: 1px solid var(--card-border); border-radius: 8px;
    cursor: pointer; background: var(--input-bg); outline: none; -webkit-appearance: none; -moz-appearance: none; appearance: none; overflow: hidden;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; }
.color-input::-moz-color-swatch { border: none; }
.color-input:focus-visible { outline: 2px solid var(--primary-accent); outline-offset: 2px; }

.file-upload-wrapper { display: flex; align-items: center; gap: 10px; }
.file-label {
    flex: 1; background: var(--input-bg); border: 1px dashed var(--card-border); padding: 12px; border-radius: 8px;
    text-align: center; cursor: pointer; color: var(--text-muted); transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
}
.file-label:hover { border-color: var(--primary-accent); color: var(--primary-accent); }
.file-label:focus-visible { outline: 2px solid var(--primary-accent); border-radius: 8px; }

.remove-btn {
    background: rgba(239,68,68,0.1); color: #f87171; border: 1px solid rgba(239,68,68,0.2); min-width: 44px; min-height: 44px;
    border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; font-family: var(--font-body);
}
.remove-btn:hover { background: #ef4444; color: #fff; }
.remove-btn:focus-visible { outline: 2px solid #ef4444; }

/* Preview Panel */
.preview-panel { position: sticky; top: 2rem; width: 100%; min-width: 0; }
.preview-card { text-align: center; display: flex; flex-direction: column; align-items: center; }

.qr-canvas-wrapper {
    background: #ffffff; padding: 20px; border-radius: 12px; margin-bottom: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    width: 100%; max-width: min(320px, 100%); aspect-ratio: 1 / 1; display: flex; justify-content: center; align-items: center;
}
.qr-canvas-wrapper svg, .qr-canvas-wrapper canvas { width: 100% !important; height: 100% !important; display: block; }

/* Download buttons */
.download-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; width: 100%; }
.download-btn {
    padding: 12px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 1rem;
    transition: transform 0.2s, background 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; font-family: var(--font-body);
}
.download-btn:focus-visible { outline: 2px solid var(--primary-accent); outline-offset: 2px; }
.download-btn:hover { transform: translateY(-2px); }
.download-btn.primary { background: var(--primary-accent); color: #fff; border-color: var(--primary-accent); }
.download-btn.primary:hover { background: #2563eb; }
.download-btn.secondary { background: transparent; border-color: var(--card-border); color: var(--text-main); }
.download-btn.secondary:hover { background: var(--hover-bg); }

.info-card-mini { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.info-card-mini i { color: #10b981; margin-right: 5px; }

/* Utilities */
.hidden { display: none !important; opacity: 0; pointer-events: none; }
.mt-1 { margin-top: 1rem; }
.hint { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }

/* Toast */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #1e1e24; border: 1px solid var(--primary-accent);
    color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 0.9rem;
    white-space: nowrap; opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
html.light-theme .toast { background: #ffffff; color: #0f172a; border-color: var(--primary-accent); }
.toast.toast-visible { opacity: 1; pointer-events: auto; }
.toast.toast-error { border-color: #ef4444; color: #fca5a5; }
html.light-theme .toast.toast-error { border-color: #ef4444; color: #dc2626; }

/* Info Section */
.info-section { margin-top: 4rem; padding: 0 1rem; width: 100%; }
.info-section h2 { font-family: var(--font-heading); color: var(--text-main); margin-bottom: 2rem; font-size: 1.5rem; text-align: center; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.info-grid h3 { color: var(--primary-accent); font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: 0.5rem; }
.info-grid p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.faq-container { margin-top: 3rem; background: var(--card-bg); border: 1px solid var(--card-border); padding: 2rem; border-radius: 16px; }
.faq-container h3 { font-family: var(--font-heading); color: var(--text-main); margin-bottom: 1.5rem; border-bottom: 1px solid var(--card-border); padding-bottom: 0.5rem; }
.faq-container h4 { color: var(--primary-accent); font-size: 1rem; margin-bottom: 0.5rem; margin-top: 1.5rem; font-family: var(--font-body); }
.faq-container p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1rem; line-height: 1.6; }

footer { text-align: center; padding: 3rem 0; color: var(--text-muted); font-size: 0.9rem; border-top: 1px solid var(--card-border); margin-top: 3rem; }
footer a { color: var(--primary-accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* === RESPONSIVE === */

@media (max-width: 900px) {
    .tool-layout { grid-template-columns: 1fr; }
    .preview-panel { position: static; top: auto; order: -1; margin-bottom: 0; }
    .info-grid { grid-template-columns: 1fr; }
    .qr-canvas-wrapper { max-width: min(360px, 100%); }
}

@media (max-width: 768px) {
    textarea.qr-input { resize: none; }
}

@media (max-width: 480px) {
    .tool-header { padding: 1rem; align-items: center; justify-content: space-between; }
    .main-content { padding: 1rem; }
    .tool-intro h1 { font-size: 1.4rem; }
    .card { padding: 1rem; border-radius: 12px; }
    .tab-label { display: none; }
    .tab-btn { padding: 10px 6px; }
    .download-actions { grid-template-columns: 1fr; }
    .input-row { grid-template-columns: 1fr; }
    .color-grid { grid-template-columns: 1fr; }
    .qr-canvas-wrapper { padding: 12px; max-width: 100%; }
    .info-grid { grid-template-columns: 1fr; }
    .faq-container { padding: 1.5rem 1rem; }
}

@media (max-width: 360px) {
    .download-actions { grid-template-columns: 1fr; }
    .tab-btn { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    .download-btn:hover { transform: none; }
}