/* TagFly - modern SaaS blue/green UI (no dependencies) */

/* =========================
   THEME TOKENS (LIGHT)
   ========================= */
:root{
  --primary:#152E69;
  --primary-dark:#0F2452;
  --secondary:#5BB04E;

  --accent:#1E6FD9;
  --accent-dark:#1557B0;

  --bg:#F6F8FC;
  --card:#FFFFFF;
  --surface-2:#F1F5FF;
  --text:#0F172A;
  --muted:#64748B;
  --border:#E6EAF2;

  --danger:#DC2626;
  --success:#16A34A;
  --warning:#F59E0B;

  --topbar-bg: rgba(246,248,252,0.88);
  --glass: rgba(255,255,255,0.65);
  --glass-strong: rgba(255,255,255,0.92);

  --primary-08: rgba(21,46,105,0.08);
  --primary-10: rgba(21,46,105,0.10);
  --primary-12: rgba(21,46,105,0.12);
  --primary-18: rgba(21,46,105,0.18);
  --primary-25: rgba(21,46,105,0.25);
  --primary-35: rgba(21,46,105,0.35);

  --shadow: 0 10px 30px rgba(2, 8, 23, 0.08);
  --radius: 18px;
  --focus: 0 0 0 4px rgba(30,111,217,0.18);
}

/* =========================
   THEME TOKENS (DARK)
   ========================= */
html[data-theme="dark"]{
  --primary:#3D5CC9;
  --primary-dark:#2F4EB6;
  --secondary:#6FD35F;

  --accent:#60A5FA;
  --accent-dark:#3B82F6;

  --bg:#0B1220;
  --card:#0F1A2E;
  --surface-2:#12213A;
  --text:#E5E7EB;
  --muted:#94A3B8;
  --border:#1E2A44;

  --danger:#F87171;
  --success:#22C55E;
  --warning:#FBBF24;

  --topbar-bg: rgba(11,18,32,0.72);
  --glass: rgba(15,26,46,0.65);
  --glass-strong: rgba(15,26,46,0.92);

  --primary-08: rgba(96,165,250,0.10);
  --primary-10: rgba(96,165,250,0.12);
  --primary-12: rgba(96,165,250,0.14);
  --primary-18: rgba(96,165,250,0.22);
  --primary-25: rgba(96,165,250,0.28);
  --primary-35: rgba(96,165,250,0.38);

  --shadow: 0 12px 34px rgba(0,0,0,0.45);
  --focus: 0 0 0 4px rgba(96,165,250,0.20);
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

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

.container{max-width:1100px;margin:0 auto;padding:24px}

/* Dégradé subtil uniquement en haut (hero zone) */
.page-hero{
  background:
    radial-gradient(1200px 600px at 20% -10%, var(--primary-12), transparent 60%),
    radial-gradient(1000px 500px at 80% 0%, var(--primary-08), transparent 55%);
  padding-bottom: 28px;
}

/* =========================
   TOPBAR
   ========================= */
.topbar{
  position:sticky;top:0;z-index:20;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}
.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 24px;
}

.brand{
  display:inline-flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  letter-spacing:-0.02em;
  font-size:18px;
  color:var(--text);
}
.brand-logo{
  height:40px;
  width:auto;
  display:block;
}

.nav{display:flex;gap:14px}
.nav a{color:var(--muted);font-weight:600}
.nav a:hover{color:var(--text)}

.right{
  display:flex;
  align-items:center;
  gap:10px;
}

/* =========================
   THEME SWITCH
   ========================= */
.theme-toggle{
  display:inline-flex;
  align-items:center;
  gap:10px;
  flex-shrink:0;
  position:relative;
}
.theme-switch{
  position:absolute;
  left:-9999px;
  opacity:0;
  width:1px;height:1px;
}
.theme-switch-label{
  position:relative;
  width:56px;
  height:34px;
  border-radius:999px;
  border:1px solid var(--border);
  background: var(--glass);
  box-shadow: 0 8px 20px rgba(2,8,23,0.06);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
  user-select:none;
}
.theme-switch-label:hover{
  transform: translateY(-1px);
  border-color: var(--primary-35);
}
.theme-switch-icons{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 10px;
  font-size:14px;
  pointer-events:none;
  opacity:.9;
}
.theme-switch-icons .sun{ color: var(--warning); }
.theme-switch-icons .moon{ color: var(--muted); }

.theme-switch-thumb{
  position:absolute;
  top:4px;
  left:4px;
  width:26px;
  height:26px;
  border-radius:999px;
  background: var(--card);
  border:1px solid var(--border);
  box-shadow: 0 10px 18px rgba(2,8,23,0.10);
  transition: left .22s ease, background .2s ease, border-color .2s ease;
}
.theme-switch:checked ~ .theme-switch-label .theme-switch-thumb{
  left:26px;
}
html[data-theme="dark"] .theme-switch-icons .moon{ color: var(--warning); }
html[data-theme="dark"] .theme-switch-icons .sun{ color: var(--muted); }

.theme-switch:focus ~ .theme-switch-label{
  box-shadow: var(--focus);
  border-color: var(--accent);
}

/* =========================
   BUTTONS
   ========================= */
.btn{
  display:inline-flex;align-items:center;justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  background:var(--primary);
  border:1px solid var(--primary-25);
  color:#fff;
  font-weight:700;
  box-shadow: 0 10px 25px var(--primary-18);
  cursor:pointer;
}
.btn:hover{background:var(--primary-dark)}
.btn.ghost{
  background:transparent;
  color:var(--text);
  border:1px solid var(--border);
  box-shadow:none;
}
.btn.ghost:hover{border-color:var(--primary-35);color:var(--primary-dark)}
.btn.small{padding:8px 10px;border-radius:10px;font-size:13px}
.btn.danger{background:var(--danger);border-color:rgba(220,38,38,0.25);box-shadow:none}
html[data-theme="dark"] .btn.danger{ border-color: rgba(248,113,113,0.25); }
.wfull{width:100%}

/* =========================
   CARD / TITLES
   ========================= */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
}
.section{margin-top:28px}
h1{font-size:44px;line-height:1.05;margin:0 0 10px}
h2{font-size:22px;margin:0 0 12px}
h3{font-size:16px;margin:0 0 8px}
.lead{font-size:16px;line-height:1.6;color:var(--muted);max-width:56ch}

.muted{color:var(--muted)}
.small{font-size:12px}
.truncate{max-width:520px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* =========================
   FORMS / AUTH
   ========================= */
.auth{display:flex;justify-content:center;margin-top:28px}
.auth-card{max-width:820px;width:100%;padding:18px}
label{display:block;font-weight:900;margin:12px 0 6px}

.input,
input, select, textarea{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  outline:none;
  background: var(--card);
  color: var(--text);
  font-size:14px;
}
.input:focus,
input:focus, select:focus, textarea:focus{
  border-color: rgba(30,111,217,0.55);
  box-shadow: var(--focus);
}

/* =========================
   TABLE
   ========================= */
.table-card{ padding:10px; background: var(--card); }
.table{width:100%;border-collapse:separate;border-spacing:0}
.table th, .table td{
  padding:12px 10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:top
}
.table th{
  color:var(--muted);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:0.06em
}
.table tbody tr:hover{ background: var(--surface-2); }

/* =========================
   USER MENU
   ========================= */
.user-menu { position: relative; }

.user-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: var(--glass);
  cursor:pointer;
  font-weight:800;
  box-shadow: 0 8px 20px rgba(2,8,23,0.06);
}
.user-btn:hover{
  border-color: var(--primary-35);
  background: var(--glass-strong);
}
.user-avatar{
  width:34px;height:34px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: var(--primary-10);
  border:1px solid var(--primary-18);
  color: var(--primary-dark);
}
.user-caret{ color: var(--muted); font-weight: 900; margin-left: 2px; }

.user-dropdown{
  position:absolute;
  right:0;
  top:calc(100% + 10px);
  width:260px;
  border-radius:16px;
  border:1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  padding:10px;
  display:none;
  z-index:9999;
}
.user-dropdown.open{ display:block; }

.user-head{
  padding:10px;
  border-radius:14px;
  background: rgba(2,6,23,0.04);
  border:1px solid rgba(2,6,23,0.06);
  margin-bottom:8px;
}
html[data-theme="dark"] .user-head{
  background: rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.06);
}

.user-name{ font-weight:950; }
.user-sub{ color: var(--muted); font-size:12px; margin-top:2px; font-weight:800; }

.user-item{
  display:block;
  width:100%;
  text-align:left;
  padding:10px 10px;
  border-radius:12px;
  color: var(--text);
  font-weight:800;
  border:0;
  background:transparent;
  cursor:pointer;
  text-decoration:none;
}
.user-item:hover{
  background: var(--primary-08);
  color: var(--primary-dark);
}
.user-sep{ height:1px; background: var(--border); margin:8px 2px; }
.user-item.danger{ color: var(--danger); }
.user-item.danger:hover{ background: rgba(220,38,38,0.10); }

/* =========================
   STATS STRIP
   ========================= */
.stats-strip{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 18px;
  border-radius:18px;
  background: var(--glass-strong);
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  margin-top:12px;
}
.stats-right{ display:flex; justify-content:flex-end; }
.stats-pill{
  display:inline-flex;
  align-items:center;
  gap:12px;
  padding:14px 18px;
  border-radius:18px;
  background: var(--card);
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  white-space:nowrap;
}
.stats-icon{
  width:34px;height:34px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: var(--primary-10);
  border:1px solid var(--primary-18);
  color: var(--primary-dark);
}
.stats-label{ font-weight:900; }
.stats-value{ font-weight:950; }

/* =========================
   ICON BUTTONS (Edit/Delete)
   ========================= */
.icon-actions{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:flex-end !important;
  gap:10px;
  flex-wrap:nowrap !important;
  white-space:nowrap !important;
}
.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:42px;
  height:36px;
  border-radius:12px;
  border:1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  cursor:pointer;
  box-shadow: 0 8px 20px rgba(2,8,23,0.06);
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
  padding:0;
}
.icon-btn:hover{
  transform: translateY(-1px);
  border-color: var(--primary-35);
  background: var(--glass-strong);
}
.icon-btn svg{ width:18px;height:18px;display:block; }

.icon-btn--danger{
  color: var(--danger);
  border-color: rgba(220,38,38,0.25);
  background: rgba(220,38,38,0.08);
  box-shadow:none;
}
.icon-btn--danger:hover{
  border-color: rgba(220,38,38,0.45);
  background: rgba(220,38,38,0.14);
}
html[data-theme="dark"] .icon-btn{
  background: rgba(15,26,46,0.55);
  border-color: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .icon-btn:hover{
  border-color: rgba(96,165,250,0.35);
  background: rgba(15,26,46,0.85);
}

/* =========================
   RESPONSIVE (clean)
   ========================= */
@media (max-width: 900px){
  h1{font-size:36px}
  .truncate{max-width:260px}
  .topbar-inner{flex-wrap:wrap}
}

/* IMPORTANT: on garde le scroll table, mais on NE FORCE PAS les actions en colonne */
@media (max-width: 768px) {
  .table-card { overflow-x: auto; }
  .table { min-width: 520px; }
  .user-dropdown{ width:220px; }
}

/* iPhone: actions toujours sur une ligne */
@media (max-width: 520px){
  .icon-actions{ gap:6px; }
  .icon-btn{
    width:36px;
    height:32px;
    border-radius:10px;
  }
  .icon-btn svg{ width:16px; height:16px; }

  .table td:last-child{
    min-width: 96px;
    white-space:nowrap;
  }
}
/* =========================
   Icon buttons colors (LIGHT)
   Edit = blue like pagination active
   ========================= */

/* Edit button */
.icon-btn--edit{
  background: var(--primary);
  border-color: var(--primary-25);
  color: #fff;
  box-shadow: 0 10px 25px var(--primary-18);
}

.icon-btn--edit:hover{
  background: var(--primary-dark);
  border-color: var(--primary-35);
}

/* Keep danger as-is (red) */
.icon-btn--danger{
  color: var(--danger);
  border-color: rgba(220,38,38,0.25);
  background: rgba(220,38,38,0.10);
  box-shadow:none;
}
.icon-btn--danger:hover{
  border-color: rgba(220,38,38,0.45);
  background: rgba(220,38,38,0.16);
}

/* Dark theme: edit stays blue but slightly glassy */
html[data-theme="dark"] .icon-btn--edit{
  background: rgba(61,92,201,0.35);
  border-color: rgba(96,165,250,0.35);
  color: #E5E7EB;
}
html[data-theme="dark"] .icon-btn--edit:hover{
  background: rgba(61,92,201,0.55);
  border-color: rgba(96,165,250,0.55);
}
/* Search + Total on same line inside stats strip */
.stats-strip{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

/* Left side: search */
.stats-left{
  flex: 1 1 auto;
  min-width: 0; /* IMPORTANT: évite le débordement iPhone */
}

.search-inline{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
}
/* =========================
   FIX "CARRÉ BLANC" HAMBURGER
   (à mettre TOUT EN BAS du style.css)
   ========================= */

/* Desktop */
.nav-desktop{ display:flex; }
.nav-toggle{ display:none; }
#mobileNav{ display:none !important; }
#mobileNav[hidden]{ display:none !important; }

/* Reset total du bouton (supprime le style natif blanc) */
.nav-toggle{
  all: unset;                 /* ✅ IMPORTANT */
  box-sizing: border-box;
  display:none;               /* desktop caché */
  width:44px;
  height:44px;
  border-radius:12px;
  border:1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  cursor:pointer;
  align-items:center;
  justify-content:center;
  box-shadow: 0 8px 20px rgba(2,8,23,0.06);
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:hover{
  background: var(--glass-strong);
  border-color: var(--primary-35);
}
.nav-toggle:focus{
  outline:none;
  box-shadow: var(--focus);
  border-color: var(--accent);
}

/* Les 3 barres */
.nav-toggle span{
  display:block;
  width:20px;
  height:2px;
  background: currentColor;
  border-radius:2px;
}
.nav-toggle span + span{ margin-top:5px; }

/* Mobile */
@media (max-width: 820px){
  .nav-desktop{ display:none; }
  .nav-toggle{ display:flex; }            /* ✅ visible seulement mobile */
  #mobileNav:not([hidden]){ display:block !important; }
}
/* FIX: carré blanc = checkbox du thème visible */
input.theme-switch{
  position:absolute !important;
  left:-9999px !important;
  top:auto !important;
  width:1px !important;
  height:1px !important;
  opacity:0 !important;
  padding:0 !important;
  margin:0 !important;
  border:0 !important;
  background:transparent !important;
  pointer-events:none !important;
  -webkit-appearance:none !important;
  appearance:none !important;
}
