/* ------------------------------------------------------------------ */
/* FILE: style.css */
/* Place this file in the same folder (style.css) */
/* ------------------------------------------------------------------ */


:root{
--bg:#0f1724; /* deep navy */
--panel:#0b1220;
--muted:#9aa4b2;
--accent:#7dd3fc; /* cyan */
--accent-2:#60a5fa;
--me:#dcf8c6;
--other:#ffffff;
--admin:#ffd166;
--glass: rgba(255,255,255,0.03);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}


*{box-sizing:border-box}
html,body{height:100%;margin:0;background:linear-gradient(180deg,#071021 0%, #0b1220 100%);color:var(--other)}


.chat-app{display:grid;grid-template-columns:260px 1fr;min-height:100vh;gap:20px;padding:24px}
.sidebar{background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));border-radius:14px;padding:18px;box-shadow:0 6px 30px rgba(2,6,23,0.6)}
.brand{font-weight:700;font-size:18px;margin-bottom:12px}
.user-info{display:flex;align-items:center;gap:12px;padding:8px 0}
.avatar{width:44px;height:44px;border-radius:10px;background:linear-gradient(135deg,var(--accent),var(--accent-2));display:flex;align-items:center;justify-content:center;font-weight:700;color:#06202b}
.username{font-weight:600}
.role{font-size:12px;color:var(--muted)}
.actions{margin-top:18px;display:flex;flex-direction:column;gap:8px}
.btn{display:inline-block;padding:8px 12px;border-radius:10px;text-decoration:none;background:var(--accent);color:#022235;font-weight:600;text-align:center}
.btn.ghost{background:transparent;border:1px solid rgba(255,255,255,0.06);color:var(--other)}


.chat-panel{display:flex;flex-direction:column;background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));border-radius:14px;padding:0;box-shadow:0 8px 40px rgba(2,6,23,0.6);overflow:hidden}
.chat-header{padding:18px 20px;border-bottom:1px solid rgba(255,255,255,0.02);display:flex;justify-content:space-between;align-items:center}
.chat-header h1{margin:0;font-size:16px}
.chat-header .meta{color:var(--muted);font-size:13px}


.messages{flex:1;overflow:auto;padding:22px;display:flex;flex-direction:column;gap:10px}
.notice{padding:12px;border-radius:10px;background:var(--glass);color:var(--muted);text-align:center}
.notice.error{background:rgba(255,0,0,0.06);color:#ffb4b4}


.message{max-width:70%;padding:10px 14px;border-radius:12px;line-height:1.3;box-shadow:0 4px 18px rgba(2,6,23,0.6)}
.message .meta{font-weight:700;font-size:13px;margin-bottom:6px}
.message .time{display:block;font-size:11px;color:var(--muted);margin-top:6px}


.msg-me{margin-left:auto;background:linear-gradient(180deg,var(--me),#e6f7d8);color:#05220b;border-bottom-right-radius:4px}
.msg-other{margin-right:auto;background:rgba(255,255,255,0.04)}
.msg-admin{background:linear-gradient(90deg,var(--admin),#ffc28a);color:#1b1200}


.composer{display:flex;gap:12px;padding:14px;border-top:1px solid rgba(255,255,255,0.02);align-items:flex-end}
.composer textarea{flex:1;resize:none;border-radius:10px;padding:10px 12px;border:1px solid rgba(255,255,255,0.04);background:transparent;color:var(--other);min-height:44px;max-height:140px;outline:none}
.composer button{padding:10px 14px;border-radius:10px;border:none;background:var(--accent);color:#022235;font-weight:700;cursor:pointer}


/* message row layout */
.row{display:flex;gap:10px;align-items:flex-end}
.row .avatar{width:36px;height:36px;border-radius:8px}
.row .bubble{display:flex;flex-direction:column}


/* responsive */
@media (max-width:900px){.chat-app{grid-template-columns:1fr;padding:12px}.sidebar{display:none}.message{max-width:86%}}

.delete-btn {
  background: transparent;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  margin-left: 6px;
  font-size: 14px;
}
.delete-btn:hover { color: #ff0000; }

.message { position: relative; }
.delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 14px;
}
.delete-btn:hover { color: #ff0000; }

.admin-table button {
    background: #ff6b6b;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    position: static; /* <- important pour qu'il reste dans la cellule */
}
.admin-table button:hover {
    background: #ff0000;
}

.btn-return {
    display: inline-block;
    margin: 10px 0 20px 0;
    padding: 6px 12px;
    background: #60a5fa;
    color: #022235;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-return:hover {
    background: #3b82f6;
}
.chat-container {
    width: auto;
    min-height: 200px;        /* hauteur minimale si peu de messages */
    max-height: 800px;        /* hauteur max avant scroll */
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    background: rgba(11,18,32,0.8);
    overflow: hidden;         /* empêche la page de scroller */
}


.chat-messages {
    flex: 1 1 auto;           /* prend l’espace disponible et peut se réduire */
    overflow-y: auto;         /* scroll uniquement si beaucoup de messages */
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0,0,0,0.05);
}

.chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(11,18,32,0.9);
}

.chat-form textarea {
    flex: 1;
    resize: none;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.chat-form button {
    padding: 8px 12px;
    border-radius: 8px;
    background: #60a5fa;
    border: none;
    color: #022235;
    font-weight: 600;
    cursor: pointer;
}
/* === Login === */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #0b1220, #1a1f2e);
}

.login-box {
    background: rgba(11,18,32,0.8);
    padding: 30px 40px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    width: 320px;
}

.login-box h1 {
    margin: 0 0 20px 0;
    font-size: 1.8rem;
    text-align: center;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-box input {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.login-box input:focus {
    border-color: #60a5fa;
}

.login-box button {
    padding: 8px 14px;
    border-radius: 8px;
    background: #60a5fa;
    color: #022235;
    font-weight: 600;
    cursor: pointer;
}

.login-box button:hover {
    filter: brightness(1.1);
}

/* Message d'erreur spécifique login */
.login-box .notice {
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255,50,50,0.2);
    color: #ff6b6b;
    font-weight: 500;
}

/* === Logout === */
.logout-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #0b1220, #1a1f2e);
}

.logout-box {
    background: rgba(11,18,32,0.8);
    padding: 30px 40px;
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.logout-box h1 {
    margin-bottom: 20px;
    font-size: 1.6rem;
}

.logout-box .btn-return {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 12px;
    background: #60a5fa;
    color: #022235;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.logout-box .btn-return:hover {
    background: #3b82f6;
}

/* === Admin === */
.admin-container {
    padding: 20px;
}

.admin-container h1 {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table th, .admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    text-align: left;
}

.admin-table th {
    background: rgba(255,255,255,0.02);
}

.admin-table button {
    background: #ff6b6b;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.admin-table button:hover {
    background: #ff0000;
}

.admin-container .btn-return {
    display: inline-block;
    margin: 10px 0 20px 0;
    padding: 6px 12px;
    background: #60a5fa;
    color: #022235;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.admin-container .btn-return:hover {
    background: #3b82f6;
}

/* Scrollbar pour Webkit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 10px; /* largeur de la scrollbar verticale */
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05); /* fond derrière le scroll */
    border-radius: 8px;
}

::-webkit-scrollbar-thumb {
    background: rgba(96,165,250,0.6); /* couleur du “thumb” */
    border-radius: 8px;
    border: 2px solid rgba(11,18,32,0.8); /* contour pour se fondre dans le chat */
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(96,165,250,0.9);
}

/* Scrollbar pour Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(96,165,250,0.6) rgba(255,255,255,0.05);
}

.code-block {
    background: rgba(0,0,0,0.3);
    border-left: 4px solid #60a5fa;
    padding: 10px;
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
    color: #dbeafe;
    white-space: pre-wrap; /* gère le retour à la ligne */
    overflow-x: auto;
    margin-bottom: 8px;
}

.code-block pre {
    margin: 0;
    font-size: 0.9rem;
}
