:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --bg-card: #020617;
  --border: #1e293b;
  --accent: #3b82f6;
  --accent-soft: rgba(59,130,246,0.15);
  --accent-strong: #2563eb;
  --text: #e5e7eb;
  --text-soft: #9ca3af;
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,0.18);
  --radius: 10px;
  --shadow: 0 14px 30px rgba(0,0,0,0.4);
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%);
  color: var(--text);
}

/* GENERAL UTIL */

.hidden { display: none !important; }
.muted { color: var(--text-soft); font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.4rem; }

/* LOGIN */

.full-screen {
  min-height: 100vh;
  display: flex;
}

.centered {
  justify-content: center;
  align-items: center;
}

.card {
  background: radial-gradient(circle at top left, #111827 0, #020617 55%);
  border-radius: 18px;
  padding: 24px 24px 28px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
  border: 1px solid rgba(148,163,184,0.25);
}

.card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.card form {
  margin-top: 1.3rem;
}

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

input[type="password"],
input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(15,23,42,0.9);
  padding: 0.5rem 0.65rem;
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background: #020617;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* BUTTONS */

.btn {
  border-radius: 999px;
  border: none;
  padding: 0.5rem 0.95rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  box-shadow: 0 10px 25px rgba(59,130,246,0.35);
}

.btn.primary:hover {
  background: linear-gradient(135deg, var(--accent-strong), #1d4ed8);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(148,163,184,0.5);
  color: var(--text-soft);
}

.btn.ghost:hover {
  background: rgba(15,23,42,0.75);
}

.btn.danger {
  background: var(--danger);
  color: white;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
}

.btn.full {
  width: 100%;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.1rem;
}

/* TOPBAR */

#main-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(148,163,184,0.25);
  background: rgba(15,23,42,0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tab-btn {
  border-radius: 999px;
  border: none;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  background: transparent;
  color: var(--text-soft);
  transition: background 0.12s ease, color 0.12s ease;
}

.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* CONTENT */

.content {
  flex: 1;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto 2rem;
  width: 100%;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  gap: 0.5rem;
}

.tab-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

/* actions for logs header */
.logs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

/* TABLES */

.table-wrapper {
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(15,23,42,0.9);
  box-shadow: 0 18px 40px rgba(15,23,42,0.65);
  /* key change: allow horizontal scroll instead of cutting off */
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: rgba(15,23,42,0.98);
}

th, td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(30,64,175,0.25);
}

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-soft);
}

tbody tr:nth-child(odd) {
  background: rgba(15,23,42,0.9);
}

tbody tr:nth-child(even) {
  background: rgba(15,23,42,0.95);
}

tbody tr:hover {
  background: rgba(30,64,175,0.2);
}

/* LOGS + SHOTS */

.logs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem;
}

.logs-panel,
.shots-panel {
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(15,23,42,0.9);
  box-shadow: 0 18px 40px rgba(15,23,42,0.65);
  padding: 0.75rem 0.9rem;
}

.logs-panel h3,
.shots-panel h3 {
  margin-top: 0;
  font-size: 1rem;
}

#logs-view {
  margin: 0;
  padding: 0.55rem 0.6rem;
  max-height: 400px;
  overflow: auto;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.75rem;
  border-radius: 9px;
  border: 1px solid rgba(30,64,175,0.5);
}

.shots-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow: auto;
}

.shot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(30,64,175,0.4);
  font-size: 0.8rem;
}

/* make the text take remaining space and allow it to shrink */
.shot-path {
  flex: 1;
  min-width: 0;              /* important for ellipsis in flex */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* target the buttons container (second div in .shot-item) */
.shot-item > div:last-child {
  display: flex;
  flex-shrink: 0;            /* do not shrink buttons */
  gap: 0.35rem;
}

/* MODAL */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;           /* add space around dialog */
  overflow-y: auto;        /* allow scrolling when modal is taller than screen */
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;        /* never exceed viewport height */
  overflow-y: auto;        /* scroll inside modal if content is too tall */
  background: radial-gradient(circle at top left, #111827 0, #020617 60%);
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,0.3);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem 1rem;
}

/* optional: on very small screens, stick the modal to the top instead of perfect centering */
@media (max-width: 600px) {
  .modal-backdrop {
    align-items: flex-start;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.modal-footer {
  margin-top: 0.9rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* RESPONSIVE */

@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .content {
    padding: 0.7rem;
  }

  th, td {
    padding: 0.4rem 0.45rem;
  }

  /* keep tables scrollable instead of squashing */
  table {
    min-width: 720px; /* adjust if you want tighter */
  }

  .logs-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal {
    max-width: 95%;
  }
}

@media (max-width: 480px) {
  .tab-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tab-header h2 {
    margin-bottom: 0.3rem;
  }

  .logs-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
