/*
 * 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 {
  --blue-900: #0b2a5b;
  --blue-800: #123d7e;
  --blue-700: #1a56b0;
  --blue-600: #2563d9;
  --blue-100: #dbe7fb;
  --blue-50: #eef4fd;

  --text: #1b2433;
  --muted: #5b6678;
  --border: #d5dde9;
  --surface: #ffffff;
  --background: #f4f7fb;

  --success-bg: #e5f5ec;
  --success-text: #17603a;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --warning-bg: #fff6e0;
  --warning-text: #7a5300;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 40 80 / 6%), 0 4px 16px rgb(16 40 80 / 6%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--background);
}

a {
  color: var(--blue-700);
}

a:hover {
  color: var(--blue-900);
}

h1, h2, h3 {
  line-height: 1.25;
  color: var(--blue-900);
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}

small, .muted {
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
  background: var(--blue-50);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* Layout */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

main.container {
  padding-top: 2rem;
  padding-bottom: 4rem;
}

.site-header {
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700));
  color: #fff;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  min-height: 64px;
}

.site-header a {
  color: #fff;
  text-decoration: none;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.site-nav a {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  color: rgb(255 255 255 / 85%);
}

.site-nav a:hover,
.site-nav a.active {
  color: #fff;
  background: rgb(255 255 255 / 15%);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: rgb(255 255 255 / 80%);
}

.user-menu a {
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  color: rgb(255 255 255 / 85%);
}

.user-menu a:hover,
.user-menu a.active {
  color: #fff;
  background: rgb(255 255 255 / 15%);
}

.card-danger {
  border-top: 4px solid var(--danger);
}

.card-danger h2 {
  color: var(--danger);
}

.user-menu button {
  background: transparent;
  border: 1px solid rgb(255 255 255 / 50%);
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

.user-menu button:hover {
  background: rgb(255 255 255 / 15%);
}

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

.page-header h1 {
  margin: 0;
}

.page-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card > :last-child {
  margin-bottom: 0;
}

.card-highlight {
  border-top: 4px solid var(--blue-600);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.actions form {
  display: inline;
}

/* Buttons */

button,
input[type="submit"],
.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  color: #fff;
  background: var(--blue-600);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

button:hover,
input[type="submit"]:hover,
.button:hover {
  color: #fff;
  background: var(--blue-800);
}

button:disabled,
input[type="submit"]:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button-secondary,
button.button-secondary {
  color: var(--blue-700);
  background: var(--surface);
  border-color: var(--border);
}

.button-secondary:hover,
button.button-secondary:hover {
  color: var(--blue-900);
  background: var(--blue-50);
}

.button-danger,
button.button-danger {
  color: var(--danger);
  background: var(--surface);
  border-color: #f0c5c0;
}

.button-danger:hover,
button.button-danger:hover {
  color: #fff;
  background: var(--danger);
}

/* Forms */

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  font: inherit;
  width: 100%;
  max-width: 560px;
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px var(--blue-100);
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--blue-600);
  vertical-align: -2px;
}

input[type="checkbox"] + label {
  font-weight: 400;
}

textarea.code {
  max-width: 100%;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1.25rem 0.25rem;
  margin: 1rem 0;
  max-width: 600px;
}

legend {
  font-weight: 600;
  color: var(--blue-900);
  padding: 0 0.4rem;
}

/* Messages */

.flash,
.notice,
.errors {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
}

.flash-notice {
  background: var(--success-bg);
  color: var(--success-text);
}

.flash-alert {
  background: var(--danger-bg);
  color: var(--danger);
}

.notice {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.errors {
  background: var(--danger-bg);
  color: var(--danger);
  padding-left: 2rem;
}

/* Tables */

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

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

th,
td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--blue-50);
}

td .actions {
  justify-content: flex-end;
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  color: var(--muted);
  background: #eef0f4;
}

.badge-published {
  color: var(--success-text);
  background: var(--success-bg);
}

/* Template details and preview */

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0 0 1.5rem;
}

.details dt {
  font-weight: 600;
  color: var(--muted);
}

.details dd {
  margin: 0;
}

.preview {
  display: block;
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.share-link {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.share-link input {
  margin: 0;
  max-width: none;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  background: var(--blue-50);
}

/* Sign-in page and home */

.hero {
  text-align: center;
  max-width: 560px;
  margin: 4rem auto;
}

.hero h1 {
  font-size: 2.25rem;
}

.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.tile {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.tile:hover {
  color: var(--text);
  border-color: var(--blue-600);
}

.tile h2 {
  color: var(--blue-700);
}

@media (max-width: 640px) {
  .site-header .container {
    gap: 0.75rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .user-menu span {
    display: none;
  }

  .share-link {
    flex-direction: column;
  }

  .details {
    grid-template-columns: 1fr;
  }
}

/* Footer and legal pages */

.site-footer {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-bottom: 2rem;
  font-size: 0.875rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer-operator {
  margin-left: auto;
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--blue-700);
  text-decoration: underline;
}

.legal {
  max-width: 760px;
}

.legal h2 {
  margin-top: 1.75rem;
}

.legal li {
  margin-bottom: 0.4rem;
}
