/* =========================================================================
   Hatchiko x Cignal Activation Portal — global theme
   Red brand palette + animated backdrop, glass surfaces, mobile-first.
   Per-company pages override --primary / --primary-dark via inline style.
   ========================================================================= */

:root {
  --red-1:  #3a0009;
  --red-2:  #7a0010;
  --red-3:  #b3001b;
  --red-4:  #e10026;
  --red-5:  #ff3b3b;

  --primary:      #b3001b;
  --primary-dark: #7a0010;

  --ink:    #1a0307;
  --text:   #1f2937;
  --muted:  #6b7280;
  --border: rgba(0,0,0,.08);

  --surface:        #ffffff;
  --surface-soft:   #fff7f8;
  --surface-glass:  rgba(255,255,255,.92);

  --danger:  #c51a1a;
  --success: #16a34a;
  --warn:    #d97706;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow:    0 8px 24px rgba(80, 0, 10, .12);
  --shadow-lg: 0 14px 40px rgba(80, 0, 10, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: #1a0003;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ---------- Animated red backdrop ---------- */
.bg-anim {
  position: fixed; inset: 0; z-index: -3;
  background: linear-gradient(120deg,#3a0009,#7a0010,#b3001b,#e10026,#7a0010,#3a0009);
  background-size: 400% 400%;
  animation: bgShift 22s ease infinite;
}
.bg-anim::before, .bg-anim::after {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,80,80,.45), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,30,80,.40), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(120,0,0,.45), transparent 60%);
  animation: floatBlob 24s ease-in-out infinite alternate;
  filter: blur(20px);
}
.bg-anim::after {
  animation-duration: 32s;
  background:
    radial-gradient(circle at 70% 20%, rgba(255,120,80,.30), transparent 45%),
    radial-gradient(circle at 30% 80%, rgba(180,0,40,.40), transparent 50%);
}
.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, #000 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 30%, transparent 70%);
}

@keyframes bgShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes floatBlob {
  0%   { transform: translate(0,0)        scale(1); }
  50%  { transform: translate(40px,-30px) scale(1.10); }
  100% { transform: translate(-30px,30px) scale(.95); }
}
@keyframes pulseDot {
  0%, 100% { opacity: .65; }
  50%      { opacity: 1; }
}

/* When a company background image is uploaded, show it as a softer overlay */
body.with-bg .bg-anim::after {
  background-image: var(--bg-img);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  mix-blend-mode: overlay; opacity: .55; filter: none;
  animation: none;
}

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 18px 20px; position: relative; }
.container.narrow { max-width: 720px; }
.container.tight  { max-width: 480px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(20,0,5,.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.10);
  color: #fff;
}
.topbar a { color: #fff; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px;
}
.topbar .brand {
  font-weight: 800; font-size: 18px; letter-spacing: .2px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.topbar .topbar-inner > .brand:first-child::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--red-5);
  box-shadow: 0 0 14px var(--red-5);
  animation: pulseDot 1.6s ease infinite;
}
.topbar .nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.topbar .nav a {
  padding: 7px 12px; border-radius: 8px; font-size: 14px;
  color: #ffd9dc;
  transition: background .15s ease, color .15s ease;
}
.topbar .nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar .userbox { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.topbar .user { font-size: 13px; color: #ffd9dc; opacity: .9; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; line-height: 1.2;
  transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(.95); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(120,0,16,.35);
}
.btn-secondary { background: #4b5563; color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-ghost     { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(120,0,16,.10);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }

.card-link { color: inherit; text-decoration: none; display: block; }
.card-link:hover .card { border-color: var(--primary); transform: translateY(-2px); transition: all .15s ease; }
.card-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }

.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  margin-top: 16px;
}

/* ---------- KPI tiles ---------- */
.kpi-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi {
  background: var(--surface-glass);
  border: 1px solid rgba(120,0,16,.10);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -14px; top: -14px;
  width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle, rgba(225,0,38,.18), transparent 70%);
}
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.kpi .value { font-size: 30px; font-weight: 800; margin-top: 2px; color: var(--ink); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 12px; }
.form .field { display: grid; gap: 6px; }
.form label { font-weight: 700; font-size: 13px; color: #2c0207; }
.form input[type=text],
.form input[type=email],
.form input[type=tel],
.form input[type=password],
.form input[type=number],
.form input[type=color],
.form input[type=file],
.form select,
.form textarea {
  border: 1px solid #e7d6da; border-radius: var(--radius-sm); padding: 10px 12px;
  font: inherit; background: #fff; width: 100%; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(179,0,27,.18);
}
.form input[type=color] { padding: 4px; height: 42px; }
.form input[type=file]  { padding: 8px; }
.form .row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form .row { grid-template-columns: 1fr; } }
.form .help { font-size: 12px; color: var(--muted); }
.form .actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #fff; border: 1px solid rgba(120,0,16,.10);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  padding: 11px 12px; border-bottom: 1px solid #f0e2e5;
  text-align: left; font-size: 14px; vertical-align: middle;
}
.table th {
  background: linear-gradient(180deg,#fff,#fff7f8);
  font-weight: 700; color: #6b2125;
  text-transform: uppercase; letter-spacing: .04em; font-size: 12px;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fffafa; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
}
.badge-pending,
.badge-pending_otp { background: #fff3cd; color: #8a6d00; border: 1px solid #f1deb1; }
.badge-active,
.badge-approved    { background: #dcf6e3; color: #0a6b2c; border: 1px solid #a6e0b9; }
.badge-disapproved,
.badge-disabled    { background: #fde2e2; color: #951313; border: 1px solid #f3b1b1; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin: 10px 0; font-size: 14px; }
.alert-error   { background: #fde2e2; color: #7a1010; border: 1px solid #f5b8b8; }
.alert-success { background: #dcf6e3; color: #0a5d24; border: 1px solid #a9e3bb; }
.alert-info    { background: #ffe8eb; color: #7a0010; border: 1px solid #ffc6cd; }

/* ---------- Auth screens (login, OTP, register) ---------- */
.auth-wrap {
  min-height: calc(100vh - 60px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin: 0 0 4px; font-size: 24px; color: var(--ink); }
.auth-card .sub { color: var(--muted); margin-bottom: 18px; font-size: 14px; }

/* ---------- Section title row ---------- */
.section-title {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  margin-top: 22px;
}
.section-title h1, .section-title h2 { margin: 0; }

/* Headings sitting directly on the animated bg are white; inside cards they stay dark */
.container > h1, .container > h2, .container > h3,
.section-title > h1, .section-title > h2,
.section-title > div > h1 {
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.45);
}
.card h1, .card h2, .card h3,
.glass h1, .glass h2, .glass h3,
.kpi  h1, .kpi  h2, .kpi  h3 { color: var(--ink); text-shadow: none; }

/* Subtitle / muted lines under headings on bg should also be readable */
.container > p.muted, .container > .muted { color: #ffd9dc; }
.card .muted, .table .muted, .kpi .muted { color: var(--muted); }

/* ---------- Misc ---------- */
.hr { border: 0; border-top: 1px solid #f0e2e5; margin: 18px 0; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.right  { text-align: right; }
.center { text-align: center; }

/* Code in admin pages */
code {
  background: #fff0f2; color: #7a0010; padding: 2px 6px;
  border-radius: 5px; font-size: 12.5px; border: 1px solid #ffdce0;
}

/* ---------- Mobile (member) tweaks ---------- */
body.mobile .container { padding: 12px; }
body.mobile h1 { font-size: 22px; }
body.mobile .topbar-inner { padding: 10px 12px; gap: 8px; }
body.mobile .topbar .brand { font-size: 15px; }
body.mobile .btn { padding: 11px 16px; font-size: 15px; }
body.mobile .form input, body.mobile .form select { font-size: 16px; padding: 12px; }
body.mobile .auth-card { padding: 20px; max-width: 100%; }
body.mobile .table { font-size: 13px; }
body.mobile .table th, body.mobile .table td { padding: 9px 10px; }
body.mobile .kpi-grid { grid-template-columns: repeat(2, 1fr); }
body.mobile .kpi .value { font-size: 24px; }
body.mobile .section-title { flex-direction: column; align-items: flex-start; }
