/*
 * ============================================================
 *  auth.css — Shared Authentication Styles
 *  Change Request System · ICTA Kenya
 *  Kenyan flag palette: Red #bb0000 · White #ffffff · Green #006600 · Black #000000
 * ============================================================
 */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=Crimson+Pro:ital,wght@0,400;0,600;1,400;1,600&display=swap');

/* ══════════════════════════════════════════
   1. DESIGN TOKENS
══════════════════════════════════════════ */
:root {
  /* Kenyan flag palette */
  --ke-red:        #bb0000;
  --ke-red-deep:   #8e0000;
  --ke-red-glow:   rgba(187, 0, 0, 0.12);
  --ke-green:      #006600;
  --ke-green-deep: #004d00;
  --ke-green-glow: rgba(0, 102, 0, 0.12);
  --ke-black:      #0d0d0d;
  --ke-white:      #ffffff;

  /* Neutrals */
  --surface:       #f5f6f4;
  --card-bg:       #ffffff;
  --input-bg:      #f8f9f7;
  --border:        #e0e4de;
  --border-hover:  #c4ccc0;
  --muted:         #687066;
  --muted-light:   #a0a89e;

  /* Semantics */
  --error:         var(--ke-red);
  --success:       var(--ke-green);
  --info-bg:       #eef6ee;
  --info-border:   rgba(0, 102, 0, 0.2);
  --info-text:     var(--ke-green-deep);

  /* Layout */
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     22px;
  --card-width:    min(1020px, 96vw);
  --panel-width:   44%;

  /* Shadows */
  --shadow-card:
    0 1px 3px rgba(0,0,0,0.04),
    0 10px 36px rgba(0,0,0,0.09),
    0 36px 72px rgba(0,0,0,0.05);
  --shadow-btn-red:   0 4px 18px rgba(187,0,0,0.28);
  --shadow-btn-green: 0 4px 18px rgba(0,102,0,0.26);
  --shadow-btn-dark:  0 4px 18px rgba(13,13,13,0.20);

  /* Typography */
  --font-body:    'Sora', sans-serif;
  --font-display: 'Crimson Pro', Georgia, serif;
}

/* ══════════════════════════════════════════
   2. RESET & BASE
══════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background-color: var(--surface);
  color: var(--ke-black);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

/* ── Ambient background layers ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 10% 15%, var(--ke-red-glow) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 90% 85%, var(--ke-green-glow) 0%, transparent 55%),
    radial-gradient(ellipse 40% 35% at 50% 50%, rgba(0,0,0,0.025) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle diagonal stripe texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 40px,
    rgba(0,0,0,0.012) 40px,
    rgba(0,0,0,0.012) 41px
  );
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════════
   3. AUTH CARD WRAPPER
══════════════════════════════════════════ */
.auth-wrapper {
  display: flex;
  width: var(--card-width);
  min-height: 600px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  animation: authReveal 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Narrow-card variant for single-column pages (invalid token, etc.) */
.auth-wrapper--narrow {
  max-width: 480px;
  width: 100%;
  min-height: unset;
  flex-direction: column;
}

@keyframes authReveal {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ══════════════════════════════════════════
   4. LEFT VISUAL PANEL
══════════════════════════════════════════ */
.auth-panel {
  flex: 0 0 var(--panel-width);
  background: var(--ke-black);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 44px;
  overflow: hidden;
}

/* Kenyan flag stripe — top */
.auth-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--ke-red) 0%, var(--ke-white) 50%, var(--ke-green) 100%);
  z-index: 3;
}

/* Large radial glow */
.auth-panel::after {
  content: '';
  position: absolute;
  bottom: -100px;
  right: -100px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(187,0,0,0.18) 0%, transparent 65%);
  pointer-events: none;
}

/* Dot matrix grid overlay */
.auth-panel__grid {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

/* Secondary green glow top-left */
.auth-panel__glow {
  position: absolute;
  top: -60px;
  left: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,102,0,0.2) 0%, transparent 65%);
  pointer-events: none;
}

.auth-panel__inner {
  position: relative;
  z-index: 2;
  text-align: center;
}

/* ── Logo ── */
.auth-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  background: var(--ke-white);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 32px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12),
    0 8px 32px rgba(0,0,0,0.45),
    0 2px 8px rgba(0,0,0,0.3);
  overflow: hidden;
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 8px 32px rgba(0,0,0,0.45), 0 0 0 0 rgba(187,0,0,0); }
  50%       { box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 8px 32px rgba(0,0,0,0.45), 0 0 0 8px rgba(187,0,0,0.08); }
}

.auth-logo img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.auth-logo__monogram {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--ke-red), var(--ke-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: none;
}

/* ── Panel heading ── */
.auth-panel__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ke-white);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.auth-panel__title em {
  font-style: italic;
  color: var(--ke-red);
}

.auth-panel__title em.em-green {
  color: #4dba6e;
}

.auth-panel__sub {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.4);
  line-height: 1.7;
  max-width: 200px;
  margin: 0 auto;
  font-weight: 300;
}

/* ── Kenyan flag colour band (bottom) ── */
.auth-panel__flag {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 5px;
  display: flex;
}

.auth-panel__flag span:nth-child(1) { flex: 1; background: var(--ke-red); }
.auth-panel__flag span:nth-child(2) { flex: 1; background: var(--ke-white); }
.auth-panel__flag span:nth-child(3) { flex: 1; background: var(--ke-green); }

/* Floating shield icon (decorative) */
.auth-panel__icon {
  position: absolute;
  bottom: 28px;
  right: 28px;
  width: 48px;
  height: 48px;
  opacity: 0.07;
}

/* ══════════════════════════════════════════
   5. RIGHT FORM PANEL
══════════════════════════════════════════ */
.auth-form-panel {
  flex: 1;
  background: var(--card-bg);
  padding: 56px 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Red→Green accent line — left edge */
.auth-form-panel::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--ke-red) 0%, var(--ke-white) 50%, var(--ke-green) 100%);
}

/* Corner decoration */
.auth-form-panel::after {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,102,0,0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Form header ── */
.auth-form-header {
  margin-bottom: 32px;
}

.auth-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ke-red);
  margin-bottom: 10px;
}

.auth-eyebrow::before {
  content: '';
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ke-red);
  border-radius: 2px;
}

.auth-eyebrow--green {
  color: var(--ke-green);
}
.auth-eyebrow--green::before {
  background: var(--ke-green);
}

.auth-form-header h2 {
  font-family: var(--font-display);
  font-size: 1.95rem;
  font-weight: 600;
  color: var(--ke-black);
  margin-bottom: 6px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.auth-form-header p {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 300;
}

/* ── Messages area ── */
.auth-messages {
  margin-bottom: 18px;
}

/* ── Flash message component ── */
.auth-messages-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 20px;
}

.cr-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: opacity 0.2s ease;
  overflow-wrap: break-word;
}

/* Colour variants */
.cr-msg--success {
  background: #eef7ee;
  border-color: #2d8a3a;
}
.cr-msg--error {
  background: #fdf0f0;
  border-color: var(--ke-red);
}
.cr-msg--warning {
  background: #fdf6ec;
  border-color: #c87f17;
}
.cr-msg--info {
  background: #edf4fb;
  border-color: #2271b3;
}

/* Icon circle */
.cr-msg__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.cr-msg--success .cr-msg__icon { background: #2d8a3a; }
.cr-msg--error   .cr-msg__icon { background: var(--ke-red); }
.cr-msg--warning .cr-msg__icon { background: #c87f17; }
.cr-msg--info    .cr-msg__icon { background: #2271b3; }

.cr-msg__icon svg {
  width: 10px;
  height: 10px;
}

/* Body text */
.cr-msg__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cr-msg__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  display: block;
}
.cr-msg--success .cr-msg__label { color: #1a5c22; }
.cr-msg--error   .cr-msg__label { color: #8b1a1a; }
.cr-msg--warning .cr-msg__label { color: #7a4c0a; }
.cr-msg--info    .cr-msg__label { color: #0e3d6a; }

.cr-msg__text {
  font-size: 0.84rem;
  line-height: 1.5;
}
.cr-msg--success .cr-msg__text { color: #1e6b27; }
.cr-msg--error   .cr-msg__text { color: #8b1a1a; }
.cr-msg--warning .cr-msg__text { color: #7a4c0a; }
.cr-msg--info    .cr-msg__text { color: #0e3d6a; }

/* Close button */
.cr-msg__close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  opacity: 0.4;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
  margin-top: 2px;
}
.cr-msg__close:hover { opacity: 0.85; }
.cr-msg__close svg {
  width: 12px;
  height: 12px;
}
.cr-msg--success .cr-msg__close { color: #1a5c22; }
.cr-msg--error   .cr-msg__close { color: #8b1a1a; }
.cr-msg--warning .cr-msg__close { color: #7a4c0a; }
.cr-msg--info    .cr-msg__close { color: #0e3d6a; }

/* ── Hint/info box ── */
.auth-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 24px;
}

.auth-hint__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ke-green);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.auth-hint__icon svg {
  width: 12px;
  height: 12px;
  fill: #fff;
}

.auth-hint p {
  font-size: 0.82rem;
  color: var(--info-text);
  line-height: 1.6;
  font-weight: 400;
}

/* ══════════════════════════════════════════
   6. FORM FIELDS
══════════════════════════════════════════ */
.auth-field {
  margin-bottom: 20px;
}

.auth-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #3d443b;
  margin-bottom: 8px;
}

.auth-field label .req {
  color: var(--ke-red);
  margin-left: 2px;
}

/* All text / email / password inputs */
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="text"] {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--ke-black);
  outline: none;
  transition: border-color 0.22s, box-shadow 0.22s, background 0.22s;
  -webkit-appearance: none;
}

.auth-field input:hover {
  border-color: var(--border-hover);
}

.auth-field input:focus {
  border-color: var(--ke-green);
  background: var(--ke-white);
  box-shadow: 0 0 0 3px var(--ke-green-glow);
}

.auth-field input::placeholder {
  color: var(--muted-light);
  font-weight: 300;
}

/* Field errors */
.auth-field__errors {
  margin-top: 7px;
}

.auth-field__errors p {
  font-size: 0.76rem;
  color: var(--error);
  line-height: 1.4;
}

/* ── Password strength meter ── */
.strength-meter {
  display: flex;
  gap: 5px;
  margin-top: 9px;
}

.strength-meter__bar {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.32s ease;
}

/* ══════════════════════════════════════════
   7. BUTTONS
══════════════════════════════════════════ */
.auth-btn {
  width: 100%;
  padding: 13.5px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  margin-top: 12px;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.22s, background 0.22s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Shimmer overlay */
.auth-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 55%);
  pointer-events: none;
}

.auth-btn:hover  { transform: translateY(-2px); }
.auth-btn:active { transform: translateY(0); }

/* Red variant */
.auth-btn--red {
  background: var(--ke-red);
  box-shadow: var(--shadow-btn-red);
}
.auth-btn--red:hover {
  background: var(--ke-red-deep);
  box-shadow: 0 8px 28px rgba(187,0,0,0.35);
}

/* Green variant */
.auth-btn--green {
  background: var(--ke-green);
  box-shadow: var(--shadow-btn-green);
}
.auth-btn--green:hover {
  background: var(--ke-green-deep);
  box-shadow: 0 8px 28px rgba(0,102,0,0.32);
}

/* Dark variant */
.auth-btn--dark {
  background: var(--ke-black);
  box-shadow: var(--shadow-btn-dark);
}
.auth-btn--dark:hover {
  background: #1e1e1e;
  box-shadow: 0 8px 28px rgba(13,13,13,0.30);
}

/* Arrow arrow — shows on right */
.auth-btn__arrow {
  font-size: 1rem;
  transition: transform 0.2s;
}
.auth-btn:hover .auth-btn__arrow {
  transform: translateX(3px);
}

/* ══════════════════════════════════════════
   8. FOOTER + BRAND
══════════════════════════════════════════ */
.auth-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 300;
}

.auth-footer a {
  color: var(--ke-green);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.auth-footer a:hover {
  color: var(--ke-red);
}

/* Brand strip */
.auth-brand {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-brand__flag {
  display: flex;
  align-items: center;
  gap: 4px;
}

.auth-brand__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.auth-brand__dot--red   { background: var(--ke-red); }
.auth-brand__dot--white { background: #c8ccc6; border: 1px solid #ddd; }
.auth-brand__dot--green { background: var(--ke-green); }
.auth-brand__dot--black { background: var(--ke-black); }

.auth-brand__label {
  font-size: 0.68rem;
  color: var(--muted-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ══════════════════════════════════════════
   9. INVALID TOKEN / STATUS PAGE
══════════════════════════════════════════ */
.auth-status {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 56px 48px;
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  animation: authReveal 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  max-width: 440px;
  width: 100%;
  margin: 0 16px;
}

/* Top flag bar */
.auth-status::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, var(--ke-red) 0%, var(--ke-white) 50%, var(--ke-green) 100%);
}

.auth-status__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fdf2f2;
  border: 2px solid rgba(187,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.auth-status__icon svg {
  width: 34px;
  height: 34px;
  color: var(--ke-red);
}

.auth-status h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ke-black);
  margin-bottom: 12px;
}

.auth-status p {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 28px;
}

/* ══════════════════════════════════════════
   10. RESPONSIVE
══════════════════════════════════════════ */

/* Tablet */
@media (max-width: 860px) {
  .auth-form-panel {
    padding: 44px 40px;
  }

  .auth-panel {
    flex: 0 0 38%;
    padding: 44px 32px;
  }

  .auth-panel__title {
    font-size: 1.75rem;
  }
}

/* Mobile */
@media (max-width: 640px) {
  body {
    align-items: flex-start;
    padding: 0;
  }

  .auth-wrapper {
    flex-direction: column;
    min-height: 100dvh;
    border-radius: 0;
    animation: none;
  }

  .auth-panel {
    flex: none;
    padding: 32px 28px;
    min-height: 200px;
  }

  .auth-panel__sub {
    max-width: 260px;
  }

  .auth-form-panel {
    flex: 1;
    padding: 36px 28px 40px;
    justify-content: flex-start;
  }

  .auth-logo {
    width: 68px;
    height: 68px;
    margin-bottom: 22px;
  }

  .auth-logo img {
    width: 50px;
    height: 50px;
  }

  .auth-panel__title {
    font-size: 1.5rem;
  }

  .auth-form-header h2 {
    font-size: 1.6rem;
  }

  .auth-form-panel::before { width: 2px; }

  .auth-status {
    border-radius: 0;
    min-height: 100dvh;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .auth-form-panel {
    padding: 28px 20px 32px;
  }

  .auth-form-header h2 {
    font-size: 1.4rem;
  }
}
