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

:root {
  --red: #ed1b24;
  --red-deep: #c51017;
  --bg: #0a0a0a;
  --bg-2: #131313;
  --bg-3: #1d1d1d;
  --grey-9: #2a2a2a;
  --grey-7: #4a4a4a;
  --grey-3: #b8b8b8;
  --grey-1: #ececec;
  --green: #22c55e;
  --amber: #f59e0b;
  --text: #ededed;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* === Layout === */
body { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--grey-9);
  display: flex; flex-direction: column;
  padding: 22px 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px 22px; border-bottom: 1px solid var(--grey-9);
  margin-bottom: 18px;
}
.sidebar__brand img { height: 28px; }
.sidebar__brand span {
  font-weight: 700; font-size: 11px; letter-spacing: 0.18em;
  color: var(--red); text-transform: uppercase;
}
.sidebar__nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.sidebar__nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 6px;
  font-size: 13.5px; font-weight: 500;
  color: var(--grey-3);
  transition: background 0.15s, color 0.15s;
}
.sidebar__nav a:hover { background: var(--bg-3); color: var(--text); }
.sidebar__nav a.active { background: var(--red); color: #fff; }
.sidebar__nav .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; opacity: 0.85; font-size: 14px;
}
.sidebar__nav .nav-sep {
  font-size: 10px;
  color: var(--grey-7);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 18px 14px 6px;
  font-weight: 600;
}
.sidebar__footer { padding: 16px 22px; border-top: 1px solid var(--grey-9); margin-top: 18px; }
.sidebar__footer .view-site {
  display: block; padding: 8px 0; font-size: 12px; color: var(--grey-3);
  margin-bottom: 12px;
}
.sidebar__footer .view-site:hover { color: var(--red); }
.sidebar__footer .user {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--grey-3);
}
.sidebar__footer .user a { color: var(--red); font-weight: 500; }

/* === Main === */
.main { padding: 32px 40px 60px; max-width: 100%; overflow-x: hidden; }
.main-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.main-head h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.01em;
}
.head-actions { display: flex; gap: 10px; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); }
.btn-ghost { background: transparent; color: var(--grey-3); border-color: var(--grey-9); }
.btn-ghost:hover { color: var(--text); border-color: var(--grey-7); }
.btn-danger { background: transparent; color: #ef4444; border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: #ef4444; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* === Cards / panels === */
.card {
  background: var(--bg-2);
  border: 1px solid var(--grey-9);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 18px;
}
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--grey-1); }

/* === Stats grid === */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 28px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--grey-9);
  border-radius: 10px;
  padding: 18px 22px;
}
.stat__label { font-size: 12px; color: var(--grey-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat__value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat__sub { font-size: 12px; color: var(--grey-7); margin-top: 4px; }

/* === Table === */
.table-wrap { background: var(--bg-2); border: 1px solid var(--grey-9); border-radius: 10px; overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  padding: 12px 18px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--grey-3); font-weight: 600;
  background: var(--bg-3); border-bottom: 1px solid var(--grey-9);
}
table.tbl td {
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13.5px; color: var(--grey-1); vertical-align: middle;
}
table.tbl tr:hover td { background: rgba(255,255,255,0.02); }
table.tbl tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: var(--bg-3); }
.thumb-sponsor { width: 60px; height: 36px; object-fit: contain; background: #fff; padding: 4px; border-radius: 4px; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  background: var(--bg-3); color: var(--grey-3);
}
.badge--red { background: rgba(237,27,36,0.14); color: #ff5460; }
.badge--green { background: rgba(34,197,94,0.14); color: var(--green); }
.badge--amber { background: rgba(245,158,11,0.14); color: var(--amber); }

/* === Forms === */
.form { max-width: 720px; }
.form-grid { display: grid; gap: 18px; }
.form-grid--2 { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--grey-3); font-weight: 600;
}
.field input, .field select, .field textarea {
  background: var(--bg);
  border: 1px solid var(--grey-9);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--red);
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field .help { font-size: 12px; color: var(--grey-7); }
.field--check {
  flex-direction: row; align-items: center; gap: 10px;
}
.field--check input { width: 18px; height: 18px; }
.field--check label { text-transform: none; letter-spacing: normal; font-size: 13.5px; color: var(--text); cursor: pointer; }

/* === File upload === */
.file-upload {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border: 1px dashed var(--grey-9);
  border-radius: 8px;
}
.file-upload .preview {
  width: 64px; height: 64px; border-radius: 6px;
  background: var(--bg-3) center/cover no-repeat;
  flex-shrink: 0;
}
.file-upload .preview--landscape { width: 100px; }
.file-upload .info { flex: 1; }
.file-upload input[type=file] { font-size: 12px; color: var(--grey-3); }
.file-upload .current-name { font-size: 12px; color: var(--grey-7); margin-top: 4px; }

/* === Form actions === */
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 28px; padding-top: 22px;
  border-top: 1px solid var(--grey-9);
}

/* === Flash / Toast === */
.flash {
  padding: 14px 18px; border-radius: 8px;
  margin-bottom: 22px; font-size: 14px;
  border: 1px solid;
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.flash--success { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.3); color: var(--green); }
.flash--error { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.3); color: #ef4444; }
.flash--info { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.3); color: #60a5fa; }

/* === Login page === */
.login-page {
  display: grid; grid-template-columns: 1fr; align-items: center; justify-items: center;
  min-height: 100vh; padding: 30px;
  background:
    radial-gradient(circle at 20% 30%, rgba(237,27,36,0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(237,27,36,0.08) 0%, transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-2); border: 1px solid var(--grey-9);
  border-radius: 14px; padding: 36px 32px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
}
.login-card .brand {
  display: flex; align-items: center; flex-direction: column; gap: 14px;
  text-align: center; margin-bottom: 28px;
}
.login-card .brand img { height: 40px; }
.login-card .brand small {
  font-size: 11px; letter-spacing: 0.2em; color: var(--red); text-transform: uppercase; font-weight: 700;
}
.login-card h1 {
  font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 22px;
  color: var(--grey-1);
}
.login-card .form-actions { border-top: 0; padding-top: 0; margin-top: 22px; }
.login-card .btn { width: 100%; justify-content: center; padding: 13px; }

/* === Filters === */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters .chip {
  padding: 8px 14px; border-radius: 20px;
  background: var(--bg-2); border: 1px solid var(--grey-9);
  font-size: 12px; color: var(--grey-3); cursor: pointer;
  transition: all 0.15s;
}
.filters .chip:hover { border-color: var(--grey-7); color: var(--text); }
.filters .chip.active { background: var(--red); border-color: var(--red); color: #fff; }

/* === Drag handle === */
.drag-handle {
  cursor: grab; color: var(--grey-7);
  user-select: none; padding: 0 8px;
}
.drag-handle:active { cursor: grabbing; }
tr.dragging { opacity: 0.5; }

/* === Mobile bottom-nav hamburger drawer === */
.admin-mobile-bar {
  display: none;
  position: sticky; top: 0; z-index: 90;
  background: var(--bg-2); border-bottom: 1px solid var(--grey-9);
  padding: 12px 16px; align-items: center; justify-content: space-between;
}
.admin-mobile-bar__logo { display:flex; align-items:center; gap:10px }
.admin-mobile-bar__logo img { height: 24px }
.admin-mobile-bar__logo span { color: var(--red); font-size:11px; letter-spacing:.18em; text-transform:uppercase; font-weight:700 }
.admin-burger {
  background: transparent; border: 1px solid var(--grey-9); border-radius: 6px;
  width: 38px; height: 38px; display:inline-flex; align-items:center; justify-content:center;
  cursor: pointer; padding: 0;
}
.admin-burger span { display:block; width:18px; height:2px; background:#fff; position:relative; transition:.2s }
.admin-burger span::before,
.admin-burger span::after { content:""; position:absolute; left:0; right:0; height:2px; background:#fff; transition:.2s }
.admin-burger span::before { top:-6px }
.admin-burger span::after  { top:6px }
.admin-burger.open span { background: transparent }
.admin-burger.open span::before { top:0; transform: rotate(45deg) }
.admin-burger.open span::after  { top:0; transform: rotate(-45deg) }
.admin-overlay {
  display:none;
  position: fixed; inset:0;
  background: rgba(0,0,0,.6);
  z-index: 95;
}
.admin-overlay.show { display:block }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .admin-mobile-bar { display:flex }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 86vw;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    border-right: 1px solid var(--grey-9);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.6) }
  .sidebar__nav { flex-direction: column; padding: 0 12px 12px; }
  .sidebar__nav a { padding: 12px 14px; font-size: 14px }
  .sidebar__footer { display: block; padding-bottom: 24px }
  .main { padding: 18px 16px 60px; }
  .main-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 20px }
  .main-head h1 { font-size: 22px }
  .head-actions { flex-wrap: wrap; width: 100% }
  .head-actions .btn { flex: 1 1 auto; justify-content: center }
  .form { max-width: 100% }
  .form-grid--2 { grid-template-columns: 1fr; }
  .card { padding: 18px }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px }
  .stat { padding: 14px }
  .stat__value { font-size: 22px }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch }
  table.tbl { min-width: 600px }
  table.tbl th, table.tbl td { padding: 10px 12px; font-size: 13px }
  .row-actions { gap: 4px }
  .row-actions .btn { padding: 5px 9px; font-size: 11px }
  .filters { gap: 6px }
  .filters .chip { padding: 6px 10px; font-size: 11px }
  .field input, .field select, .field textarea { font-size: 16px } /* anti iOS zoom */
  .form-actions { flex-direction: column-reverse; align-items: stretch }
  .form-actions .btn { width: 100%; justify-content: center }
  .login-card { padding: 24px 20px; max-width: 100% }
  .file-upload { flex-direction: column; align-items: stretch; text-align: center }
  .file-upload .preview { width: 100%; height: 140px }
  .file-upload .preview--landscape { width: 100%; height: 140px }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr }
  .card { padding: 14px }
  .main { padding: 14px 12px 50px }
}

/* Sledgehammer: any inline grid/flex in admin main collapses on mobile */
@media (max-width: 768px) {
  .main [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .main [style*="display:flex"][style*="align-items:flex-end"],
  .main [style*="display:flex"][style*="align-items: flex-end"] { flex-wrap: wrap !important; }
  /* Invoice items table needs to stay scrollable, not stacked */
  #items-table { min-width: 600px }
}
