/*
  QR Service UI
  - Minimal, calm, premium-ish look
  - No frameworks, no heavy animations
*/

:root {
    --bg: #f7f7fb;
    --surface: #ffffff;
    --surface-2: #fbfbff;
    --text: #0f172a;
    --text-rgb: 15, 23, 42;
    --muted: #64748b;
    --border: rgba(15, 23, 42, 0.10);
    --shadow: 0 12px 30px rgba(2, 6, 23, 0.06);
    --shadow-sm: 0 6px 18px rgba(2, 6, 23, 0.06);
    --radius: 16px;
    --radius-sm: 12px;

    /* Accent: muted emerald (no blue) */
    --accent: #22c55e;
    --accent-strong: #16a34a;
    --accent-ring: rgba(34, 197, 94, 0.18);

    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-text: #7f1d1d;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-text: #14532d;
    --info-bg: #eff6ff;
    --info-text: #1e40af;

    --header-bg: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #1e293b;
    --text: #f1f5f9;
    --text-rgb: 241, 245, 249;
    --muted: #94a3b8;
    --border: rgba(241, 245, 249, 0.12);
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.2);

    --accent: #22c55e;
    --accent-strong: #4ade80;
    --accent-ring: rgba(34, 197, 94, 0.25);

    --success-bg: rgba(22, 163, 74, 0.1);
    --success-text: #4ade80;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --danger-text: #fca5a5;
    --info-bg: rgba(59, 130, 246, 0.1);
    --info-text: #93c5fd;

    --header-bg: rgba(15, 23, 42, 0.85);
}

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

html,
body {
    height: 100%;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
    line-height: 1.55;
    color: var(--text);
    /* Subtle, dynamic light background */
    background:
        radial-gradient(1200px 600px at 12% 0%, rgba(34, 197, 94, 0.10), transparent 60%),
        radial-gradient(900px 500px at 92% 12%, rgba(16, 185, 129, 0.08), transparent 55%),
        linear-gradient(180deg, var(--bg), var(--bg));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

main {
    flex: 1;
    padding: 2rem 0 2.75rem;
}

/* Top navigation */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.user-greeting {
    position: absolute;
    top: 0.5rem;
    right: 1.25rem;
    z-index: 11;
    pointer-events: none;
}

.user-greeting .nav-meta {
    pointer-events: auto;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.3px;
    padding: 0.25rem 0.4rem;
    border-radius: 6px;
    transition: background 0.15s ease;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.brand:hover {
    background: rgba(var(--text-rgb), 0.03);
}

.brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    flex: 1;
    margin-left: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.nav-links::-webkit-scrollbar {
    display: none;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-meta {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    background: rgba(var(--text-rgb), 0.05);
    border: 1px solid var(--border);
    transition: background 0.15s ease;
    flex-shrink: 0;
    display: inline-block;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.2);
    transform: translateY(-1px);
}

.nav-link.primary {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.25);
    font-weight: 600;
}

.nav-link.active {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.25);
    font-weight: 600;
    color: var(--accent-strong);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.card-header {
    margin-bottom: 1.25rem;
}

h1,
h2,
h3 {
    letter-spacing: -0.2px;
}

h2 {
    font-size: 1.45rem;
    margin-bottom: 0.3rem;
}

.subtle {
    color: var(--muted);
    font-size: 0.98rem;
}

main a:not(.btn) {
    color: var(--accent-strong);
    text-decoration: none;
    font-weight: 650;
}

main a:not(.btn):hover {
    text-decoration: underline;
}

/* Auth pages */
.auth-wrap {
    display: grid;
    place-items: center;
    padding-top: 1.25rem;
}

.auth-card {
    width: 100%;
    max-width: 460px;
}

.profile-page .auth-card {
    max-width: 600px;
}

/* Forms */
form {
    display: grid;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 650;
    font-size: 0.92rem;
    color: var(--text);
    opacity: 0.9;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(2, 6, 23, 0.03);
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.3s ease, color 0.3s ease;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: rgba(34, 197, 94, 0.55);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.05rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 650;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #35d06a, #169a45);
}

.btn-secondary {
    background: rgba(var(--text-rgb), 0.06);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(var(--text-rgb), 0.1);
    border-color: var(--border);
}

.btn:disabled,
button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}

/* Alerts */
.alert {
    margin-top: 1rem;
    padding: 0.85rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.95rem;
    display: none;
}

.alert:not(:empty) {
    display: block;
}

.alert-error {
    color: var(--danger-text);
    background: var(--danger-bg);
    border-color: rgba(220, 38, 38, 0.24);
}

.alert-success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: rgba(22, 163, 74, 0.22);
}

/* Result blocks */
.result {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.result h3 {
    font-size: 1.02rem;
    margin-bottom: 0.75rem;
}

.qr-preview {
    display: grid;
    place-items: center;
    padding: 0.75rem 0.25rem 0.25rem;
}

.qr-preview img {
    width: min(340px, 100%);
    height: auto;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.actions-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Decode info box */
.info-box {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    overflow-wrap: anywhere;
}

.info-box a {
    color: var(--accent-strong);
    text-decoration: underline;
    font-weight: 650;
}

.info-box a:hover {
    text-decoration: none;
}

/* Dropzone */
.dropzone {
    display: grid;
    gap: 0.25rem;
    padding: 1.1rem;
    border-radius: var(--radius);
    border: 1.5px dashed rgba(34, 197, 94, 0.28);
    background: rgba(34, 197, 94, 0.04);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.dropzone:hover {
    background: rgba(34, 197, 94, 0.06);
    border-color: rgba(34, 197, 94, 0.36);
}

.dropzone.dragover {
    background: rgba(34, 197, 94, 0.09);
    border-color: rgba(34, 197, 94, 0.52);
}

.dropzone-title {
    font-weight: 700;
}

.dropzone-hint {
    color: var(--muted);
    font-size: 0.95rem;
}

.file-name {
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.92rem;
}

/* Footer */
footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
    padding: 1rem 0;
}

footer p {
    margin: 0;
    font-size: 0.92rem;
}

/* Accessibility helpers */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* History Page Styles */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.12s ease, transform 0.12s ease, background 0.3s ease;
}

.history-item:hover {
    box-shadow: 0 4px 16px rgba(2, 6, 23, 0.08);
    transform: translateY(-2px);
}

.history-item .qr-preview {
    padding: 0.5rem;
}

.history-item .qr-preview img {
    width: 100%;
    max-width: 200px;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.history-item-text {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: background 0.3s ease;
}

.qr-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: center;
}

.qr-data {
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
    font-size: 0.95rem;
}

.qr-date {
    color: var(--muted);
    font-size: 0.85rem;
}

.qr-meta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.badge-scan {
    background: rgba(34, 197, 94, 0.1);
    color: var(--accent-strong);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.qr-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

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

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}

.empty-state p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.alert-info {
    color: var(--info-text);
    background: var(--info-bg);
    border-color: rgba(59, 130, 246, 0.22);
}

#generated-section h3,
#decoded-section h3 {
    font-size: 1.15rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Home Page Styles */
.home-hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
    margin-bottom: 2rem;
}

.home-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: rgba(34, 197, 94, 0.3);
}

.feature-card:hover::before {
    transform: scaleX(1);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.feature-arrow {
    font-size: 1.5rem;
    color: var(--accent);
    margin-top: auto;
    transition: transform 0.2s ease;
}

.feature-card:hover .feature-arrow {
    transform: translateX(4px);
}

.cta-section {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 2rem;
}

.cta-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.cta-section p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Small screens */
@media (max-width: 640px) {
    .card {
        padding: 1.25rem;
    }

    .navbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .history-grid {
        grid-template-columns: 1fr;
    }

    .home-hero h1 {
        font-size: 2rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }
}