/* ===================================================
   JOSAN – Motor Control Panel — style.css
   =================================================== */

:root {
  --bg-deep:    #0a0c14;
  --bg-card:    #11141f;
  --bg-card2:   #161929;
  --border:     rgba(255,255,255,0.06);
  --border-glow:rgba(110,231,247,0.25);

  --cyan:   #6EE7F7;
  --violet: #A78BFA;
  --pink:   #F472B6;
  --green:  #34D399;
  --orange: #FB923C;

  --text-primary:   #E8EAF6;
  --text-secondary: #7B82A0;
  --text-muted:     #454966;

  --sidebar-w: 240px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow: 0 8px 32px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 30px rgba(110,231,247,0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Screens ───────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute; inset: 0;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: float 8s ease-in-out infinite;
}
.orb-1 { width: 400px; height: 400px; background: var(--violet); top: -100px; left: -120px; animation-delay: 0s; }
.orb-2 { width: 350px; height: 350px; background: var(--cyan);   bottom: -80px; right: -80px; animation-delay: 3s; }
.orb-3 { width: 280px; height: 280px; background: var(--pink);   top: 50%; left: 60%; animation-delay: 1.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-24px) scale(1.04); }
}

.login-card {
  position: relative; z-index: 1;
  background: rgba(17,20,31,0.85);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow), var(--shadow-glow);
  animation: slideUp 0.5s ease-out;
}

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

.login-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon {
  display: inline-flex;
  width: 72px; height: 72px;
  margin-bottom: 0.75rem;
  animation: spin-slow 12s linear infinite;
}
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.logo-icon.small { width: 32px; height: 32px; animation: none; }
.logo-title { font-size: 2rem; font-weight: 800; letter-spacing: 4px; background: linear-gradient(135deg, var(--cyan), var(--violet)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-subtitle { font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }

.login-form { display: flex; flex-direction: column; gap: 1.1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

.input-wrapper {
  position: relative;
  display: flex; align-items: center;
}
.input-icon {
  position: absolute; left: 14px;
  font-size: 0.9rem; color: var(--text-muted);
  pointer-events: none;
}
.input-wrapper input {
  width: 100%;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrapper input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(110,231,247,0.12);
}

.login-error { font-size: 0.82rem; color: var(--pink); }
.hidden { display: none !important; }

.login-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.login-hint strong { color: var(--cyan); }

/* ── Primary Button ── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  border: none; border-radius: var(--radius-sm);
  color: #0a0c14; font-family: inherit; font-size: 0.95rem; font-weight: 700;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(110,231,247,0.25);
  width: 100%;
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 6px 28px rgba(110,231,247,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.full-width { width: 100%; margin-top: 0.5rem; }

.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #0a0c14;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════
   DASHBOARD LAYOUT
══════════════════════════════════════════════════ */
#dashboard-screen {
  min-height: 100vh;
  flex-direction: row;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.5rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1rem; font-weight: 800; letter-spacing: 3px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}
.nav-item .nav-icon { font-size: 1.1rem; }
.nav-item:hover { background: rgba(110,231,247,0.06); color: var(--text-primary); }
.nav-item.active { background: linear-gradient(90deg, rgba(110,231,247,0.12), rgba(167,139,250,0.08)); color: var(--cyan); border-left: 3px solid var(--cyan); padding-left: calc(1rem - 3px); }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.75rem;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #0a0c14;
  flex-shrink: 0;
}
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 0.72rem; color: var(--text-muted); }
.btn-logout {
  margin-left: auto;
  background: none; border: none;
  font-size: 1.1rem; cursor: pointer;
  color: var(--text-muted); transition: color 0.2s;
}
.btn-logout:hover { color: var(--pink); }

/* ── Main Content ── */
.main-content {
  flex: 1;
  display: flex; flex-direction: column;
  overflow-y: auto;
  min-height: 100vh;
}

.main-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(10,12,20,0.85);
  backdrop-filter: blur(16px);
  z-index: 10;
}
.main-header h2 { font-size: 1.3rem; font-weight: 700; }
.header-subtitle { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.header-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-secondary); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); transition: background 0.4s; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: var(--pink); }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--green); }
  50%       { box-shadow: 0 0 14px var(--green); }
}

/* ── Views ── */
.view { display: none; padding: 2rem; }
.view.active { display: block; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--border-glow); transform: translateY(-2px); }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 0.5rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--cyan); }
.stat-value small { font-size: 0.7rem; color: var(--text-secondary); }

/* ── Control Grid ── */
.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) { .control-grid { grid-template-columns: 1fr; } }

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.full-card { width: 100%; }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.card-desc { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 1.5rem; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* ── Motor Visual ── */
.motor-visual {
  display: flex; align-items: center; justify-content: center;
  margin: 1.5rem 0;
}
.motor-ring {
  position: relative;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 3px solid transparent;
  background: linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
              linear-gradient(135deg, var(--cyan), var(--violet)) border-box;
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow 0.3s;
}
.motor-ring.spinning-cw { animation: rotateCW 0.6s linear infinite; box-shadow: 0 0 24px rgba(110,231,247,0.3); }
.motor-ring.spinning-ccw { animation: rotateCCW 0.6s linear infinite; box-shadow: 0 0 24px rgba(167,139,250,0.3); }
@keyframes rotateCW  { to { transform: rotate(360deg); } }
@keyframes rotateCCW { to { transform: rotate(-360deg); } }
.motor-arrow {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-size: 1.3rem;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.motor-center-dot {
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 12px rgba(110,231,247,0.4);
}

/* ── Direction Buttons ── */
.direction-btns {
  display: flex; gap: 1rem; align-items: center; justify-content: center;
}
.btn-direction {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.4rem;
  color: var(--text-primary); font-family: inherit; font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.btn-direction:hover { background: rgba(110,231,247,0.08); border-color: var(--cyan); transform: scale(1.04); }
.btn-direction:active { transform: scale(0.97); }
.dir-icon { font-size: 1.6rem; }

.btn-stop {
  background: linear-gradient(135deg, var(--pink), #EF4444);
  border: none; border-radius: 50%;
  width: 64px; height: 64px;
  color: #fff; font-family: inherit; font-size: 0.7rem; font-weight: 800;
  cursor: pointer; letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(244,114,182,0.35);
  transition: transform 0.15s, box-shadow 0.2s;
}
.btn-stop:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(244,114,182,0.5); }
.btn-stop:active { transform: scale(0.95); }

/* ── Config ── */
.config-group { margin-bottom: 1.3rem; }
.config-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.6rem; }
.config-group label strong { color: var(--cyan); }

.slider {
  -webkit-appearance: none;
  width: 100%; height: 5px;
  border-radius: 99px;
  background: var(--bg-card2);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  cursor: pointer;
  box-shadow: 0 0 8px rgba(110,231,247,0.4);
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.slider-labels {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--text-muted); margin-top: 4px;
}

/* ── Presets ── */
.preset-btns {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.btn-preset {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem;
  color: var(--text-secondary); font-family: inherit; font-size: 0.78rem; font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-preset:hover { background: rgba(167,139,250,0.1); border-color: var(--violet); color: var(--violet); }

/* ── API Response ── */
.api-response {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem; font-family: monospace;
  border: 1px solid var(--border);
  word-break: break-all;
}
.api-response.success { border-color: rgba(52,211,153,0.3); color: var(--green); background: rgba(52,211,153,0.06); }
.api-response.error   { border-color: rgba(244,114,182,0.3); color: var(--pink); background: rgba(244,114,182,0.06); }

/* ── Log ── */
.log-container { display: flex; flex-direction: column; gap: 0.5rem; max-height: 480px; overflow-y: auto; }
.log-empty { color: var(--text-muted); font-size: 0.85rem; }
.log-entry {
  display: flex; align-items: flex-start; gap: 0.75rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform:translateY(0); } }
.log-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }
.log-content { flex: 1; }
.log-title { font-size: 0.85rem; font-weight: 600; }
.log-detail { font-size: 0.75rem; color: var(--text-secondary); }
.log-badge { font-size: 0.68rem; padding: 2px 8px; border-radius: 99px; font-weight: 700; white-space: nowrap; align-self: center; }
.log-badge.ok  { background: rgba(52,211,153,0.12); color: var(--green); }
.log-badge.err { background: rgba(244,114,182,0.12); color: var(--pink); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.8rem;
  color: var(--text-secondary); font-family: inherit; font-size: 0.78rem;
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: var(--pink); color: var(--pink); }

/* ── API Status View ── */
.api-info { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.2rem; }
.api-info-row { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.api-info-label { font-size: 0.78rem; color: var(--text-secondary); min-width: 120px; padding-top: 2px; }
.api-info-value { font-size: 0.82rem; font-family: monospace; color: var(--cyan); word-break: break-all; }

.badge {
  font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 99px;
  background: var(--bg-card2); color: var(--text-secondary);
}
.badge-purple { background: rgba(167,139,250,0.12); color: var(--violet); }
.badge-green  { background: rgba(52,211,153,0.12);  color: var(--green); }
.badge-red    { background: rgba(244,114,182,0.12);  color: var(--pink); }

.raw-response {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.78rem; font-family: monospace;
  color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-all;
  max-height: 220px; overflow-y: auto;
  flex: 1;
}
