/* ═══════════════════════════════════════════════════════════════
   OIA Design System — CSS Custom Properties
   Light/Dark mode + Branding Admin customizable
   ═══════════════════════════════════════════════════════════════ */

/* ─── Light palette (defaults) ─── */
:root {
    /* Backgrounds */
    --bg-app: #f5f7fa;
    --bg-surface: #ffffff;
    --bg-card: #f5f7fa;
    --bg-input: #f8fafc;
    --bg-hover: #f0f2f5;

    /* Accent */
    --accent: #1565c0;
    --accent-light: #e8f4fd;
    --accent-stroke: #b8d8f0;
    --accent-dark: #0d47a1;
    --accent-hover: #e0ecf8;

    /* Semantic */
    --danger: #e53935;
    --danger-light: #fff5f5;
    --warning: #f59e0b;
    --warning-light: #fffbf0;
    --success: #2e7d32;
    --success-light: #e8f5e9;
    --info: #1565c0;
    --info-light: #e8f4fd;

    /* Borders */
    --border: #dde3ed;
    --border-hover: #b8cce0;
    --border-focus: #1565c0;

    /* Text */
    --text-primary: #1a2640;
    --text-secondary: #6b7a90;
    --text-tertiary: #aab4c4;
    --text-accent: #0d47a1;
    --text-on-accent: #ffffff;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 20px;
    --radius-full: 9999px;

    /* Chat specific */
    --bubble-user-radius: 18px 18px 4px 18px;
    --bubble-assistant-radius: 4px 18px 18px 18px;
    --input-radius: 24px;

    /* Typography */
    --font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
}

/* ─── Dark palette ─── */
.dark {
    --bg-app: #0f1117;
    --bg-surface: #1a1d27;
    --bg-card: #1e2130;
    --bg-input: #252836;
    --bg-hover: #2a2e3d;

    --accent: #5b9bd5;
    --accent-light: #1e3a5f;
    --accent-stroke: #2d5a8a;
    --accent-dark: #8bbde8;
    --accent-hover: #253d5a;

    --danger: #ef5350;
    --danger-light: #2d1b1b;
    --warning: #fbbf24;
    --warning-light: #2d2510;
    --success: #66bb6a;
    --success-light: #1b2d1c;
    --info: #5b9bd5;
    --info-light: #1e3a5f;

    --border: #2a2e3d;
    --border-hover: #3a4055;
    --border-focus: #5b9bd5;

    --text-primary: #e4e7ec;
    --text-secondary: #8b95a5;
    --text-tertiary: #555d6e;
    --text-accent: #8bbde8;
    --text-on-accent: #ffffff;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ═══════════════════════════════════════════════════════════════
   Base styles
   ═══════════════════════════════════════════════════════════════ */

body {
    font-family: var(--font-family);
    font-weight: var(--font-weight-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Prose (markdown rendering) ─── */
.prose pre {
    background-color: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    overflow-x: auto;
    font-size: 0.8125rem;
}

.prose code {
    font-size: 0.8125rem;
    background-color: var(--bg-card);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

.prose pre code {
    background: none;
    padding: 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.prose th,
.prose td {
    border: 0.5px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.prose th {
    background-color: var(--bg-card);
    font-weight: var(--font-weight-medium);
}

/* ─── Scrollbars ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ─── Form elements ─── */
textarea:focus,
input:focus,
select:focus {
    outline: none;
    box-shadow: none;
}

/* ─── Skeleton loading ─── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-surface) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* ─── Module @mention badges (dans les bulles de messages) ─── */
.mention-module-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    vertical-align: middle;
    background: rgba(232, 247, 242, 0.25);
    color: #fff;
    border: 0.5px solid rgba(93, 202, 165, 0.5);
}
/* En dehors de la bulle user (assistant/preview) : thème teal classique */
.bg-surface .mention-module-badge,
.prose .mention-module-badge {
    background: #E8F7F2;
    color: #0F6E56;
    border-color: #5DCAA5;
}
.dark .bg-surface .mention-module-badge,
.dark .prose .mention-module-badge {
    background: rgba(29, 158, 117, 0.15);
    color: #5CC9A3;
    border-color: rgba(93, 202, 165, 0.3);
}

/* ─── Alpine.js cloak ─── */
[x-cloak] {
    display: none !important;
}

/* ─── Transitions (subtiles) ─── */
* {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 0.15s;
    transition-timing-function: ease;
}

/* Désactiver transitions sur les éléments qui ne doivent pas transitionner */
pre *, code *, svg, img, canvas, video {
    transition: none;
}
