/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --olymp-bg-from: #418587;
  --olymp-bg-to: #43486a;
  --olymp-ink: #324b4c;
  --olymp-muted: #75789e;
  --olymp-border: #95b0b1;
  --olymp-surface: #ffffff;
  --olymp-shadow: 0 20px 45px -15px rgba(31, 41, 55, 0.35);
  --olymp-radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--olymp-ink);
  background: linear-gradient(135deg, var(--olymp-bg-from), var(--olymp-bg-to));
  -webkit-font-smoothing: antialiased;
}

/* Centered single-card layouts (login & home) */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--olymp-surface);
  border-radius: var(--olymp-radius);
  box-shadow: var(--olymp-shadow);
  padding: 40px 36px;
  text-align: center;
}

.auth-logo {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--olymp-bg-from), var(--olymp-bg-to));
  color: #fff;
  box-shadow: 0 10px 20px -8px rgba(65, 133, 135, 0.6);
}

/* The bolt SVG. The two stacked paths inside it carry the whole animation:
   the stroke prints the outline, then the fill fades in with one soft flash
   and hands off to a slow ambient glow. */
.logo-mark {
  position: relative;
  z-index: 1;
  display: block;
  width: 34px;
  height: 34px;
}

/* Stroke prints the bolt's outline. pathLength="100" on the SVG normalises the
   dash math, so the offset travels the full path regardless of its real length. */
.logo-bolt-stroke {
  fill: transparent;
  stroke: #ffd66b;
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: bolt-draw 0.85s ease-in-out both;
}

/* Fill fades in once the outline is mostly printed, peaks in one soft flash,
   then settles into the resting glow that bolt-breathe carries on from. */
.logo-bolt-fill {
  fill: url(#olymp-bolt-gold);
  opacity: 0;
  animation:
    bolt-fill 0.7s ease-out 0.7s both,
    bolt-breathe 6s ease-in-out 1.6s infinite;
}

/* Print the outline. */
@keyframes bolt-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Fade the gold in with a single soft white-gold flash, then settle. */
@keyframes bolt-fill {
  0% {
    opacity: 0;
    filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  }
  55% {
    opacity: 1;
    filter: brightness(1.8) drop-shadow(0 0 12px rgba(255, 245, 200, 0.95));
  }
  100% {
    opacity: 1;
    filter: drop-shadow(0 0 5px rgba(255, 214, 107, 0.45));
  }
}

/* Steady state: a slow breathing glow — the bolt quietly "charged". */
@keyframes bolt-breathe {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(255, 214, 107, 0.35));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(255, 224, 140, 0.85));
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo-bolt-stroke {
    animation: none;
    stroke-dashoffset: 0;
    stroke: transparent;
  }
  .logo-bolt-fill {
    animation: none;
    opacity: 1;
    filter: drop-shadow(0 0 5px rgba(255, 214, 107, 0.45));
  }
}

.auth-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  margin: 0 0 28px;
  color: var(--olymp-muted);
  font-size: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.2s ease,
    background-color 0.2s ease, border-color 0.2s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-google {
  background: #ffffff;
  color: #3c4043;
  border-color: var(--olymp-border);
  box-shadow: 0 1px 2px rgba(31, 41, 55, 0.08);
}

.btn-google:hover {
  background: #f8f9fb;
  box-shadow: 0 2px 6px rgba(31, 41, 55, 0.12);
}

.btn-google svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-secondary {
  background: #f3f4f6;
  color: var(--olymp-ink);
  border-color: var(--olymp-border);
}

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

/* button_to renders a <form> wrapper — make it lay out like the button */
.auth-card form.button_to {
  margin: 0;
}

/* Signed-in identity block */
.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 28px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
  border: 2px solid var(--olymp-border);
}

.profile-avatar--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--olymp-bg-from), var(--olymp-bg-to));
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
}

.profile-email {
  font-size: 14px;
  color: var(--olymp-muted);
}

/* Flash messages */
.flash {
  margin-bottom: 20px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  text-align: left;
}

.flash-alert {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.flash-notice {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* ===== Service picker (landing) ===== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 8px 0 28px;
}

.service-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 12px;
  border-radius: 14px;
  border: 1px solid var(--olymp-border);
  background: var(--olymp-surface);
  color: var(--olymp-ink);
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

a.service-btn:hover {
  transform: translateY(-2px);
  border-color: var(--olymp-bg-from);
  box-shadow: var(--olymp-shadow);
}

.service-icon {
  font-size: 26px;
  line-height: 1;
}

.service-name {
  font-size: 15px;
  font-weight: 600;
}

.service-desc {
  font-size: 12px;
  color: var(--olymp-muted);
}

.service-btn--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Service still in development: muted, but a working link — unlike --disabled,
   which is for tiles that cannot be opened at all. */
.service-btn--wip {
  opacity: 0.6;
}

a.service-btn--wip:hover {
  opacity: 0.85;
}

.service-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--olymp-muted);
  background: #f3f4f6;
  border-radius: 8px;
  padding: 1px 7px;
}

/* Compact identity row under the service grid */
.profile--compact {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 0;
  padding-top: 18px;
  border-top: 1px solid var(--olymp-border);
}

.profile--compact .profile-avatar {
  width: 32px;
  height: 32px;
  margin-bottom: 0;
  font-size: 15px;
}

.flash code {
  font-size: 13px;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 5px;
}

/* Wide admin pages (users list & permissions form) */
.page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px;
}

.page-card {
  width: 100%;
  max-width: 760px;
  background: var(--olymp-surface);
  border-radius: var(--olymp-radius);
  box-shadow: var(--olymp-shadow);
  padding: 32px 36px 40px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-back {
  color: var(--olymp-muted);
  font-size: 14px;
  text-decoration: none;
}

.page-back:hover {
  color: var(--olymp-ink);
}

/* Buttons that should size to content, not stretch full-width */
.btn-inline {
  width: auto;
}

.btn-primary {
  background: var(--olymp-ink);
  color: #fff;
  border-color: var(--olymp-ink);
}

.btn-primary:hover {
  background: #263b3c;
}

/* Users search */
.users-search {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.users-search-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--olymp-border);
  font-size: 15px;
  color: var(--olymp-ink);
}

.users-search-input:focus {
  outline: none;
  border-color: var(--olymp-bg-from);
  box-shadow: 0 0 0 3px rgba(65, 133, 135, 0.15);
}

/* Users table */
.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--olymp-muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid #eef0f4;
}

.users-table td {
  padding: 12px;
  border-bottom: 1px solid #eef0f4;
  font-size: 15px;
  vertical-align: middle;
}

.users-col-avatar {
  width: 48px;
}

.users-col-count {
  text-align: right;
  white-space: nowrap;
}

.users-row {
  position: relative;
}

.users-row:hover {
  background: #f8fafa;
}

/* Stretched link makes the entire row clickable while staying a real <a>. */
.users-row-link {
  color: var(--olymp-ink);
  font-weight: 600;
  text-decoration: none;
}

.users-row-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.users-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.users-avatar--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--olymp-bg-from), var(--olymp-bg-to));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}

.users-empty {
  color: var(--olymp-muted);
  font-size: 15px;
  text-align: center;
  padding: 32px 0;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 22px;
  font-size: 14px;
}

.pagination-link {
  color: var(--olymp-ink);
  text-decoration: none;
  font-weight: 600;
}

.pagination-link--disabled {
  color: var(--olymp-border);
  font-weight: 500;
}

.pagination-info {
  color: var(--olymp-muted);
}

/* Permissions form */
.perm-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #f8fafa;
  border-radius: 12px;
  margin-bottom: 20px;
}

.perm-user-name {
  font-size: 16px;
  font-weight: 600;
}

.perm-user-email {
  font-size: 14px;
  color: var(--olymp-muted);
}

.perm-group {
  margin-bottom: 24px;
}

.perm-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eef0f4;
}

.perm-group-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--olymp-muted);
}

.perm-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--olymp-muted);
  cursor: pointer;
  white-space: nowrap;
}

.perm-group-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--olymp-bg-from);
  cursor: pointer;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  cursor: pointer;
}

.perm-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--olymp-bg-from);
  cursor: pointer;
}

.perm-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.perm-item-label {
  font-size: 15px;
  font-weight: 500;
}

.perm-item-key {
  font-size: 12px;
  color: var(--olymp-muted);
}

.perm-actions {
  margin-top: 8px;
}

.page-title--centered {
  text-align: center;
}

.terminator-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.btn--compact {
  border-radius: 8px;
  padding: 8px 16px;
}

.btn--underline {
  text-decoration: underline;
}
