/* ===== CSS Variables & Reset ===== */
:root {
    --bg: #0a0a0f;
    --bg-card: #13131a;
    --bg-card-hover: #1a1a24;
    --bg-input: #0e0e16;
    --border: #1f1f2e;
    --border-focus: #6c5ce7;
    --accent: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --accent-light: #a29bfe;
    --text: #e8e8f0;
    --text-muted: #6b6b80;
    --text-dim: #44445a;
    --success: #00cec9;
    --danger: #ff6b6b;
    --warning: #feca57;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px var(--accent-glow);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.6;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Background gradient decoration */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(108,92,231,0.06) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(0,206,201,0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===== Pages ===== */
.page {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    z-index: 1;
}
.page.active { display: flex; }

/* ===== Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(10,10,15,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}
.logo-icon.small { width: 36px; height: 36px; border-radius: 10px; }
.logo-icon .material-icons-round { font-size: 22px; color: #fff; }
.logo-icon.small .material-icons-round { font-size: 18px; }

.app-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: -2px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}
.header-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    text-decoration: none;
    box-shadow: var(--shadow-glow);
}
.header-btn .material-icons-round { font-size: 18px; color: var(--accent-light); }

/* ===== Scan Main ===== */
.scan-main {
    flex: 1;
    padding: 24px 20px 120px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Language Selector ===== */
.language-section { margin-bottom: 28px; }

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.section-label .material-icons-round { font-size: 18px; color: var(--accent-light); }

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 14px 44px 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}
.select-wrapper select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.select-wrapper select option {
    background: var(--bg-card);
    color: var(--text);
    padding: 8px;
}
.select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 22px;
}

/* ===== Result Area ===== */
.result-area {
    animation: fadeSlideUp 0.4s ease;
}

.result-image-wrap {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    max-height: 300px;
}
.result-image-wrap img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
    display: block;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.result-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 12px;
}
.result-label .material-icons-round { font-size: 16px; }

.result-text {
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.result-original {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ===== Loading ===== */
.loading-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 0;
    animation: fadeIn 0.3s ease;
}
.loading-area p { color: var(--text-muted); font-size: 0.9rem; }

.loader-ring {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== Scanner ===== */
.scanner-area {
    animation: fadeSlideUp 0.35s ease;
}

.qr-reader {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-glow);
}

/* Override html5-qrcode styles */
#qr-reader {
    border: none !important;
}
#qr-reader video {
    border-radius: var(--radius-sm);
}

.btn-cancel-scan {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: rgba(255,107,107,0.1);
    border: 1px solid rgba(255,107,107,0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-cancel-scan:hover { background: rgba(255,107,107,0.2); }

/* ===== Bottom Bar ===== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    z-index: 200;
}

.btn-scan {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-glow), 0 4px 20px rgba(108,92,231,0.4);
    transition: var(--transition);
    letter-spacing: 0.3px;
}
.btn-scan:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow), 0 8px 30px rgba(108,92,231,0.5); }
.btn-scan:active { transform: translateY(0); }
.btn-scan .material-icons-round { font-size: 24px; }

/* ===== Create Page ===== */
.create-main {
    flex: 1;
    padding: 24px 20px 40px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.create-form-section { display: flex; flex-direction: column; gap: 20px; }

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

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}
.form-label .material-icons-round { font-size: 20px; color: var(--accent-light); }
.form-label .flag-emoji { font-size: 1.1rem; }
.optional { color: var(--text-dim); font-weight: 400; font-size: 0.78rem; }

.form-input, .form-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.92rem;
    line-height: 1.6;
    outline: none;
    transition: var(--transition);
    resize: vertical;
}
.form-input:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-dim); }

.image-preview-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    max-height: 180px;
}
.image-preview-wrap img {
    width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: cover;
    display: block;
}

.btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
}
.btn-generate:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow), 0 8px 30px rgba(108,92,231,0.5); }
.btn-generate:active { transform: translateY(0); }
.btn-generate .material-icons-round { font-size: 22px; }

/* ===== QR Output ===== */
.qr-output { margin-top: 28px; animation: fadeSlideUp 0.4s ease; }

.qr-output-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow);
}
.qr-output-card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent-light), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.qr-code-container {
    display: inline-block;
    padding: 16px;
    background: #fff;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.qr-code-container canvas, .qr-code-container img { display: block; }

.qr-hint { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.btn-secondary .material-icons-round { font-size: 18px; }

/* ===== Footer ===== */
.app-footer {
    padding: 20px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Animations ===== */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Kamera-Berechtigungs-Modal ===== */
.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.camera-modal.hidden { display: none !important; }

.camera-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.camera-modal-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px 24px;
    width: 100%;
    max-width: 440px;
    text-align: center;
    animation: fadeSlideUp 0.3s ease;
    box-shadow: var(--shadow);
}

.camera-modal-icon {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
}
.camera-modal-icon .material-icons-round { font-size: 34px; color: var(--danger); }
.camera-modal-icon.warn { background: rgba(254,202,87,0.1); border-color: rgba(254,202,87,0.25); }
.camera-modal-icon.warn .material-icons-round { color: var(--warning); }
.camera-modal-icon.info { background: rgba(108,92,231,0.1); border-color: rgba(108,92,231,0.25); }
.camera-modal-icon.info .material-icons-round { color: var(--accent-light); }

.camera-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.camera-modal-msg {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 18px;
}

.camera-modal-steps {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 20px;
    text-align: left;
}
.camera-modal-steps:empty { display: none; margin: 0; }
.camera-modal-steps .steps-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: block;
}
.camera-modal-steps ol {
    padding-left: 18px;
    font-size: 0.84rem;
    color: var(--text);
    line-height: 1.85;
    margin: 0;
}
.camera-modal-steps ol li strong { color: var(--text); }

.camera-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.camera-modal-actions .btn-scan {
    position: relative;
    z-index: 1;
}
.camera-modal-actions .btn-secondary {
    width: 100%;
    justify-content: center;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
    .scan-main, .create-main { padding-left: 32px; padding-right: 32px; }
    .app-header { padding: 18px 32px; }
    .bottom-bar { padding: 20px 32px; }
}
