/* ============================================================
   tech-soft.ch Portail — Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:   #3a7de0;
  --accent2:  #2563c7;
  --bg:       #f5f6fa;
  --bg2:      #eef0f5;
  --bg3:      #ffffff;
  --text:     #1a1d23;
  --text2:    #6b7280;
  --text3:    #9ca3af;
  --border:   #e5e7eb;
  --border2:  #d1d5db;
  --ok:       #16a34a;
  --ok-bg:    #f0fdf4;
  --warn:     #d97706;
  --warn-bg:  #fffbeb;
  --danger:   #dc2626;
  --danger-bg:#fef2f2;
  --radius:   10px;
  --radius-sm:6px;
  --shadow:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:0 4px 12px rgba(0,0,0,.10);
}

/* ---- THEME : DARK (doit etre apres :root) ---- */
[data-theme="dark"] {
  --accent:#4f8ef7; --accent2:#6aa0ff;
  --bg:#0f1117; --bg2:#1a1d27; --bg3:#252836;
  --text:#e8eaf0; --text2:#9199b0; --text3:#5a6280;
  --border:#2e3348; --border2:#3a3f55;
  --ok:#2ecc71; --ok-bg:rgba(46,204,113,.12);
  --warn:#f39c12; --warn-bg:rgba(243,156,18,.12);
  --danger:#e74c3c; --danger-bg:rgba(231,76,60,.12);
  --shadow:0 4px 24px rgba(0,0,0,.4); --shadow-md:0 6px 24px rgba(0,0,0,.5);
}

/* ---- TAILLE BOUTON THEME ---- */
.theme-toggle-btn { font-size:1.1rem !important; }

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 15px; color: var(--text); background: var(--bg); }
#app { min-height: 100vh; }

/* ---- NAVBAR ---- */
.navbar {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.nav-brand .accent { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--text2); }
.nav-user { display: flex; align-items: center; gap: 8px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; flex-shrink: 0; }

/* ---- PAGE ---- */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: .85rem; color: var(--text2); margin-bottom: 28px; }
.section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); margin-bottom: 14px; }

/* ---- LOGIN ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.login-logo .brand .accent { color: var(--accent); }
.login-logo .sub { font-size: .82rem; color: var(--text2); margin-top: 4px; }

/* ---- APPS GRID ---- */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 36px; }
.app-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  text-decoration: none;
}
.app-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,125,224,.1); }
.app-card.locked { opacity: .5; cursor: default; }
.app-card.locked:hover { border-color: var(--border); box-shadow: none; }
.app-icon-wrap { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.app-icon-wrap.blue   { background: #dbeafe; color: #1d4ed8; }
.app-icon-wrap.teal   { background: #ccfbf1; color: #0f766e; }
.app-icon-wrap.amber  { background: #fef3c7; color: #92400e; }
.app-icon-wrap.coral  { background: #fee2e2; color: #991b1b; }
.app-icon-wrap.purple { background: #ede9fe; color: #6d28d9; }
.app-icon-wrap.green  { background: #dcfce7; color: #15803d; }
.app-icon-wrap.gray   { background: var(--bg2); color: var(--text2); }
.app-name { font-size: .87rem; font-weight: 600; text-align: center; color: var(--text); line-height: 1.3; }
.app-desc { font-size: .75rem; color: var(--text2); text-align: center; line-height: 1.4; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 600; border-radius: 20px; padding: 2px 9px; }
.badge.active  { background: var(--ok-bg);     color: var(--ok); }
.badge.locked  { background: var(--bg2);        color: var(--text3); }
.badge.admin   { background: #ede9fe;           color: #6d28d9; }
.badge.warn    { background: var(--warn-bg);    color: var(--warn); }
.badge.danger  { background: var(--danger-bg);  color: var(--danger); }

/* ---- ADMIN TABS ---- */
.tab-bar { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: .88rem; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; transition: color .15s; border-radius: 0; display: flex; align-items: center; gap: 6px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- TABLE ---- */
.table-wrap { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { background: var(--bg2); color: var(--text2); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.td-act { display: flex; gap: 5px; }

/* ---- CARDS ---- */
.card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 28px; }
.stat-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-val { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: .75rem; color: var(--text2); margin-top: 2px; }

/* ---- FORMS ---- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
label { font-size: .8rem; font-weight: 600; color: var(--text2); }
.inp { width: 100%; padding: 8px 11px; border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: .88rem; color: var(--text); background: var(--bg3); transition: border-color .15s; outline: none; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,125,224,.12); }
select.inp { cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500; cursor: pointer; background: var(--bg3); color: var(--text); transition: all .15s; text-decoration: none; }
.btn:hover { background: var(--bg2); border-color: var(--border2); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-success { background: var(--ok-bg); color: var(--ok); border-color: #86efac; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-icon { padding: 5px 8px; }
.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--bg2); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--bg3); border-radius: var(--radius); padding: 28px 28px 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }

/* ---- TOAST ---- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 11px 18px; border-radius: var(--radius-sm); font-size: .85rem; opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none; z-index: 300; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.warn  { background: var(--warn); }
.toast.ok    { background: var(--ok); }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 10px; opacity: .4; }
.empty-state p { font-size: .88rem; }

/* ---- HEADER ACTIONS ---- */
.header-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.header-row .left .title { font-size: 1.2rem; font-weight: 700; }
.header-row .left .sub { font-size: .82rem; color: var(--text2); margin-top: 3px; }

/* ---- USER INITIALS ---- */
.initials { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.initials.blue   { background: #dbeafe; color: #1d4ed8; }
.initials.client { background: #ede9fe; color: #6d28d9; }
.initials.admin  { background: #fef3c7; color: #92400e; }

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .page { padding: 20px 14px; }
  .apps-grid { grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .modal-box { padding: 20px; }
}
