/* ============================================================
   HSBC Admin Panel – Styles (Dark Theme)
   ============================================================ */

:root {
  --a-red:    #DB0011;
  --a-red-d:  #a80009;
  --a-red-l:  #f9e0e2;
  --a-dark:   #0d0d0d;
  --a-bg:     #111318;
  --a-surface:#1a1d24;
  --a-border: #2a2d36;
  --a-text:   #e2e8f0;
  --a-muted:  #8b949e;
  --a-blue:   #3b82f6;
  --a-green:  #10b981;
  --a-orange: #f59e0b;
  --a-purple: #8b5cf6;
  --a-sidebar-w: 240px;
  --a-topbar-h: 60px;
  --a-radius: 10px;
  --a-shadow: 0 2px 8px rgba(0,0,0,.4);
  --a-font: 'Inter', -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--a-font); background: var(--a-bg); color: var(--a-text); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; cursor: pointer; }
button { cursor: pointer; border: none; background: none; font-family: var(--a-font); color: inherit; }
input, select, textarea { font-family: var(--a-font); color: var(--a-text); }
[hidden] { display: none !important; }

/* ---- Logo ---- */
.a-hex-grid { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 28px; height: 28px; flex-shrink: 0; }
.a-hex-grid.small { width: 22px; height: 22px; gap: 1.5px; }
.ahx { background: var(--a-red); clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); }
.ahx.tr, .ahx.bl { opacity: .55; }
.a-wordmark { font-size: 1.2rem; font-weight: 800; color: var(--a-red); letter-spacing: -.3px; }
.a-wordmark.sm { font-size: 1rem; }
.a-wordmark-sub { font-size: .65rem; color: var(--a-muted); margin-top: -2px; text-transform: uppercase; letter-spacing: .5px; }

/* ============================================================
   LOGIN SCREEN – vollflächig, deckt alles ab
   ============================================================ */

/* Login-Screen: füllt den ganzen Viewport, liegt über allem */
.a-login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #060608 0%, #100005 40%, #0a0010 70%, #080808 100%);
  overflow-y: auto;
  /* Isolation sichert z-index auch in Safari/Firefox */
  isolation: isolate;
}
.a-login-screen[hidden] { display: none !important; }

body.admin-login-page {
  min-height: 100vh;
  background: #060608;
  /* overflow:hidden NICHT setzen – kann z-index-Stapelung in Firefox/Safari brechen */
  overflow: auto;
}

.a-login-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.a-bg-shape { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(219,0,17,.15) 0%, transparent 70%); animation: aBgPulse 10s ease-in-out infinite alternate; }
.a-bg-shape.s1 { width: 500px; height: 500px; top: -100px; left: -100px; }
.a-bg-shape.s2 { width: 350px; height: 350px; bottom: -60px; right: -60px; animation-delay: -4s; }
@keyframes aBgPulse { from{opacity:.2;} to{opacity:.5;} }

.a-login-wrap { position: relative; z-index: 1; width: 100%; max-width: 440px; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.a-login-logo { display: flex; align-items: center; gap: 12px; }
.a-login-card { width: 100%; background: var(--a-surface); border: 1px solid var(--a-border); border-radius: 16px; padding: 32px 28px; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.a-login-card h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.a-login-sub { font-size: .82rem; color: var(--a-muted); margin-bottom: 24px; }

/* Alerts */
.a-alert { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: .82rem; margin-bottom: 14px; }
.a-alert-error { background: rgba(219,0,17,.1); color: #ff6b7a; border: 1px solid rgba(219,0,17,.3); }
.a-alert-success { background: rgba(16,185,129,.1); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }

/* Fields */
.a-field-group { margin-bottom: 14px; }
.a-field-group label { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--a-muted); margin-bottom: 5px; }
.a-field-wrap { position: relative; display: flex; align-items: center; }
.a-field-icon { position: absolute; left: 11px; color: var(--a-muted); font-size: .85rem; pointer-events: none; }
.a-field-wrap input, .a-field-wrap select, .a-field-wrap textarea {
  width: 100%; height: 42px; padding: 0 38px 0 34px;
  background: var(--a-bg); border: 1.5px solid var(--a-border); border-radius: 8px;
  font-size: .875rem; color: var(--a-text);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.a-field-wrap textarea { height: auto; padding: 10px 12px 10px 34px; resize: vertical; }
.a-field-wrap input:focus, .a-field-wrap select:focus, .a-field-wrap textarea:focus {
  outline: none; border-color: var(--a-red); box-shadow: 0 0 0 3px rgba(219,0,17,.15);
}
.a-field-wrap select { padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.a-pw-toggle { position: absolute; right: 10px; color: var(--a-muted); font-size: .85rem; }
.a-pw-toggle:hover { color: var(--a-text); }

/* Buttons */
.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px;
  font-size: .875rem; font-weight: 600;
  transition: background .2s, opacity .2s, transform .15s;
  white-space: nowrap;
}
.a-btn:active { transform: translateY(1px); }
.a-btn:disabled { opacity: .5; cursor: not-allowed; }
.a-btn-full { width: 100%; }
.a-btn-sm { padding: 6px 12px; font-size: .8rem; }
.a-btn-red { background: var(--a-red); color: white; }
.a-btn-red:hover { background: var(--a-red-d); }
.a-btn-ghost { background: transparent; color: var(--a-muted); border: 1px solid var(--a-border); }
.a-btn-ghost:hover { background: var(--a-border); color: var(--a-text); }
.a-btn-blue { background: var(--a-blue); color: white; }
.a-btn-blue:hover { background: #2563eb; }
.a-btn-green { background: var(--a-green); color: white; }
.a-btn-green:hover { background: #059669; }
.a-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  font-size: .8rem; color: var(--a-muted);
  transition: background .2s, color .2s;
}
.a-btn-icon:hover { background: var(--a-border); color: var(--a-text); }
.a-btn-icon.danger:hover { background: rgba(219,0,17,.15); color: var(--a-red); }
.a-btn-icon.success:hover { background: rgba(16,185,129,.15); color: var(--a-green); }

/* Demo box */
.a-demo-box { margin-top: 20px; padding: 12px 14px; background: var(--a-bg); border: 1px solid var(--a-border); border-radius: 8px; }
.a-demo-box-title { font-size: .72rem; font-weight: 700; color: var(--a-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.a-demo-row { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; padding: 6px 8px; border-radius: 6px; color: var(--a-muted); transition: background .2s; }
.a-demo-row:hover { background: var(--a-border); color: var(--a-text); }
.a-back-link { font-size: .8rem; color: var(--a-muted); display: flex; align-items: center; gap: 6px; }
.a-back-link:hover { color: var(--a-text); }

/* ============================================================
   APP TOPBAR
   ============================================================ */
/* .a-app: display:flex nur wenn NICHT hidden */
.a-app { display: flex; flex-direction: column; min-height: 100vh; }
.a-app[hidden] { display: none !important; }
.a-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--a-topbar-h);
  background: var(--a-surface); border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.a-topbar-left { display: flex; align-items: center; gap: 14px; }
.a-topbar-center { display: flex; align-items: center; gap: 8px; }
.a-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--a-green); box-shadow: 0 0 6px var(--a-green); animation: livePulse 2s ease-in-out infinite; }
@keyframes livePulse { 0%,100%{opacity:1;} 50%{opacity:.3;} }
.a-live-label { font-size: .75rem; color: var(--a-green); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.a-topbar-right { display: flex; align-items: center; gap: 14px; }
.a-menu-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: var(--a-muted); transition: background .2s; }
.a-menu-btn:hover { background: var(--a-border); color: var(--a-text); }

.a-admin-info { display: flex; align-items: center; gap: 10px; }
.a-admin-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--a-red); color: white; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.a-admin-name { font-size: .85rem; font-weight: 600; }
.a-admin-role { font-size: .7rem; color: var(--a-muted); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.a-app-body { margin-top: var(--a-topbar-h); display: flex; min-height: calc(100vh - var(--a-topbar-h)); }
.a-sidebar {
  width: var(--a-sidebar-w); flex-shrink: 0;
  background: var(--a-surface); border-right: 1px solid var(--a-border);
  position: fixed; top: var(--a-topbar-h); bottom: 0; left: 0; z-index: 100;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.a-nav { padding: 16px 10px; flex: 1; overflow-y: auto; }
.a-nav-group { margin-bottom: 6px; }
.a-nav-label { display: block; padding: 6px 8px; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--a-muted); }
.a-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  font-size: .84rem; font-weight: 500; color: var(--a-muted);
  transition: background .15s, color .15s; cursor: pointer;
  white-space: nowrap;
}
.a-nav-item i { width: 16px; text-align: center; flex-shrink: 0; }
.a-nav-item span:first-of-type { flex: 1; }
.a-nav-item:hover { background: var(--a-border); color: var(--a-text); }
.a-nav-item.active { background: rgba(219,0,17,.15); color: var(--a-red); }
.a-nav-badge { font-size: .68rem; padding: 1px 6px; border-radius: 999px; background: var(--a-border); color: var(--a-muted); font-weight: 600; }
.a-nav-item.active .a-nav-badge { background: rgba(219,0,17,.2); color: var(--a-red); }

/* Sidebar Footer – Logout */
.a-sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--a-border);
  flex-shrink: 0;
}
.a-sidebar-logout {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 10px; border-radius: 7px;
  font-size: .84rem; font-weight: 500; color: var(--a-muted);
  transition: background .15s, color .15s; cursor: pointer;
}
.a-sidebar-logout:hover { background: rgba(219,0,17,.12); color: var(--a-red); }
.a-sidebar-logout i { width: 16px; text-align: center; }

/* Mobile Overlay */
.a-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.a-overlay.visible { display: block; }

/* ============================================================
   MAIN
   ============================================================ */
.a-main { flex: 1; margin-left: var(--a-sidebar-w); padding: 24px; min-width: 0; overflow-x: hidden; }

/* Modal – large variant */
.a-modal-lg { max-width: 620px; }

/* Admin details in topbar */
.a-admin-details { line-height: 1.2; }
.a-logout-label { display: inline; }

/* ============================================================
   CARDS & LAYOUT
   ============================================================ */
.a-card { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); overflow: hidden; }
.a-card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--a-border); }
.a-card-header h3 { font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.a-card-header h3 i { color: var(--a-red); }
.a-card-body { padding: 18px; }

.a-page-header { margin-bottom: 20px; }
.a-page-header h1 { font-size: 1.3rem; font-weight: 700; }
.a-page-header p { font-size: .82rem; color: var(--a-muted); }

.a-grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.a-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.a-grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.a-mb-16 { margin-bottom: 16px; }
.a-mb-20 { margin-bottom: 20px; }

/* KPI Cards */
.a-kpi { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); padding: 16px; }
.a-kpi-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--a-muted); margin-bottom: 6px; }
.a-kpi-value { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.a-kpi-sub { font-size: .75rem; color: var(--a-muted); }
.a-kpi.red .a-kpi-value { color: var(--a-red); }
.a-kpi.green .a-kpi-value { color: var(--a-green); }
.a-kpi.blue .a-kpi-value { color: var(--a-blue); }
.a-kpi.orange .a-kpi-value { color: var(--a-orange); }

/* ============================================================
   TABLE
   ============================================================ */
.a-table-wrap { overflow-x: auto; }
.a-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.a-table th { padding: 9px 12px; text-align: left; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--a-muted); background: var(--a-bg); border-bottom: 1px solid var(--a-border); white-space: nowrap; }
.a-table td { padding: 11px 12px; border-bottom: 1px solid var(--a-border); vertical-align: middle; }
.a-table tr:last-child td { border-bottom: none; }
.a-table tr:hover td { background: var(--a-border); }
.a-table td.money { font-weight: 600; }
.a-table td.money.pos { color: var(--a-green); }
.a-table td.money.neg { color: var(--a-red); }

/* Status badges */
.a-badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.a-badge.active, .a-badge.completed { background: rgba(16,185,129,.15); color: var(--a-green); }
.a-badge.blocked, .a-badge.cancelled { background: rgba(219,0,17,.15); color: var(--a-red); }
.a-badge.pending, .a-badge.paused { background: rgba(245,158,11,.15); color: var(--a-orange); }
.a-badge.closed { background: rgba(139,92,246,.15); color: var(--a-purple); }
.a-badge.superadmin { background: rgba(219,0,17,.15); color: var(--a-red); }
.a-badge.admin { background: rgba(59,130,246,.15); color: var(--a-blue); }
.a-badge.viewer { background: rgba(139,92,246,.15); color: var(--a-purple); }

/* Search & filter bar */
.a-filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.a-search-wrap { position: relative; flex: 1; min-width: 180px; }
.a-search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--a-muted); font-size: .82rem; }
.a-search-wrap input { width: 100%; height: 36px; padding: 0 12px 0 30px; background: var(--a-bg); border: 1px solid var(--a-border); border-radius: 7px; font-size: .82rem; color: var(--a-text); }
.a-search-wrap input:focus { outline: none; border-color: var(--a-red); }
.a-filter-select { height: 36px; padding: 0 24px 0 10px; background: var(--a-bg); border: 1px solid var(--a-border); border-radius: 7px; font-size: .82rem; color: var(--a-text); -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }

/* ============================================================
   MODAL
   ============================================================ */
.a-modal-backdrop { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.7); display: flex !important; align-items: center; justify-content: center; padding: 16px; }
.a-modal-backdrop[hidden] { display: none !important; }
.a-modal { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; animation: aSlideUp .18s ease; }
@keyframes aSlideUp { from{transform:translateY(16px);opacity:0;} to{transform:translateY(0);opacity:1;} }
.a-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--a-border); }
.a-modal-header h3 { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.a-modal-header h3 i { color: var(--a-red); }
.a-modal-close { font-size: 1.2rem; color: var(--a-muted); transition: color .15s; }
.a-modal-close:hover { color: var(--a-text); }
.a-modal-body { padding: 18px 20px; }
.a-modal-footer { padding: 14px 20px; border-top: 1px solid var(--a-border); display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================
   CHART
   ============================================================ */
.a-chart-wrap { position: relative; }

/* ============================================================
   TOAST
   ============================================================ */
#a-toast-container { position: fixed; bottom: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.a-toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--a-surface); border: 1px solid var(--a-border); border-radius: 8px; box-shadow: var(--a-shadow); animation: aToastIn .2s ease; font-size: .82rem; }
@keyframes aToastIn { from{transform:translateX(100%);opacity:0;} to{transform:translateX(0);opacity:1;} }
.a-toast.success { border-color: var(--a-green); }
.a-toast.error   { border-color: var(--a-red); }
.a-toast.info    { border-color: var(--a-blue); }
.a-toast.warning { border-color: var(--a-orange); }
.a-toast i.a-t-icon { font-size: .95rem; flex-shrink: 0; }
.a-toast.success i.a-t-icon { color: var(--a-green); }
.a-toast.error   i.a-t-icon { color: var(--a-red); }
.a-toast.info    i.a-t-icon { color: var(--a-blue); }
.a-toast.warning i.a-t-icon { color: var(--a-orange); }
.a-toast-text { flex: 1; color: var(--a-text); }
.a-toast-close { color: var(--a-muted); cursor: pointer; }

/* ============================================================
   DIVIDER & UTILS
   ============================================================ */
.a-divider { border: none; border-top: 1px solid var(--a-border); margin: 14px 0; }
.a-text-muted { color: var(--a-muted); }
.a-text-red { color: var(--a-red); }
.a-text-green { color: var(--a-green); }
.a-font-mono { font-family: monospace; }
.a-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: .68rem; font-weight: 600; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .a-grid-4 { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 768px) {
  /* Sidebar: off-screen by default on mobile */
  .a-sidebar {
    transform: translateX(calc(-1 * var(--a-sidebar-w)));
    z-index: 400;
    box-shadow: none;
  }
  .a-sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0,0,0,.6);
  }

  /* Main: no left margin on mobile */
  .a-main { margin-left: 0 !important; padding: 14px 12px 20px; }

  /* Topbar */
  .a-topbar { padding: 0 12px; }
  .a-topbar-center { display: none; }
  .a-admin-details { display: none; }
  .a-logout-label { display: none; }

  /* Grids */
  .a-grid-3 { grid-template-columns: repeat(2,1fr); }
  .a-grid-2 { grid-template-columns: 1fr; }

  /* Page header: stack on mobile */
  .a-page-header { flex-direction: column !important; gap: 12px; align-items: flex-start !important; }

  /* Modals: bottom sheet on mobile */
  .a-modal-backdrop { align-items: flex-end; padding: 0; }
  .a-modal, .a-modal-lg { max-width: 100%; width: 100%; margin: 0; border-radius: 14px 14px 0 0; max-height: 90vh; }
  .a-modal-body { padding: 14px 16px; max-height: 65vh; overflow-y: auto; }
  .a-modal-footer { flex-direction: column; gap: 6px; }
  .a-modal-footer .a-btn { width: 100%; justify-content: center; }

  /* Filter bars */
  .a-filter-bar { flex-direction: column; align-items: stretch; }
  .a-search-wrap { min-width: 100%; }
  .a-filter-select { width: 100%; }

  /* Tables: scrollable */
  .a-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
  .a-grid-2, .a-grid-3, .a-grid-4 { grid-template-columns: 1fr; }
  .a-kpi-value { font-size: 1.1rem; }
  .a-table { font-size: .76rem; }
  .a-table th, .a-table td { padding: 7px 8px; }
  .a-card-body { padding: 12px; }
  .a-card-header { padding: 12px; }
  .a-page-header h1 { font-size: 1.1rem; }

  /* Login auf kleinen Screens */
  .a-login-card { padding: 24px 18px; }
  .a-login-wrap { padding: 16px 12px; }
}
