/**
 * Main stylesheet
 */

/* Brand color palette (derived from the Viaplay header logo) */
:root {
  --brand-pink: #cc0099;
  --brand-red: #ff0000;
  --brand-gradient: linear-gradient(to bottom, var(--brand-red), var(--brand-pink));
  --brand-white: #ffffff;

  --text-color: #333;
  --text-muted: #7f8c8d;
  --bg-color: #f5f5f5;
  --surface: #ffffff;
  --border-color: #ecf0f1;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
}

/* Navigation */
.navbar {
  background: var(--brand-gradient);
  color: var(--brand-white);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(204, 0, 153, 0.25);
}

.nav-brand a {
  color: var(--brand-white);
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: bold;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

.nav-menu a {
  color: var(--brand-white);
  text-decoration: none;
  transition: opacity 0.3s;
}

.nav-menu a:hover {
  opacity: 0.8;
}

[x-cloak] {
  display: none !important;
}

.nav-user {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-user-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--brand-white);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.nav-user-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--brand-white);
}

.nav-user-name {
  color: var(--brand-white);
  font-weight: 500;
}

.nav-user-caret {
  font-size: 0.7rem;
  line-height: 1;
  transition: transform 0.2s;
}

.nav-user-caret.is-open {
  transform: rotate(180deg);
}

.nav-user-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 170px;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(204, 0, 153, 0.2);
  z-index: 100;
}

.nav-user-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  color: var(--text-color);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nav-user-menu-item:hover {
  background: var(--brand-gradient);
  color: var(--brand-white);
}

/* Layout */
main {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.page h1,
.header-actions h1 {
  margin-bottom: 1rem;
}

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 1rem;
  transition: opacity 0.3s;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: var(--brand-gradient);
  color: var(--brand-white);
}

.btn-secondary {
  background-color: var(--text-muted);
  color: var(--brand-white);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--brand-gradient);
  color: var(--brand-white);
  font-weight: 600;
}

/* States */
.loading,
.empty-state {
  padding: 1.5rem;
  color: var(--text-muted);
}

.error {
  padding: 1rem 1.5rem;
  background-color: #fdecea;
  color: #c0392b;
  border-radius: 4px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.pagination-range {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0 0.5rem;
}

.pagination-btn {
  background-color: var(--text-muted);
  color: var(--brand-white);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.3s;
}

.pagination-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.pagination-btn:disabled {
  background-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-color);
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--brand-pink);
  box-shadow: 0 0 0 3px rgba(204, 0, 153, 0.12);
}

/* Auth pages */
.auth-page {
  min-height: calc(100vh - 160px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0;
}

.auth-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text-color);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

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

.error-message {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background-color: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
}

/* Metrics controls */
.controls {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.control select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  background-color: var(--surface);
  color: var(--text-color);
  cursor: pointer;
}

.control select:focus {
  outline: none;
  border-color: var(--brand-pink);
  box-shadow: 0 0 0 3px rgba(204, 0, 153, 0.12);
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem;
  background-color: var(--surface);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-color);
}

/* Per-service median bars */
.bar-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bar-track {
  flex: 1;
  min-width: 60px;
  height: 8px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: 4px;
}

.bar-label {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Utilities */
.text-muted {
  color: var(--text-muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* Deployment detail */
.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.detail-grid dt {
  font-weight: 600;
  color: var(--text-muted);
}

.detail-grid dd {
  margin: 0;
}

.timeline-heading {
  margin-bottom: 1rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  position: relative;
  display: flex;
  gap: 1rem;
  padding: 0 0 1.5rem 1.5rem;
  border-left: 2px solid var(--border-color);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -7px;
  top: 0.25rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-gradient);
}

.timeline-item--pr_opened .timeline-marker,
.timeline-item--pr_merged .timeline-marker {
  background: var(--text-muted);
}

.timeline-body {
  padding-bottom: 0.25rem;
}

.timeline-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.timeline-time {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-white);
}

.badge-success {
  background-color: #27ae60;
}

.badge-danger {
  background-color: #c0392b;
}

/* Profile */
.profile-container {
  max-width: 640px;
}

.profile-card {
  display: flex;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-avatar {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: var(--brand-white);
  font-size: 1.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.profile-details {
  flex: 1;
}

.profile-field {
  margin-bottom: 1.25rem;
}

.profile-field:last-child {
  margin-bottom: 0;
}

.profile-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.profile-field p {
  margin: 0;
  word-break: break-word;
}

.profile-field-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-field-edit {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-field-edit-row {
  display: flex;
  gap: 0.5rem;
}

.profile-name-input {
  flex: 1;
  padding: 0.4rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-name-input:focus {
  outline: none;
  border-color: var(--brand-pink);
  box-shadow: 0 0 0 3px rgba(204, 0, 153, 0.12);
}

.profile-field-error {
  color: #c0392b;
  font-size: 0.85rem;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.profile-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}


