/* ============================================================
   Accès Machines — feuille de style principale
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --color-navy:        #15233D;
  --color-navy-light:  #1F3258;
  --color-accent:      #6366F1;
  --color-accent-dark: #4f46e5;
  --color-on-accent:   #ffffff;
  --color-on-navy:     #ffffff;
  --color-bg:          #F4F5F7;
  --color-card:        #FFFFFF;
  --color-text:        #1F2937;
  --color-heading:     #15233D;
  --color-muted:       #6B7280;
  --color-border:      #E2E4E9;
  --color-error:       #B3261E;
  --color-error-bg:    #FBEAE9;
  --color-success:     #1E7B34;
  --color-success-bg:  #EAF6EC;
  --color-warn:        #B45309;
  --color-warn-bg:     #FEF3C7;
  --radius:            8px;
  --font-heading:      'Space Grotesk', sans-serif;
  --font-body:         'Inter', sans-serif;
  --topbar-h:          56px;
}

/* ── Palettes ────────────────────────────────────────────── */
[data-palette="marine"] {
  --color-navy: #15233D; --color-navy-light: #1F3258;
  --color-accent: #1F6FEB; --color-accent-dark: #1558c7;
}
[data-palette="emeraude"] {
  --color-navy: #064E3B; --color-navy-light: #065F46;
  --color-accent: #059669; --color-accent-dark: #047857;
}
[data-palette="bordeaux"] {
  --color-navy: #4C0519; --color-navy-light: #881337;
  --color-accent: #E11D48; --color-accent-dark: #be123c;
}
[data-palette="ardoise"] {
  --color-navy: #1E293B; --color-navy-light: #334155;
  --color-accent: #6366F1; --color-accent-dark: #4f46e5;
}
[data-palette="aubergine"] {
  --color-navy: #3B0764; --color-navy-light: #581C87;
  --color-accent: #9333EA; --color-accent-dark: #7e22ce;
}

/* ── Mode sombre ─────────────────────────────────────────── */
[data-theme="sombre"] {
  --color-bg:      #0F1117;
  --color-card:    #1A1D27;
  --color-text:    #E4E6EF;
  --color-heading: #F3F4F6;
  --color-muted:   #9CA3AF;
  --color-border:  #2D3148;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-heading);
  margin-top: 0;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--color-navy);
  color: var(--color-on-navy);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-title {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 1.1rem; color: var(--color-on-navy);
  text-decoration: none;
  display: flex; align-items: center; gap: .5rem;
  white-space: nowrap; flex-shrink: 0;
}
.topbar-title:hover { text-decoration: none; }
.topbar-title svg { width: 22px; height: 22px; }
.topbar-icones {
  display: flex; align-items: center; gap: .25rem; margin-left: auto;
}
.topbar-icone {
  position: relative; display: flex; align-items: center;
  justify-content: center; width: 38px; height: 38px;
  border-radius: 50%; color: rgba(255,255,255,.8);
  text-decoration: none; transition: background .15s, color .15s;
}
.topbar-icone:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar-icone svg { width: 20px; height: 20px; }

/* Menu profil */
.profil-menu { position: relative; flex-shrink: 0; }
.profil-trigger {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: none; color: var(--color-on-navy);
  cursor: pointer; padding: .35rem .6rem;
  border-radius: var(--radius); font-family: var(--font-body);
  font-size: .9rem; transition: background .15s;
}
.profil-trigger:hover { background: rgba(255,255,255,.1); }
.profil-avatar {
  width: 30px; height: 30px;
  background: var(--color-accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
}
.profil-nom { font-weight: 500; }
.profil-chevron { width: 14px; height: 14px; opacity: .7; }
.profil-dropdown {
  position: absolute; right: 0; top: calc(100% + .4rem);
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.15);
  min-width: 200px; padding: .4rem 0; z-index: 200;
}
.profil-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; color: var(--color-text);
  font-size: .9rem; text-decoration: none;
  transition: background .12s; background: none; border: none;
  width: 100%; cursor: pointer; font-family: var(--font-body);
}
.profil-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.profil-item:hover { background: var(--color-bg); text-decoration: none; }
.profil-item--danger { color: var(--color-error); }
.profil-item--danger:hover { background: var(--color-error-bg); }
.profil-separator { border-top: 1px solid var(--color-border); margin: .3rem 0; }

/* ── Layout principal ────────────────────────────────────── */
.page-wrapper {
  max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem;
}
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.4rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.25rem;
}
.card-title {
  font-family: var(--font-heading); font-size: 1rem;
  font-weight: 700; color: var(--color-heading);
  margin: 0 0 1rem 0; display: flex; align-items: center; gap: .5rem;
}

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  font-family: var(--font-body); font-size: .9rem;
  font-weight: 500; cursor: pointer; border: none;
  text-decoration: none; transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary   { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); text-decoration: none; }
.btn-danger    { background: var(--color-error); color: #fff; }
.btn-danger:hover { opacity: .85; text-decoration: none; color: #fff; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }

/* ── Formulaires ─────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-weight: 600; font-size: .85rem;
  margin-bottom: .3rem; color: var(--color-heading);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: .55rem .75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-family: var(--font-body); font-size: .95rem;
  background: var(--color-card); color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: .8rem; color: var(--color-muted); margin-top: .25rem; }

/* ── Messages flash ──────────────────────────────────────── */
.msg {
  padding: .75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .9rem;
  display: flex; align-items: flex-start; gap: .5rem;
}
.msg-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #b7f0c3; }
.msg-error   { background: var(--color-error-bg);   color: var(--color-error);   border: 1px solid #f5c0bc; }
.msg-warn    { background: var(--color-warn-bg);    color: var(--color-warn);    border: 1px solid #fcd34d; }

/* ── Tableaux ────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--color-muted); padding: .6rem .75rem;
  border-bottom: 2px solid var(--color-border); white-space: nowrap;
}
tbody td {
  padding: .65rem .75rem; border-bottom: 1px solid var(--color-border);
  vertical-align: middle; font-size: .9rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--color-bg); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .15rem .55rem; border-radius: 20px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-orange { background: #FEF3C7; color: #92400E; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-gray   { background: var(--color-bg); color: var(--color-muted); border: 1px solid var(--color-border); }

/* ── Page auth ───────────────────────────────────────────── */
.page-auth {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--color-navy) 0%, var(--color-navy-light) 45%, var(--color-bg) 45%);
}
.auth-outer {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 380px;
}
.auth-logo-wrap {
  width: 80px; height: 80px;
  background: var(--color-card); border-radius: 16px;
  box-shadow: 0 4px 20px rgba(21,35,61,.22);
  overflow: hidden; margin-bottom: -1.5rem;
  position: relative; z-index: 1; flex-shrink: 0;
}
.auth-logo { width: 100%; height: 100%; object-fit: contain; display: block; }
.auth-card {
  background: var(--color-card); padding: 2.5rem;
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(21,35,61,.18);
  width: 100%; max-width: 380px;
}
.auth-card h1 { font-size: 1.4rem; }
.auth-subtitle { color: var(--color-muted); margin-top: -.5rem; margin-bottom: 1.5rem; font-size: .9rem; }
.auth-card label { display: block; font-weight: 600; font-size: .85rem; margin-top: 1rem; margin-bottom: .3rem; }
.auth-card input {
  width: 100%; padding: .6rem .75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-family: var(--font-body); font-size: .95rem;
  background: var(--color-card); color: var(--color-text);
}
.auth-card input:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.auth-card button[type=submit] {
  width: 100%; margin-top: 1.5rem; padding: .65rem;
  background: var(--color-accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 1rem;
  font-weight: 600; cursor: pointer; transition: background .15s;
}
.auth-card button[type=submit]:hover { background: var(--color-accent-dark); }
.otp-input { text-align: center; font-size: 1.6rem !important; letter-spacing: .3em; }
.mfa-hint {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: .5rem .75rem;
  font-family: monospace; font-size: .9rem; word-break: break-all;
  color: var(--color-text); margin-top: .5rem;
}
.mw-440 { max-width: 440px !important; }
.qr-code { border-radius: var(--radius); border: 4px solid var(--color-border); }

/* ── Grille de machines ──────────────────────────────────── */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.machine-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1rem;
  display: flex; flex-direction: column;
  gap: .75rem;
  transition: box-shadow .2s, transform .15s;
  position: relative;
  overflow: hidden;
}
.machine-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  transform: translateY(-2px);
}
.machine-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--machine-color, var(--color-accent));
}
.machine-header {
  display: flex; align-items: center; gap: 1rem;
}
.machine-logo {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--machine-color, var(--color-accent));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.machine-logo img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.machine-logo svg { width: 28px; height: 28px; color: #fff; }
.machine-info { flex: 1; min-width: 0; }
.machine-name {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 1rem; color: var(--color-heading);
  margin: 0 0 .15rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.machine-ip {
  font-family: monospace; font-size: .85rem;
  color: var(--color-muted); display: flex; align-items: center; gap: .3rem;
}
.machine-ip svg { width: 13px; height: 13px; }
.machine-desc {
  font-size: .85rem; color: var(--color-muted);
  line-height: 1.4; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.machine-footer {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-top: auto; padding-top: .25rem;
  border-top: 1px solid var(--color-border);
}

/* ── Boutons d'accès ─────────────────────────────────────── */
.btn-access {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .38rem .8rem; border-radius: 6px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: opacity .15s, transform .1s;
  flex: 1; justify-content: center; min-width: 90px;
}
.btn-access:hover { opacity: .85; transform: scale(1.03); text-decoration: none; }
.btn-access svg { width: 14px; height: 14px; }
.btn-cockpit { background: #0EA5E9; color: #fff; }
.btn-mstsc   { background: #0078D4; color: #fff; }
.btn-ssh     { background: #1E7B34; color: #fff; }
.btn-web     { background: #6366F1; color: #fff; }
.btn-vnc     { background: #9333EA; color: #fff; }
.btn-wol     { background: #D97706; color: #fff; }
.btn-wol.wol-sending { opacity: .6; pointer-events: none; }
.btn-wol.wol-ok      { background: #1E7B34; }
.btn-wol.wol-err     { background: #B3261E; }

/* ── Modal SSH ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--color-card); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 1.5rem; max-width: 480px; width: 100%;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--color-muted); padding: .25rem;
  border-radius: 4px; transition: background .15s;
}
.modal-close:hover { background: var(--color-bg); }
.modal-close svg { width: 20px; height: 20px; display: block; }
.cmd-block {
  background: #1E293B; color: #e2e8f0;
  border-radius: var(--radius); padding: .75rem 1rem;
  font-family: monospace; font-size: .9rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin: .75rem 0;
}
.cmd-text { flex: 1; word-break: break-all; }
.cmd-copy {
  background: rgba(255,255,255,.1); border: none; cursor: pointer;
  color: #94A3B8; border-radius: 4px; padding: .25rem .5rem;
  font-size: .78rem; white-space: nowrap; transition: background .15s;
  display: flex; align-items: center; gap: .25rem;
}
.cmd-copy:hover { background: rgba(255,255,255,.2); color: #fff; }
.cmd-copy svg { width: 13px; height: 13px; }
.cmd-copied { color: #4ADE80; }

/* ── Admin — formulaire machine ──────────────────────────── */
.acces-list { display: flex; flex-direction: column; gap: .75rem; }
.acces-row {
  display: flex; gap: .75rem; align-items: flex-end;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: .75rem;
}
.acces-row .form-group { margin: 0; }
.acces-row .fg-type  { width: 130px; flex-shrink: 0; }
.acces-row .fg-port  { width: 90px;  flex-shrink: 0; }
.acces-row .fg-user  { flex: 1; }
.acces-row .fg-url   { flex: 2; }
.acces-row-del {
  background: none; border: none; cursor: pointer;
  color: var(--color-error); padding: .35rem;
  border-radius: 4px; transition: background .15s; flex-shrink: 0;
  align-self: flex-end; margin-bottom: .3rem;
}
.acces-row-del:hover { background: var(--color-error-bg); }
.acces-row-del svg { width: 16px; height: 16px; display: block; }

/* ── Filtres / recherche ─────────────────────────────────── */
.search-bar {
  display: flex; gap: .75rem; align-items: center;
  flex-wrap: wrap; margin-bottom: 1.25rem;
}
.search-input {
  flex: 1; min-width: 200px;
  padding: .5rem .75rem; border: 1px solid var(--color-border);
  border-radius: var(--radius); font-family: var(--font-body);
  font-size: .9rem; background: var(--color-card); color: var(--color-text);
}
.search-input:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }

/* ── Logo upload preview ─────────────────────────────────── */
.logo-preview-wrap {
  display: flex; align-items: center; gap: 1rem; margin-top: .5rem;
}
.logo-preview {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--color-bg); border: 2px solid var(--color-border);
  object-fit: cover; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ── Utilitaires ─────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--color-muted); }
.text-accent { color: var(--color-accent); }
.fs-sm  { font-size: .875rem; }
.fs-xs  { font-size: .78rem; }
.mt-05  { margin-top: .5rem; }
.mt-125 { margin-top: 1.25rem; }
.mb-125 { margin-bottom: 1.25rem; }
.mb-2   { margin-bottom: 2rem; }
.cursor-pointer { cursor: pointer; }
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .machines-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .acces-row { flex-direction: column; }
  .acces-row .fg-type, .acces-row .fg-port { width: 100%; }
}
