/**
 * QuickTools — Design System (app.css)
 * Composants globaux : layout, topbar, buttons, cards, forms, alerts, etc.
 * Utilise uniquement les rôles sémantiques (--bg-primary, --accent, etc.)
 * Mobile-first.
 */

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}
a:hover { color: var(--accent-hover); opacity: 0.85; }

img { max-width: 100%; height: auto; display: block; }

/* ═══ SKIP LINK (a11y) ═══ */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: var(--text-inverse);
    padding: 8px 16px;
    z-index: 10000;
    border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus {
    left: 0;
}

/* ═══ CONTAINER ═══ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}
@media (min-width: 768px) {
    .container { padding: 0 var(--space-6); }
}

/* ═══ MAIN ═══ */
.main {
    flex: 1;
    padding: var(--space-6) 0;
}

/* ═══ TOPBAR ═══ */
.topbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.topbar__inner {
    display: flex;
    align-items: center;
    height: 60px;
    gap: var(--space-4);
}

.topbar__logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: var(--font-size-lg);
    flex-shrink: 0;
}
.topbar__logo-icon { font-size: 22px; }

.topbar__nav {
    display: none;
    align-items: center;
    gap: var(--space-1);
    margin-left: var(--space-6);
}
@media (min-width: 768px) {
    .topbar__nav { display: flex; }
}

.topbar__nav-link {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}
.topbar__nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.topbar__actions {
    display: none;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}
@media (min-width: 768px) {
    .topbar__actions { display: flex; }
}

.topbar__btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}
.topbar__btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.topbar__points {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: var(--accent-bg);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--accent-text);
    text-decoration: none;
}

.topbar__avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.topbar__cta {
    display: none;
}
@media (min-width: 1024px) {
    .topbar__cta { display: inline-flex; }
}

/* Dropdowns */
.topbar__lang-dropdown,
.topbar__user-dropdown {
    position: relative;
}

.topbar__dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 1001;
    overflow: hidden;
}
.topbar__dropdown.open { display: block; }

.topbar__dropdown-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-light);
}
.topbar__dropdown-header strong { display: block; }
.topbar__dropdown-sub {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.topbar__dropdown-item {
    display: block;
    padding: var(--space-2) var(--space-4);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: background var(--transition-fast);
}
.topbar__dropdown-item:hover { background: var(--bg-tertiary); }
.topbar__dropdown-item.active { color: var(--accent); font-weight: 600; }

/* Burger */
.topbar__burger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    margin-left: auto;
}
.topbar__burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-fast);
}
@media (min-width: 768px) {
    .topbar__burger { display: none; }
}

/* Mobile nav */
.mobile-nav {
    display: none;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
}
.mobile-nav.open { display: block; }
.mobile-nav__link {
    display: block;
    padding: var(--space-3) var(--space-2);
    color: var(--text-primary);
    font-weight: 500;
    border-radius: var(--radius-md);
}
.mobile-nav__link:hover { background: var(--bg-tertiary); }

/* Theme toggle icons */
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* ═══ BUTTONS ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 12px 24px;
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--text-inverse);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn-secondary:hover {
    background: var(--accent-bg);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
}

.btn-full { width: 100%; }

.btn:disabled,
.btn--loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══ CARDS ═══ */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-6);
    transition: box-shadow var(--transition-base), transform var(--transition-base), opacity var(--transition-base);
}
.card:hover {
    /* Only tool cards should lift on hover — apply .card--hover where needed */
}
.card--hover:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* ═══ FORMS ═══ */
.form-group {
    margin-bottom: var(--space-5);
}

.form-group--row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}
.form-label__link {
    font-size: var(--font-size-xs);
    font-weight: 400;
}

.input,
.textarea,
.select {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1.5px solid transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}
.input:focus,
.textarea:focus,
.select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
    background: var(--bg-primary);
}
.input::placeholder { color: var(--text-tertiary); }

.textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-hint {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.input-password-wrapper {
    position: relative;
}
.input-password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

.password-strength {
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.password-strength__bar {
    height: 4px;
    width: 0%;
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    background: var(--error);
}
.password-strength__text {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    white-space: nowrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* ═══ ALERTS ═══ */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}
.alert--error { background: var(--error-bg); color: var(--error); }
.alert--success { background: var(--success-bg); color: var(--success); }
.alert--warning { background: var(--warning-bg); color: var(--warning); }
.alert--info { background: var(--info-bg); color: var(--info); }

/* ═══ FLASH MESSAGES ═══ */
.flash-container {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 100%;
    max-width: 500px;
    padding: 0 var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    animation: flashIn 0.3s ease;
}
.flash--success { background: var(--success); color: #fff; }
.flash--error { background: var(--error); color: #fff; }
.flash--warning { background: var(--warning); color: #fff; }
.flash--info { background: var(--info); color: #fff; }

.flash__close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
}
.flash__close:hover { opacity: 1; }

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══ TOAST ═══ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: #fff;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}
.toast--success { background: var(--success); }
.toast--error { background: var(--error); }
.toast--warning { background: var(--warning); }
.toast--info { background: var(--info); }
.toast--points { background: var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ═══ AUTH PAGES ═══ */
.page-auth .main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px - 80px);
}
.page-auth .container {
    display: flex;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    padding: var(--space-8);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-top: var(--space-1);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ═══ PROFILE PAGE ═══ */
.profile-header {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    margin-bottom: var(--space-8);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-3xl);
    flex-shrink: 0;
}

.profile-info h1 { font-size: var(--font-size-2xl); }
.profile-info p { color: var(--text-secondary); font-size: var(--font-size-sm); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}
@media (min-width: 640px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.stat-card__value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--accent);
}
.stat-card__label {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.xp-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: var(--space-2);
}
.xp-bar__fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
}

.referral-box {
    background: var(--accent-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
}
.referral-box__code {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-weight: 600;
    margin-top: var(--space-3);
}

/* ═══ COOKIE BANNER ═══ */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 9997;
    padding: var(--space-4);
}
.cookie-banner__inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.cookie-banner__text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    flex: 1;
}
.cookie-banner__actions {
    display: flex;
    gap: var(--space-2);
}

/* ═══ FOOTER ═══ */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    padding: var(--space-8) 0;
    margin-top: auto;
}
.footer__inner {
    text-align: center;
}
.footer__logo {
    font-weight: 700;
    font-size: var(--font-size-lg);
}
.footer__tagline {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    margin-top: var(--space-1);
}
.footer__links {
    display: flex;
    justify-content: center;
    gap: var(--space-5);
    margin-top: var(--space-4);
}
.footer__links a {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}
.footer__links a:hover { color: var(--accent); }
.footer__copy {
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
    margin-top: var(--space-4);
}

/* ═══ EMPTY STATES ═══ */
.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-6);
    color: var(--text-tertiary);
}
.empty-state__icon { font-size: 48px; margin-bottom: var(--space-4); opacity: 0.5; }
.empty-state__text { margin-bottom: var(--space-4); }

/* ═══ BADGES GRID ═══ */
.badges-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.badge-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-tertiary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
}
.badge-item--locked { opacity: 0.35; }

/* ═══ SKELETON LOADING ═══ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
    animation: fadeInUp 0.3s ease;
}

/* ═══ LINK ACCESSIBILITY (WCAG — not color-only) ═══ */
p a, li a, .seo-content a, .tool-description a, .aeo-answer a,
.blog-content a, .footer__col a {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}
p a:hover, li a:hover, .seo-content a:hover {
    text-decoration-thickness: 2px;
}
/* Footer links: no underline (visual grouping is sufficient) */
.footer__col a { text-decoration: none; }
.footer__col a:hover { text-decoration: underline; }

/* ═══ RESPONSIVE UTILITIES ═══ */
.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: block; } }
.hide-desktop { display: block; }
@media (min-width: 768px) { .hide-desktop { display: none; } }

/* ═══ TOUCH TARGET ACCESSIBILITY (WCAG 2.5.5 — min 44x44px) ═══ */
@media (max-width: 768px) {
    nav a, nav button,
    .topbar__btn, .topbar__nav-link--primary,
    .bottom-bar__link,
    .hero__pill,
    .btn, .btn-sm, .btn-ghost {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .topbar__logo { min-height: 44px; display: flex; align-items: center; }
    .bottom-bar__link { padding: 6px 8px; }
}

/* ═══ COMPOSITE-ONLY ANIMATIONS (Lighthouse: avoid non-composited animations) ═══ */
/* Override transition: all with composite-safe properties only */
.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-sm {
    transition: opacity 0.15s, transform 0.15s !important;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:hover { filter: brightness(1.08); }

.tool-card-item {
    transition: transform 0.2s, opacity 0.2s !important;
}
.tool-card-link:hover .tool-card-item {
    transform: translateY(-3px);
}

.topbar__nav-link, .topbar__nav-link--primary,
.footer__col a, .footer__suggestion-chip {
    transition: opacity 0.15s !important;
}
.topbar__nav-link:hover, .topbar__nav-link--primary:hover,
.footer__col a:hover, .footer__suggestion-chip:hover {
    opacity: 0.8;
}

/* Prevent animation on SVG color (non-compositable) */
.qt-icon { transition: none !important; }

/* Tool cards: reserve min-height to prevent CLS */
.tool-card-item {
    min-height: 110px;
    contain: layout style;
}

/* will-change hint for frequently animated elements */
.btn, .tool-card-link, .bottom-bar__link {
    will-change: transform, opacity;
}
