/* ============================================================
   style.css — Mobile Legends: Bang Bang Theme
   ESP32 Blue LED Control Dashboard
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Rajdhani:wght@400;500;600;700&family=Orbitron:wght@400;700;900&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --gold:         #f0c040;
  --gold-light:   #ffe87a;
  --gold-dark:    #a07800;
  --blue-deep:    #050d1a;
  --blue-mid:     #071428;
  --blue-panel:   #0a1e3a;
  --blue-border:  #1a3a6a;
  --blue-glow:    #1e6fff;
  --blue-led:     #00aaff;
  --blue-bright:  #4dc8ff;
  --red-danger:   #ff4455;
  --green-ok:     #22dd88;
  --text-main:    #d0e8ff;
  --text-dim:     #6a8aaa;
  --font-title:   'Cinzel Decorative', serif;
  --font-hud:     'Orbitron', monospace;
  --font-body:    'Rajdhani', sans-serif;
  --panel-shadow: 0 0 40px rgba(0, 90, 255, 0.25);
  --glow-gold:    0 0 12px rgba(240,192,64,0.7), 0 0 32px rgba(240,192,64,0.3);
  --glow-blue:    0 0 12px rgba(0,170,255,0.8), 0 0 32px rgba(0,170,255,0.4);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--blue-deep);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(30,111,255,0.18) 0%, transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M0 30 L30 0 L60 30 L30 60 Z' fill='none' stroke='%231a3a6a' stroke-width='0.4' opacity='0.5'/%3E%3C/svg%3E");
  background-size: auto, 60px 60px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Animated stars background ───────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 10%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 70%, rgba(200,220,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 50%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 40% 20%, rgba(255,230,100,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 90%, rgba(255,255,255,0.3) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0%   { opacity: 0.6; }
  100% { opacity: 1; }
}

/* ── Layout ───────────────────────────────────────────────── */
.wrapper {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  text-align: center;
  padding: 40px 0 20px;
  position: relative;
}

.header-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.header-ornament::before,
.header-ornament::after {
  content: '';
  flex: 1;
  max-width: 180px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: var(--glow-gold);
}

.diamond {
  width: 10px;
  height: 10px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: var(--glow-gold);
  animation: pulse-diamond 2s ease-in-out infinite;
}

@keyframes pulse-diamond {
  0%, 100% { transform: rotate(45deg) scale(1); }
  50%       { transform: rotate(45deg) scale(1.4); box-shadow: 0 0 20px var(--gold); }
}

.header h1 {
  font-family: var(--font-title);
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 55%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 10px rgba(240,192,64,0.5));
  line-height: 1.2;
}

.header-sub {
  font-family: var(--font-hud);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--blue-bright);
  text-transform: uppercase;
  margin-top: 6px;
  opacity: 0.8;
}

/* ── Panel (reusable card) ────────────────────────────────── */
.panel {
  background: linear-gradient(145deg, rgba(10,30,60,0.95) 0%, rgba(5,15,35,0.98) 100%);
  border: 1px solid var(--blue-border);
  border-radius: 4px;
  box-shadow: var(--panel-shadow), inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 28px 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

/* Corner ornaments */
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.7;
}
.panel::before { top: 6px; left: 6px; border-width: 2px 0 0 2px; }
.panel::after  { bottom: 6px; right: 6px; border-width: 0 2px 2px 0; }

.panel-title {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-dark), transparent);
}

/* ── Status Panel ─────────────────────────────────────────── */
.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.led-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 100px;
}

/* The LED "bulb" */
.led-bulb {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1a3a6a, #050d1a);
  border: 2px solid var(--blue-border);
  position: relative;
  transition: all 0.4s ease;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.5);
}

/* LED states */
.led-bulb.state-off {
  background: radial-gradient(circle at 35% 35%, #1a2a3a, #050d1a);
  border-color: #1a3050;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.5);
}

.led-bulb.state-on {
  background: radial-gradient(circle at 35% 35%, var(--blue-bright), var(--blue-led), #0050aa);
  border-color: var(--blue-bright);
  box-shadow:
    0 0 0 4px rgba(0,0,0,0.4),
    0 0 20px var(--blue-led),
    0 0 50px rgba(0,170,255,0.5),
    0 0 80px rgba(0,170,255,0.2);
}

.led-bulb.state-blink {
  animation: led-blink 0.5s steps(1) infinite;
}

@keyframes led-blink {
  0%, 100% {
    background: radial-gradient(circle at 35% 35%, var(--blue-bright), var(--blue-led), #0050aa);
    border-color: var(--blue-bright);
    box-shadow: 0 0 0 4px rgba(0,0,0,0.4), 0 0 20px var(--blue-led), 0 0 50px rgba(0,170,255,0.5);
  }
  50% {
    background: radial-gradient(circle at 35% 35%, #1a2a3a, #050d1a);
    border-color: #1a3050;
    box-shadow: 0 0 0 4px rgba(0,0,0,0.5);
  }
}

/* LED inner highlight */
.led-bulb::after {
  content: '';
  position: absolute;
  top: 16%;
  left: 20%;
  width: 28%;
  height: 20%;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  filter: blur(2px);
}

.led-label {
  font-family: var(--font-hud);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* Status text badge */
.status-info { flex: 1; min-width: 160px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 2px;
  border: 1px solid;
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
  transition: all 0.4s ease;
}

.status-badge.s-off {
  color: var(--text-dim);
  border-color: #2a3a4a;
  background: rgba(10,20,35,0.8);
}
.status-badge.s-on {
  color: var(--blue-bright);
  border-color: var(--blue-led);
  background: rgba(0,100,200,0.15);
  box-shadow: var(--glow-blue), inset 0 0 20px rgba(0,170,255,0.05);
}
.status-badge.s-blink {
  color: var(--gold-light);
  border-color: var(--gold);
  background: rgba(200,150,0,0.12);
  box-shadow: var(--glow-gold), inset 0 0 20px rgba(240,192,64,0.05);
  animation: badge-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes badge-pulse {
  from { opacity: 0.8; }
  to   { opacity: 1; box-shadow: 0 0 20px rgba(240,192,64,0.9), 0 0 50px rgba(240,192,64,0.4); }
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.status-meta span {
  color: var(--text-main);
  font-weight: 600;
}

/* ── Control Buttons ──────────────────────────────────────── */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.btn-control {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 14px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-hud);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  overflow: hidden;
  transition: all 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* Button shine sweep */
.btn-control::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
}
.btn-control:hover::before { left: 125%; }

.btn-control:active { transform: scale(0.95); }

/* Icon inside button */
.btn-icon {
  font-size: 1.6rem;
  line-height: 1;
  transition: transform 0.2s ease;
}
.btn-control:hover .btn-icon { transform: scale(1.2); }

.btn-label { position: relative; z-index: 1; }
.btn-sub {
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  opacity: 0.7;
  font-weight: 400;
}

/* OFF button */
.btn-off {
  background: linear-gradient(145deg, #1a2a3e, #0d1a2e);
  border: 1px solid #2a3a54;
  color: #7090b0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}
.btn-off:hover {
  border-color: #4a6080;
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(100,150,200,0.2), inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn-off.active {
  background: linear-gradient(145deg, #223040, #101e30);
  border-color: #5a80a0;
  color: var(--text-main);
}

/* ON button */
.btn-on {
  background: linear-gradient(145deg, #0a2a5a, #051530);
  border: 1px solid var(--blue-border);
  color: var(--blue-bright);
  box-shadow: 0 4px 16px rgba(0,50,150,0.4), inset 0 1px 0 rgba(0,170,255,0.1);
}
.btn-on:hover {
  background: linear-gradient(145deg, #103070, #07183a);
  border-color: var(--blue-led);
  box-shadow: 0 0 14px rgba(0,170,255,0.5), 0 0 40px rgba(0,170,255,0.2), inset 0 1px 0 rgba(0,200,255,0.15);
}
.btn-on.active {
  background: linear-gradient(145deg, #1540a0, #0a2560);
  border-color: var(--blue-bright);
  box-shadow: 0 0 20px rgba(0,170,255,0.7), 0 0 60px rgba(0,170,255,0.3);
  animation: btn-glow-blue 1.5s ease-in-out infinite alternate;
}

@keyframes btn-glow-blue {
  from { box-shadow: 0 0 14px rgba(0,170,255,0.5), 0 0 40px rgba(0,170,255,0.2); }
  to   { box-shadow: 0 0 24px rgba(0,170,255,0.8), 0 0 70px rgba(0,170,255,0.4); }
}

/* BLINK button */
.btn-blink {
  background: linear-gradient(145deg, #2a1a00, #180e00);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  box-shadow: 0 4px 16px rgba(150,90,0,0.3), inset 0 1px 0 rgba(255,220,100,0.08);
}
.btn-blink:hover {
  background: linear-gradient(145deg, #3a2400, #201500);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(240,192,64,0.5), 0 0 40px rgba(240,192,64,0.2), inset 0 1px 0 rgba(255,220,100,0.12);
}
.btn-blink.active {
  border-color: var(--gold-light);
  animation: btn-glow-gold 0.5s ease-in-out infinite alternate;
}

@keyframes btn-glow-gold {
  from { box-shadow: 0 0 14px rgba(240,192,64,0.5), 0 0 40px rgba(240,192,64,0.2); }
  to   { box-shadow: 0 0 28px rgba(240,192,64,0.9), 0 0 80px rgba(240,192,64,0.4); }
}

/* Disabled state */
.btn-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Activity Log ─────────────────────────────────────────── */
.log-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 300px;
  border: 1px solid var(--blue-border);
  border-radius: 2px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.log-table th {
  font-family: var(--font-hud);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: uppercase;
  padding: 10px 14px;
  background: rgba(15,30,55,0.9);
  border-bottom: 1px solid var(--blue-border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.log-table td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(26,58,106,0.4);
  color: var(--text-main);
  vertical-align: middle;
  white-space: nowrap;
}

.log-table tr:last-child td { border-bottom: none; }

.log-table tbody tr {
  background: transparent;
  transition: background 0.15s;
}
.log-table tbody tr:hover { background: rgba(30,111,255,0.06); }
.log-table tbody tr:nth-child(even) { background: rgba(10,20,40,0.5); }
.log-table tbody tr:nth-child(even):hover { background: rgba(30,111,255,0.08); }

/* Value pill in log */
.val-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-family: var(--font-hud);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border: 1px solid;
}
.val-0 { color: #6080a0; border-color: #2a4060; background: rgba(10,20,35,0.8); }
.val-1 { color: var(--blue-bright); border-color: var(--blue-led); background: rgba(0,100,200,0.15); }
.val-2 { color: var(--gold); border-color: var(--gold-dark); background: rgba(150,100,0,0.15); }

.log-empty {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 30px !important;
}

/* Row entry animation */
@keyframes row-in {
  from { opacity: 0; transform: translateX(-10px); background: rgba(30,111,255,0.12); }
  to   { opacity: 1; transform: translateX(0);     background: transparent; }
}
.log-new { animation: row-in 0.4s ease forwards; }

/* ── Toast notification ───────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 30px;
  right: 24px;
  background: linear-gradient(135deg, #0a1e3a, #050d1a);
  border: 1px solid var(--blue-border);
  border-left: 3px solid var(--gold);
  color: var(--text-main);
  font-family: var(--font-hud);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 12px 20px;
  border-radius: 2px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(240,192,64,0.2);
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
  max-width: 260px;
}
#toast.show {
  opacity: 1;
  transform: translateY(0);
}
#toast.success { border-left-color: var(--green-ok); }
#toast.error   { border-left-color: var(--red-danger); }

/* ── Sound control ────────────────────────────────────────── */
.sound-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  background: linear-gradient(135deg, #0a1e3a, #050d1a);
  border: 1px solid var(--blue-border);
  color: var(--gold);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(240,192,64,0.25);
  transition: all 0.2s ease;
}
.sound-btn:hover {
  box-shadow: var(--glow-gold);
  transform: scale(1.1);
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 20px 0 10px;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  font-family: var(--font-hud);
}
.footer span { color: var(--gold); }

/* ── Separator line ───────────────────────────────────────── */
.divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue-border), transparent);
  margin: 20px 0;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--blue-deep); }
::-webkit-scrollbar-thumb { background: var(--blue-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-glow); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .wrapper { padding: 12px 10px 50px; }
  .panel   { padding: 20px 16px; }
  .header h1 { font-size: 1.3rem; }
  .controls { grid-template-columns: 1fr; }
  .btn-control { padding: 15px 12px; }
  .status-panel { flex-direction: column; align-items: flex-start; }
  .led-visual { flex-direction: row; }
  .sound-btn { top: 12px; right: 12px; width: 38px; height: 38px; font-size: 1rem; }
}