:root {
  --bg-1: #0c0c0c;
  --bg-2: #1a1a1a;
  --card: #1f1f1f;
  --ink: #f4f4f4;
  --muted: #b0a79e;
  --accent: #f56a1c;
  --accent-strong: #d75710;
  --line: #2a2a2a;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Gill Sans", "Gill Sans MT", "Trebuchet MS", sans-serif;
  background: var(--bg-1);
}

html, body {
  width: 100%;
  overflow-x: hidden;
  background: var(--bg-1);
}

h1, h2, .title {
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  letter-spacing: 0.2px;
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background: var(--bg-1);
}

.bg-gradient {
  position: absolute;
  inset: -40vh -10vw auto -10vw;
  height: 70vh;
  background: radial-gradient(circle at 20% 20%, rgba(245, 106, 28, 0.35) 0%, rgba(245, 106, 28, 0) 60%),
              radial-gradient(circle at 80% 10%, rgba(255, 159, 64, 0.25) 0%, rgba(255, 159, 64, 0) 60%),
              linear-gradient(135deg, var(--bg-1), var(--bg-2));
  z-index: -1;
}

.page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.04), transparent 40%);
  pointer-events: none;
  z-index: -2;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 10vw 10px;
}

.topbar.compact {
  padding: 18px 6vw 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.title {
  font-size: 20px;
  font-weight: 700;
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 20px 10vw 60px;
}

.cameras-layout,
.admin-layout {
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 2fr);
}

.cameras-feed {
  padding: 12px 6vw 40px;
  max-width: 980px;
  margin: 0 auto;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  animation: rise 0.6s ease both;
  overflow: visible;
}

.panel.info {
  align-self: start;
}

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

.form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.form.inline {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input, select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 15px;
  background: #2b2b2b;
  color: var(--ink);
}

input:focus, select:focus {
  outline: 2px solid rgba(245, 106, 28, 0.25);
  border-color: var(--accent);
}

.field-error {
  color: #ff6b6b;
  min-height: 18px;
  font-size: 12px;
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  inset: calc(100% + 6px) 0 auto 0;
  background: #1d1d1d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  display: none;
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-list.open {
  display: grid;
  gap: 6px;
}

.autocomplete-item {
  background: #2b2b2b;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.autocomplete-item:hover {
  border-color: rgba(245, 106, 28, 0.4);
}

button, .ghost, .primary {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.form-note {
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.list {
  padding-left: 18px;
  margin: 18px 0 0;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.panel-header,
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.camera-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.camera-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
  background: #232323;
}

.camera-cards {
  display: grid;
  gap: 18px;
}

.camera-card.media {
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
}

.card-media {
  position: relative;
  background: #0b0b0b;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-media iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}

.card-embed {
  opacity: 0.95;
  filter: saturate(1.05) contrast(1.05);
}

.card-placeholder {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1), transparent 60%),
              linear-gradient(120deg, #1d1d1d, #2a2a2a);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
}


.card-live {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #f56a1c;
  color: #fff;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.4px;
  z-index: 2;
  box-shadow: 0 0 0 6px rgba(245, 106, 28, 0.15);
  animation: pulse 1.6s infinite;
}

.card-meta {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
  z-index: 2;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.card-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.card-action {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 12px;
  white-space: nowrap;
}

.camera-card:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 106, 28, 0.4);
}

.camera-card.media:hover {
  transform: none;
}

.camera-card.media:hover .card-media {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.card-media {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.camera-card.active {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(245, 106, 28, 0.2);
}

.player-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-top: 18px;
  background: #111;
  min-height: 260px;
}

.player-frame {
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  position: relative;
  transform-origin: center;
  transition: transform 0.2s ease;
}

.player-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

.live-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #f56a1c;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.4px;
  z-index: 2;
}

.player-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 16px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  text-align: center;
}

.auth-badge {
  width: fit-content;
  margin: 0 auto 16px;
  padding: 6px 12px;
  background: #2c2c2c;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.4px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.link {
  display: block;
  margin-top: 14px;
  color: var(--accent);
}

.error-box {
  background: rgba(255, 82, 82, 0.15);
  border: 1px solid rgba(255, 82, 82, 0.3);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.success-box {
  background: rgba(52, 199, 89, 0.15);
  border: 1px solid rgba(52, 199, 89, 0.3);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-wrap th,
.table-wrap td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
}

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.92);
  display: none;
  flex-direction: column;
  padding: 16px;
  z-index: 20;
  backdrop-filter: blur(6px);
}

.viewer.open {
  display: flex;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.viewer-title {
  font-size: 18px;
  font-weight: 700;
}

.viewer-sub {
  font-size: 13px;
  color: var(--muted);
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewer-surface {
  flex: 1;
  display: grid;
  place-items: center;
  margin-top: 16px;
}

.viewer-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #000;
  touch-action: none;
}

@media (orientation: landscape) {
  .viewer-bar,
  .hint {
    display: none;
  }

  .viewer {
    padding: 0;
  }

  .viewer-wrap {
    border-radius: 0;
    border: none;
  }
}

.viewer-frame {
  width: 100%;
  height: 100%;
  transform-origin: center;
  transition: transform 0.15s ease;
}

.viewer-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

/* sem rotacao no viewer */

.viewer.open {
  animation: viewerFade 0.2s ease;
}

@keyframes viewerFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 106, 28, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(245, 106, 28, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 106, 28, 0); }
}

@media (max-width: 980px) {
  .topbar {
    padding: 20px 6vw 10px;
  }

  .layout {
    padding: 10px 6vw 50px;
  }

  .cameras-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .panel {
    padding: 20px;
  }

  .player-actions {
    width: 100%;
    justify-content: space-between;
  }

  .viewer {
    padding: 12px;
  }
}

/* Signup page */
.signup-page {
  background: #0f0f10;
  color: #1c1c1c;
}

.signup-bg {
  position: fixed;
  inset: 0;
  background: var(--brand-bg) center/cover no-repeat, linear-gradient(120deg, #ff8a3d, #f2631b);
  filter: saturate(1.05);
  z-index: -2;
}

.signup-glow {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 10%, rgba(255, 255, 255, 0.25), transparent 50%),
              radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.18), transparent 55%);
  mix-blend-mode: screen;
  z-index: -1;
  animation: floatGlow 10s ease-in-out infinite;
}

@keyframes floatGlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.signup-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px 48px;
}

.signup-card {
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: 22px;
  padding: 28px 22px 24px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: rise 0.6s ease both;
}

.signup-brand img {
  max-width: 180px;
  height: auto;
  margin: 0 auto 12px;
  display: block;
}

.signup-brand .logo.fallback {
  display: none;
  width: 84px;
  height: 84px;
  margin: 0 auto 12px;
  border-radius: 24px;
  background: #f2631b;
  color: #fff;
  font-weight: 800;
  font-size: 28px;
  place-items: center;
}

.signup-title {
  font-size: 18px;
  font-weight: 700;
  color: #1b1b1b;
  margin-bottom: 6px;
}

.signup-subtitle {
  font-size: 14px;
  color: #666;
  margin-bottom: 18px;
}

.signup-form {
  display: grid;
  gap: 10px;
}

.input-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  background: #f7f7f9;
  border: 1px solid #e4e4ea;
  border-radius: 14px;
  padding: 10px 12px;
}

.input-row input {
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 15px;
  outline: none;
}

.input-icon {
  font-size: 18px;
  color: #f2631b;
}

.signup-form .field-error {
  text-align: left;
  padding-left: 6px;
  margin-top: -4px;
}

.signup-page .autocomplete-list {
  background: #fff;
  border: 1px solid #e4e4ea;
  color: #222;
  z-index: 60;
}

.signup-page .autocomplete-item {
  background: #f7f7f9;
  color: #222;
  border: 1px solid transparent;
}

.signup-page .autocomplete-item:hover {
  border-color: rgba(242, 99, 27, 0.5);
}

.terms {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  background: #f7f7f9;
  border: 1px solid #e4e4ea;
  border-radius: 14px;
  padding: 12px;
  color: #444;
}

.terms input {
  width: 16px;
  height: 16px;
}

.terms a {
  color: #f2631b;
  font-weight: 600;
}

.signup-button {
  margin-top: 8px;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  background: linear-gradient(90deg, #f2631b, #f7b02b);
  border: none;
}

.signup-footer {
  margin-top: 16px;
  font-size: 12px;
  color: #7a7a7a;
  background: #f2f2f6;
  border-radius: 14px;
  padding: 10px 12px;
}

.terms-page {
  background: #121212;
  color: #f4f4f4;
}

.terms-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.terms-card {
  width: min(720px, 100%);
  background: #1c1c1c;
  border-radius: 16px;
  padding: 28px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.terms-card h1 {
  margin-top: 0;
}

.terms-card h2 {
  margin-top: 20px;
}

@media (max-width: 480px) {
  .signup-card {
    padding: 22px 18px;
  }

  .signup-title {
    font-size: 16px;
  }
}

.signup-form .input-row {
  align-items: stretch;
}

.input-field {
  display: grid;
  gap: 2px;
}

.input-label {
  font-size: 12px;
  color: #6d6d6d;
  text-align: left;
}

.link-button {
  background: none;
  border: none;
  color: #f2631b;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  position: relative;
  max-width: 560px;
  width: calc(100% - 32px);
  background: #ffffff;
  color: #1c1c1c;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  z-index: 2;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-card h2 {
  margin-top: 0;
}

.modal-card h3 {
  margin-top: 18px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: #f2f2f6;
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 480px) {
  .modal-card {
    padding: 20px;
  }
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.modal-accept {
  padding: 12px 16px;
  border-radius: 12px;
}

.signup-card {
  display: grid;
  gap: 8px;
}

.signup-form {
  gap: 14px;
}

.input-row {
  background: #ffffff;
  border: 1px solid #e8e8ef;
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.06);
  align-items: center;
  padding: 12px 14px;
}

.input-row:focus-within {
  border-color: #f2631b;
  box-shadow: 0 0 0 3px rgba(242, 99, 27, 0.15);
}

.input-field {
  width: 100%;
}

.input-label {
  font-size: 12px;
  color: #8a8a8a;
  text-align: left;
}

.input-row input {
  color: #1b1b1b;
  font-weight: 600;
  text-align: left;
  padding: 6px 0 6px;
  height: 24px;
}

.input-row input::placeholder {
  color: #b9b9c0;
  font-weight: 400;
}

.signup-form .field-error {
  margin-top: -8px;
  font-size: 12px;
  color: #d11f1f;
}

@media (max-width: 480px) {
  .input-row {
    padding: 12px 12px;
  }
}

.input-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.input-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f2631b;
  color: #fff;
  display: grid;
  place-items: center;
}

.modal-accept {
  position: relative;
  overflow: hidden;
}

.modal-accept::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0.15), rgba(255,255,255,0));
  transform: translateX(-100%);
  animation: shimmer 2.2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  60% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

.card-placeholder {
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 60%),
              linear-gradient(120deg, rgba(242, 99, 27, 0.35), rgba(15, 15, 16, 0.6));
}

.terms {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: #f7f7f9;
  border: 1px solid #e4e4ea;
  border-radius: 14px;
  padding: 14px 12px;
}

.terms input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.terms-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #f2631b;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 22px;
}

.terms-check::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f2631b;
  transform: scale(0);
  transition: transform 0.2s ease;
}

.terms input:checked + .terms-check::after {
  transform: scale(1);
}

.terms input:checked + .terms-check {
  animation: pulseCheck 0.6s ease;
  box-shadow: 0 0 0 6px rgba(242, 99, 27, 0.15);
}

@keyframes pulseCheck {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.terms-text {
  font-size: 13px;
  color: #444;
}

/* Signup overrides for alignment */
.signup-page .input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 14px;
}

.signup-page .input-icon {
  flex: 0 0 36px;
}

.signup-page .input-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.signup-page .autocomplete-list {
  text-align: left;
  width: 100%;
  margin-top: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.signup-page .autocomplete-item {
  width: 100%;
}
