/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --navy: #1e3a5f;
  --navy-dark: #152a45;
  --navy-light: #2a4f7c;
  --gold: #f59e0b;
  --gold-light: #fde68a;
  --sidebar-w: 260px;
  --radius-lg: 20px;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: #f0f4f8;
  color: #1f2937;
  min-height: 100vh;
}

/* ─── Couleurs utilitaires ────────────────────────────────────────────────── */
.text-navy   { color: var(--navy) !important; }
.text-gold   { color: var(--gold) !important; }
.bg-navy     { background-color: var(--navy) !important; }
.bg-gold     { background-color: var(--gold) !important; }
.text-blue-300 { color: #93c5fd; }

.btn-navy {
  background-color: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-navy:hover, .btn-navy:focus { background-color: var(--navy-dark); border-color: var(--navy-dark); color: #fff; }
.btn-outline-navy { border-color: var(--navy); color: var(--navy); }
.btn-outline-navy:hover { background: var(--navy); color: #fff; }

/* ─── Login / erreur pages ────────────────────────────────────────────────── */
.login-page, .error-page {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}
.login-card { border-radius: var(--radius-lg) !important; }
.login-icon {
  width: 84px; height: 84px; border-radius: 22px;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
}

/* ══════════════════════════════════════════════════════════════════════════
   PORTAIL PUBLIC
   ══════════════════════════════════════════════════════════════════════════ */

.portal-layout { display: flex; flex-direction: column; min-height: 100vh; }

.portal-header {
  background: var(--navy);
  box-shadow: 0 2px 16px rgba(30,58,95,.35);
  z-index: 1030;
}
.portal-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 60px; max-width: 1400px; margin: 0 auto;
}
.portal-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.portal-brand-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(245,158,11,.18);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 1.15rem; flex-shrink: 0;
}
.portal-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.portal-brand-name { font-weight: 800; font-size: 1.02rem; color: #fff; }
.portal-brand-org { font-size: .72rem; color: #93c5fd; font-weight: 500; }

.portal-admin-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(245,158,11,.18); border: 1px solid rgba(245,158,11,.35);
  border-radius: 999px; padding: 7px 13px; color: var(--gold-light);
  text-decoration: none; font-size: .83rem; font-weight: 700;
}
.portal-admin-pill:hover { background: rgba(245,158,11,.28); color: #fff; }

.portal-user-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08); border: none; border-radius: 999px;
  padding: 5px 12px 5px 5px; color: #fff;
}
.portal-user-btn:hover { background: rgba(255,255,255,.16); }
.portal-user-btn::after { display: none; }
.avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold); color: var(--navy-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.portal-user-name { font-size: .87rem; font-weight: 600; }
.portal-user-caret { font-size: .65rem; opacity: .7; }

.portal-flashes { max-width: 900px; margin: 14px auto 0; padding: 0 16px; }

.portal-main { flex: 1; }

/* ─── Hero + recherche ───────────────────────────────────────────────────── */
.portal-hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 38px 16px 64px;
}
.portal-hero-inner { max-width: 760px; margin: 0 auto; text-align: center; }
.portal-hero-title { color: #fff; font-weight: 800; font-size: clamp(1.35rem, 3vw, 1.9rem); margin-bottom: 6px; }
.portal-hero-sub { color: #cbd8e8; margin-bottom: 26px; font-size: .98rem; }

.portal-search {
  position: relative; display: flex; align-items: center;
  background: #fff; border-radius: 16px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
  padding: 4px 6px; max-width: 520px; margin: 0 auto;
}
.portal-search i.fa-magnifying-glass { color: #9ca3af; padding: 0 12px; font-size: .95rem; }
.portal-search input {
  flex: 1; border: none; outline: none; padding: 12px 4px; font-size: .95rem; background: transparent;
}
.portal-search-clear {
  border: none; background: #f1f5f9; color: #6b7280; border-radius: 50%;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  margin-right: 4px; flex-shrink: 0;
}
.portal-search-clear:hover { background: #e2e8f0; }

/* ─── Filtres par catégorie ──────────────────────────────────────────────── */
.portal-body { max-width: 1300px; margin: -34px auto 0; padding: 0 16px 60px; }

.portal-filters {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 18px;
  scrollbar-width: none;
}
.portal-filters::-webkit-scrollbar { display: none; }
.filter-pill {
  flex-shrink: 0; border: 1px solid #e2e8f0; background: #fff; color: #475569;
  border-radius: 999px; padding: 8px 16px; font-size: .85rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px; transition: all .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.filter-pill:hover { border-color: var(--navy-light); color: var(--navy); }
.filter-pill.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ─── Grille d'applications ──────────────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 16px;
}
@media (min-width: 768px) {
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 20px; }
}

.app-tile {
  background: #fff; border-radius: 18px; padding: 22px 16px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  text-decoration: none; color: inherit; gap: 10px;
  box-shadow: 0 2px 10px rgba(15,23,42,.06);
  border: 1px solid #eef1f5;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  position: relative;
}
.app-tile:hover, .app-tile:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(15,23,42,.14);
  border-color: rgba(30,58,95,.15);
  color: inherit;
}
.app-tile:active { transform: translateY(-1px); }

.app-tile-logo {
  width: 60px; height: 60px; border-radius: 16px;
  background: color-mix(in srgb, var(--tile-color, var(--navy)) 12%, white);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.55rem; color: var(--tile-color, var(--navy));
  overflow: hidden; flex-shrink: 0;
}
.app-tile-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }

.app-tile-name { font-weight: 700; font-size: .93rem; color: #1e293b; line-height: 1.25; }
.app-tile-desc { font-size: .78rem; color: #94a3b8; line-height: 1.3; }
.app-tile-tag {
  position: absolute; top: 10px; right: 10px;
  background: #f1f5f9; color: #64748b; font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 999px;
}

.portal-footer { background: #fff; border-top: 1px solid #e5e7eb; }

/* ══════════════════════════════════════════════════════════════════════════
   ADMINISTRATION
   ══════════════════════════════════════════════════════════════════════════ */

.admin-layout { display: flex; min-height: 100vh; background: #f0f4f8; }

.admin-sidebar {
  width: var(--sidebar-w); background: var(--navy); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040;
  transform: translateX(-100%); transition: transform .22s ease;
}
.admin-sidebar.open { transform: translateX(0); }
@media (min-width: 992px) {
  .admin-sidebar { position: sticky; transform: none; }
}

.admin-sidebar-brand {
  padding: 22px 20px; font-weight: 800; font-size: 1.05rem;
  display: flex; align-items: center; gap: 10px; color: #fff;
}
.admin-sidebar-brand i { color: var(--gold); }

.admin-sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav-link {
  display: flex; align-items: center; gap: 12px; color: #cbd8e8;
  text-decoration: none; padding: 11px 14px; border-radius: 10px; font-weight: 600; font-size: .9rem;
}
.admin-nav-link i { width: 18px; text-align: center; }
.admin-nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-nav-link.active { background: var(--gold); color: var(--navy-dark); }
.admin-sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }

.admin-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035;
}
.admin-backdrop.show { display: block; }
@media (min-width: 992px) { .admin-backdrop { display: none !important; } }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-bottom: 1px solid #e5e7eb;
  padding: 0 20px; height: 60px; position: sticky; top: 0; z-index: 1020;
}
.admin-menu-btn {
  border: none; background: none; font-size: 1.2rem; color: var(--navy); padding: 6px;
}
@media (min-width: 992px) { .admin-menu-btn { display: none; } }
.admin-topbar-title { font-weight: 700; color: var(--navy); font-size: 1rem; }

.admin-content { padding: 20px; max-width: 1200px; width: 100%; margin: 0 auto; }
.admin-content .alert { border-radius: 12px; }

.admin-apps-table th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8;
  border-bottom-width: 1px; padding: 14px 12px;
}
.admin-apps-table td { padding: 10px 12px; vertical-align: middle; }
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; background: #f0f4f8; }

.app-thumb {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: color-mix(in srgb, var(--tile-color, var(--navy)) 12%, white);
  display: flex; align-items: center; justify-content: center;
  color: var(--tile-color, var(--navy)); font-size: 1.1rem; overflow: hidden;
}
.app-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }

.app-logo-preview {
  width: 96px; height: 96px; border-radius: 20px; margin: 0 auto;
  background: color-mix(in srgb, var(--tile-color, var(--navy)) 12%, white);
  display: flex; align-items: center; justify-content: center;
  color: var(--tile-color, var(--navy)); font-size: 2.2rem; overflow: hidden;
}
.app-logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }

.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--navy-light); box-shadow: 0 0 0 .2rem rgba(30,58,95,.15);
}
.form-check-input:checked { background-color: var(--navy); border-color: var(--navy); }

/* ─── Petits écrans ───────────────────────────────────────────────────────── */
@media (max-width: 575px) {
  .portal-hero { padding: 28px 14px 54px; }
  .app-tile { padding: 18px 10px; border-radius: 16px; }
  .app-tile-logo { width: 52px; height: 52px; font-size: 1.3rem; }
}
