/* ============================================================
   Atelier « Quelle IA ? » — feuille de style unique (Bootstrap-like)
   Charte EPA : teal #009FA8, orange #FF6A00, Arial, sobre.
   ============================================================ */

:root {
    --teal:        #009FA8;
    --teal-dark:   #017c83;
    --teal-darker: #0b5c61;
    --orange:      #FF6A00;
    --orange-dark: #e65f00;
    --ink:         #123037;
    --muted:       #6a7f83;
    --line:        #e2e9ea;
    --bg:          #f4f8f8;
    --card:        #ffffff;
    --danger:      #c0392b;
    --danger-bg:   #fdecea;
    --success:     #1a7a44;
    --success-bg:  #e6f6ec;
    --radius:      10px;
    --shadow:      0 6px 22px rgba(11, 92, 97, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--teal-dark); }

/* ---------- Structure : sidebar + main ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 224px;
    flex: 0 0 224px;
    background: linear-gradient(160deg, var(--teal) 0%, var(--teal-dark) 55%, var(--teal-darker) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar-brand img {
    display: block;
    width: 100%;
    height: auto;
}

.sidebar-body {
    padding: 20px 22px 8px;
}

.sidebar-title {
    font-size: 22px;
    margin: 0 0 6px;
    line-height: 1.15;
    font-weight: bold;
}
.sidebar-title span { font-weight: normal; opacity: .92; }

.sidebar-tagline {
    margin: 0;
    font-size: 13px;
    opacity: .85;
}

.sidebar-admin {
    margin-top: auto;
    padding: 18px 22px 22px;
    border-top: 1px solid rgba(255, 255, 255, .18);
}
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: rgba(255, 255, 255, .15);
    padding: 4px 10px;
    border-radius: 20px;
}
.admin-badge .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, .3);
}
.admin-user { margin: 10px 0; font-weight: bold; }
.admin-link {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    opacity: .8;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.admin-link:hover { opacity: 1; }

.main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 26px 30px 60px;
    max-width: 1100px;
}

/* ---------- Onglets (nav-tabs faits main) ---------- */
.tab-nav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.tab-btn {
    position: relative;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    color: var(--muted);
    padding: 12px 18px;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color .15s, background .15s;
    margin-bottom: -2px;
}
.tab-btn .tab-ico { font-size: 16px; }
.tab-btn:hover { color: var(--ink); background: #eef4f4; }

.tab-btn.is-active { color: #fff; }
.tab-btn.tab-teal.is-active   { background: var(--teal); border-bottom: 2px solid var(--teal); }
.tab-btn.tab-orange.is-active { background: var(--orange); border-bottom: 2px solid var(--orange); }

.tab-badge {
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .03em;
    animation: pulse 1.4s infinite;
}
.tab-btn.tab-orange.is-active .tab-badge { background: #fff; color: var(--orange); }
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- En-tête de section + barre admin ---------- */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.section-head h2 {
    margin: 0;
    font-size: 20px;
}
.section-intro {
    color: var(--muted);
    margin: 0 0 18px;
    font-size: 14px;
}

/* ---------- Thèmes & items (onglet 1) ---------- */
.theme-block {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}
.theme-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: #f0f7f7;
    border-bottom: 1px solid var(--line);
}
.theme-header .theme-name {
    font-size: 16px;
    font-weight: bold;
    color: var(--teal-darker);
    flex: 1 1 auto;
}
.theme-header .theme-actions { display: flex; gap: 6px; }

.item-list { list-style: none; margin: 0; padding: 6px; min-height: 8px; }
.item-list.dragover { background: rgba(0, 159, 168, .06); }

.item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
}
.item + .item { border-top: 1px solid var(--line); }
.item:hover { background: #f7fbfb; }
.item.dragging { opacity: .5; }
.item.drop-target { border: 1px dashed var(--teal); background: rgba(0,159,168,.05); }

.item-icon {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: #fff;
}
.item-icon.type-file   { background: var(--teal); }
.item-icon.type-prompt { background: var(--orange); }

.item-main { flex: 1 1 auto; min-width: 0; }
.item-title { font-weight: bold; margin: 0 0 2px; }
.item-meta { font-size: 12px; color: var(--muted); }

.item-prompt {
    position: relative;
    margin-top: 8px;
    background: #f4f7f8;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 15.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow: auto;
}

.item-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 18px;
    padding: 2px 4px;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }

.empty-hint {
    color: var(--muted);
    font-size: 14px;
    padding: 24px;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--card);
}

/* ---------- Informations live (onglet 2) ---------- */
.live-list { display: flex; flex-direction: column; gap: 14px; }
.live-msg {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--orange);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}
.live-msg .live-time {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.live-msg .live-body { white-space: pre-wrap; word-break: break-word; font-size: 16.5px; line-height: 1.6; }
.live-attach {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f0f7f7;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    text-decoration: none;
    color: var(--teal-dark);
    font-weight: bold;
}
.live-attach:hover { background: #e6f2f2; }

/* ---------- Ressources internet (onglet 3) ---------- */
.link-list { display: flex; flex-direction: column; gap: 12px; }
.link-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}
.link-card .link-body { flex: 1 1 auto; min-width: 0; }
.link-card .link-name { font-size: 16px; font-weight: bold; margin: 0 0 2px; }
.link-card .link-name a { text-decoration: none; }
.link-card .link-name a:hover { text-decoration: underline; }
.link-card .link-desc { color: var(--ink); margin: 3px 0 7px; font-size: 16px; line-height: 1.5; }
.link-card .link-url a { font-size: 15px; color: var(--teal); word-break: break-all; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 15px;
    cursor: pointer;
    text-decoration: none;
    transition: filter .12s, background .12s, border-color .12s;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.04); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-accent  { background: var(--orange); color: #fff; }
.btn-light   { background: #fff; color: var(--teal-dark); border-color: var(--line); }
.btn-ghost   { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); background: #f2f6f6; }
.btn-danger  { background: #fff; color: var(--danger); border-color: #f0c4c0; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-icon { padding: 6px 9px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Alertes ---------- */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin: 0 0 16px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-danger  { background: var(--danger-bg);  color: #a5281c; border-color: #f5c6cd; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #b6e3c6; }
.alert-info    { background: #e8f4f5; color: var(--teal-darker); border-color: #c4e3e5; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 9px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-file   { background: rgba(0,159,168,.14);  color: var(--teal-dark); }
.badge-prompt { background: rgba(255,106,0,.14);  color: var(--orange-dark); }

/* ---------- Formulaires ---------- */
.form-group { margin-bottom: 14px; }
label.form-label { display: block; font-weight: bold; font-size: 13px; margin-bottom: 5px; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cdd8da;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
textarea.form-control { min-height: 120px; resize: vertical; }
.form-control:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(0, 159, 168, .15);
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1 1 0; }

/* Choix Fichier / Prompt (segmented control) */
.type-toggle { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.type-toggle label {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    color: var(--muted);
    background: #fff;
}
.type-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.type-toggle input:checked + label.for-file   { background: var(--teal);   color: #fff; }
.type-toggle input:checked + label.for-prompt { background: var(--orange); color: #fff; }

/* ---------- Modales ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 48, 55, .5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    z-index: 1000;
    overflow-y: auto;
    animation: fade .15s ease;
}
.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
    width: 100%;
    max-width: 560px;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: #fff;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
    background: transparent; border: none; color: #fff;
    font-size: 24px; line-height: 1; cursor: pointer; opacity: .85;
}
.modal-close:hover { opacity: 1; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--line);
    background: #fafcfc;
}

/* ---------- Toasts ---------- */
.toast-host {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1200;
}
.toast {
    background: var(--ink);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    font-size: 14px;
    max-width: 340px;
    animation: fade .2s ease;
}
.toast.toast-error   { background: var(--danger); }
.toast.toast-success { background: var(--success); }

/* ---------- Pages d'authentification ---------- */
.auth-body {
    background: linear-gradient(160deg, var(--teal) 0%, var(--teal-dark) 60%, var(--teal-darker) 100%);
    min-height: 100vh;
    margin: 0;
}
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 16px;
}
.auth-brand { width: 180px; margin-bottom: 20px; }
.auth-brand img { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
    padding: 26px 28px;
    width: 100%;
    max-width: 400px;
}
.auth-card h2 { margin: 0 0 4px; font-size: 20px; color: var(--teal-darker); }
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.auth-form label { display: block; font-weight: bold; font-size: 13px; margin: 12px 0 5px; }
.auth-form input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cdd8da;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}
.auth-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,159,168,.15); }
.auth-form .btn { margin-top: 20px; }
.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    font-size: 13px;
    flex-wrap: wrap;
}
.auth-links a { color: var(--teal-dark); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-copyright { color: rgba(255,255,255,.85); font-size: 12px; margin-top: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
    }
    .sidebar-brand { flex: 0 0 120px; }
    .sidebar-brand img { max-height: 120px; width: auto; }
    .sidebar-body { flex: 1 1 auto; padding: 12px 16px; }
    .sidebar-tagline { display: none; }
    .sidebar-admin { margin: 0; border: none; padding: 12px 16px; }
    .main { padding: 18px 16px 50px; max-width: none; }
    .tab-btn { padding: 10px 12px; font-size: 14px; }
    .form-row { flex-direction: column; gap: 0; }
}
