/* =====================================================
   RockSongs Frontend — styles.css
   Plain CSS, no framework.
   ===================================================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  background: #f4f5f7;
  color: #222;
  min-height: 100vh;
}

.login-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at top, #34345a 0, #1a1a2e 45%, #10101d 100%); }
.login-card { width: 100%; max-width: 410px; padding: 32px; border-radius: 14px; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.4); }
.login-mark { font-size: 2.4rem; margin-bottom: 10px; }
.login-card h2 { color: #1a1a2e; font-size: 1.65rem; }
.login-card > p { color: #666; margin: 6px 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 15px; }
.login-submit { justify-content: center; width: 100%; margin-top: 2px; padding: 11px 16px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 8px; background: #eceef4; }
.auth-tab { padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; color: #555; font-weight: 700; cursor: pointer; }
.auth-tab.active { background: #fff; color: #3f51b5; box-shadow: 0 1px 4px rgba(0,0,0,.13); }
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 44px !important; }
.password-toggle { position: absolute; top: 50%; right: 5px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; transform: translateY(-50%); border: 0; border-radius: 5px; background: transparent; color: #606477; cursor: pointer; }
.password-toggle:hover { background: #eceef4; color: #303550; }
.password-toggle:focus-visible { outline: 2px solid #5c6bc0; outline-offset: 1px; }
.password-toggle svg { width: 20px; height: 20px; fill: currentColor; }
.password-toggle.is-visible::after { content: ""; position: absolute; width: 23px; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); }

/* ---------- Site Header / Banner ---------- */
.site-header {
  background: #1a1a2e;
  color: #e8e8ff;
  padding: 18px 24px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.header-inner { max-width: 1100px; margin: 0 auto; position: relative; display: flex; align-items: center; justify-content: center; }
.account-nav { position: absolute; right: 0; display: flex; gap: 8px; }
.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; background: rgba(255,255,255,.08); color: #e8e8ff; cursor: pointer; transition: background .15s, transform .1s; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn.is-login .logout-icon { transform: scaleX(-1); }

.site-header h1 {
  font-size: 1.75rem;
  letter-spacing: 0.03em;
  font-weight: 700;
}

/* ---------- Main Container ---------- */
.container {
  max-width: 900px;
  margin: 28px auto;
  padding: 0 16px;
}

.view-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.view-heading h2 { font-size: 1.6rem; color: #1a1a2e; }
.eyebrow { color: #5c6bc0; text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; font-weight: 800; margin-bottom: 4px; }
.view-subtitle { color: #666; margin-top: 5px; }
.user-table th:nth-child(3) { width: 120px; }
.user-table th:last-child { width: 160px; }
.role-badge { display: inline-block; min-width: 62px; text-align: center; border-radius: 999px; padding: 3px 9px; font-size: .75rem; font-weight: 700; }
.role-admin { color: #3f3a91; background: #e8e7fb; }
.role-basic { color: #455; background: #edf0f0; }
.role-pending { color: #8a5a00; background: #fff1cc; }

/* ---------- Action Row ---------- */
.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-area {
  flex: 1 1 260px;
}

.search-input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.search-input:focus {
  border-color: #5c6bc0;
  box-shadow: 0 0 0 3px rgba(92,107,192,0.15);
}

.action-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

.api-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #ececec;
  color: #444;
  border: 1px solid #d0d0d0;
}

.api-mode-badge.is-mock {
  background: #fff3cd;
  color: #7a5c00;
  border-color: #ffd78a;
}

.api-mode-badge.is-live {
  background: #d7f5dd;
  color: #1f6b2e;
  border-color: #9bd8a7;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #5c6bc0;
  color: #fff;
}

.btn-primary:hover {
  background: #3f51b5;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #bdbdbd;
}

.btn-danger {
  background: #e53935;
  color: #fff;
}

.btn-danger:hover {
  background: #b71c1c;
}

/* ---------- Result Summary ---------- */
.result-summary {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 8px;
  min-height: 1.2em;
}

/* ---------- Table ---------- */
.table-wrapper {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.song-table {
  width: 100%;
  border-collapse: collapse;
}

.song-table thead {
  background: #1a1a2e;
  color: #e8e8ff;
}

.song-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.song-table thead th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}

.song-table thead th[data-sort-key]:hover {
  background: #272743;
}

.song-table thead th.is-sorted {
  background: #323255;
}

.sort-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.72rem;
  opacity: 0.9;
}

.song-table tbody tr {
  border-bottom: 1px solid #eee;
  transition: background 0.15s;
}

.song-table tbody tr.is-clickable,
.user-table tbody tr {
  cursor: pointer;
}

.song-table tbody tr.is-clickable:focus-visible {
  outline: 3px solid rgba(92,107,192,.45);
  outline-offset: -3px;
}

.song-table tbody tr:last-child {
  border-bottom: none;
}

.song-table tbody tr.is-clickable:hover,
.user-table tbody tr:hover {
  background: #eef0fb;
}

.song-table td {
  padding: 10px 14px;
  vertical-align: middle;
  font-size: 0.93rem;
}

.song-table .overplayed-column {
  width: 110px;
  text-align: center;
}

/* Highlight songs marked as overplayed. */
.badge-overplayed {
  display: inline-block;
  font-size: 0.7rem;
  background: #ffecb3;
  color: #7a5c00;
  border-radius: 3px;
  padding: 1px 5px;
  vertical-align: middle;
  font-weight: 600;
}

/* ---------- Empty State ---------- */
.empty-state {
  padding: 32px;
  text-align: center;
  color: #999;
  font-size: 0.95rem;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #fff;
  color: #333;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.page-btn:hover:not(:disabled) {
  background: #eef0fb;
  border-color: #5c6bc0;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-btn.active {
  background: #5c6bc0;
  border-color: #5c6bc0;
  color: #fff;
  font-weight: 700;
}

/* ---------- Modal Overlay ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

/* ---------- Modal Box ---------- */
.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a2e;
  color: #e8e8ff;
  padding: 14px 18px;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close-x {
  background: none;
  border: none;
  color: #e8e8ff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.modal-close-x:hover {
  opacity: 1;
}

/* ---------- Form inside Modal ---------- */
#songForm, .modal-form {
  padding: 20px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.form-group input[type="email"], .form-group input[type="password"], .form-group select { padding: 8px 12px; border: 1px solid #ccc; border-radius: 5px; font-size: .93rem; background: #fff; }
.form-group input:focus, .form-group select:focus { border-color: #5c6bc0; outline: none; box-shadow: 0 0 0 3px rgba(92,107,192,.12); }
.form-group input:read-only { background: #f5f5f5; color: #555; }
.user-modal-box { max-width: 520px; }
.settings-modal-box { max-width: 460px; }
.user-identity { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
.user-identity > div { display: flex; flex-direction: column; gap: 3px; }
.user-identity span:last-child { color: #777; font-size: .84rem; }
.user-avatar { width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: #5c6bc0; font-weight: 800; }
.user-details-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.user-email-field { grid-column: 1 / -1; }
.inline-status { min-height: 1.2em; color: #287a43; font-size: .84rem; }
.inline-status.is-error { color: #b3261e; }
.form-divider { display: flex; align-items: center; gap: 10px; color: #666; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.form-divider::after { content: ""; height: 1px; background: #ddd; flex: 1; }
.split-footer { justify-content: space-between; align-items: center; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
}

.form-group input[type="text"] {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
  border-color: #5c6bc0;
  box-shadow: 0 0 0 3px rgba(92,107,192,0.12);
}

.form-group input[type="text"]:read-only {
  background: #f5f5f5;
  color: #555;
  cursor: default;
}

.form-group--checkbox {
  flex-direction: row;
  align-items: center;
}

.form-group--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.93rem;
  font-weight: normal;
  color: #333;
}

.form-group--checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ---------- Modal Footer ---------- */
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* ---------- Delete Confirm Dialog ---------- */
.confirm-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.3);
  overflow: hidden;
  border: 1px solid #f0d7d7;
}

.confirm-header {
  background: #4a1111;
  color: #ffe7e7;
  padding: 14px 16px;
}

.confirm-header h3 {
  font-size: 1.02rem;
  font-weight: 700;
}

.confirm-body {
  padding: 14px 16px;
}

.confirm-body p {
  color: #4a1f1f;
  font-size: 0.95rem;
  line-height: 1.45;
}

.confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px 16px;
}

/* ---------- Mobile Responsiveness ---------- */
@media (max-width: 600px) {
  .site-header { padding: 10px 8px; }
  .header-inner { justify-content: flex-start; }
  .account-nav { right: 0; }
  .icon-btn { width: 44px; height: 44px; }
  .site-header h1 { max-width: calc(100% - 156px); }
  .site-header h1 {
    font-size: 1.15rem;
    line-height: 1.2;
  }

  .container { margin: 18px auto; padding: 0 10px; }

  .login-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .login-card { margin: auto 0; padding: 22px 18px; }

  .search-input,
  .form-group input[type="text"],
  .form-group input[type="email"],
  .form-group input[type="password"],
  .form-group select {
    font-size: 16px;
  }

  .btn { min-height: 44px; }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-buttons {
    justify-content: flex-end;
  }

  .song-table th:nth-child(3),
  .song-table td:nth-child(3) {
    display: none; /* Hide Album column on small screens */
  }

  #songTable { table-layout: fixed; }
  #songTable th,
  #songTable td { padding: 9px 8px; overflow-wrap: anywhere; }
  #songTable .overplayed-column { width: 82px; }

  .user-table th:nth-child(3),
  .user-table td:nth-child(3) {
    display: table-cell; /* Keep Role visible in the user table */
  }

  .user-table { table-layout: fixed; }
  .user-table th,
  .user-table td { padding: 9px 7px; overflow-wrap: anywhere; }
  .user-table th:first-child { width: 27%; }
  .user-table th:nth-child(2) { width: 48%; }
  .user-table th:nth-child(3) { width: 25%; }
  .role-badge { min-width: 0; padding: 3px 6px; }

  .modal-box {
    max-width: 100%;
    max-height: calc(100dvh - 24px);
  }
  .modal-overlay { padding: 12px; }
  .modal-header { padding: 10px 12px; }
  .modal-header h2 { min-width: 0; overflow-wrap: anywhere; }
  .modal-close-x { min-width: 44px; min-height: 44px; }
  #songForm, .modal-form { padding: 16px 14px 14px; }
  .view-heading { flex-direction: column; }
  .user-details-grid { grid-template-columns: 1fr; }
  .user-email-field { grid-column: auto; }
  .user-table th:last-child, .user-table td:last-child { display: none; }
  .split-footer { align-items: stretch; flex-direction: column; }
  .split-footer > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .split-footer .btn { justify-content: center; padding-inline: 8px; white-space: normal; }
  .confirm-footer .btn { min-height: 44px; }
}
