/* ==========================================================================
   KTI Signature Generator - App UI styles
   (Kept entirely separate from the inline styles used in generated signatures)
   ========================================================================== */

:root {
  --navy: #1B3A5B;
  --navy-dark: #122740;
  --ink: #14202E;
  --muted: #647082;
  --separator: #B7C2CE;
  --gold: #C9A227;
  --bg: #F4F6F8;
  --panel-bg: #FFFFFF;
  --border: #DCE2E8;
  --danger: #B3261E;
  --success: #1E7B45;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 46, 0.06), 0 1px 1px rgba(20, 32, 46, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 32, 46, 0.08), 0 2px 6px rgba(20, 32, 46, 0.05);
  --shadow-lg: 0 16px 40px rgba(20, 32, 46, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 480px at 100% -10%, rgba(27, 58, 91, 0.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Keyframes ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.9); }
  60%  { opacity: 1; transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(27, 58, 91, 0.16); }
  50%      { box-shadow: 0 0 0 6px rgba(27, 58, 91, 0); }
}

.fade-in {
  animation: fadeIn 0.5s var(--ease) both;
}

.slide-in {
  animation: slideDown 0.35s var(--ease) both;
}

.row-in {
  animation: fadeIn 0.4s var(--ease) both;
}

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 12px 32px;
  animation: fadeIn 0.4s var(--ease) both;
}

.site-header__brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header__logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  transition: transform 0.35s var(--ease);
}

.site-header__inner:hover .site-header__logo {
  transform: rotate(-8deg) scale(1.08);
}

.site-header h1 {
  font-size: 20px;
  margin: 0;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.site-header p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.site-header__nav a {
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  display: inline-block;
}

.site-header__nav a:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ---- Hero ---- */
.hero {
  position: relative;
  overflow: hidden;
  max-width: 1200px;
  margin: 28px auto 0;
  padding: 40px 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--navy-dark), var(--navy) 55%, #2c5686);
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.55s var(--ease) both;
}

.hero__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.35;
  pointer-events: none;
  animation: drift 12s ease-in-out infinite;
}

.hero__blob--1 {
  width: 260px;
  height: 260px;
  background: var(--gold);
  top: -90px;
  right: -50px;
}

.hero__blob--2 {
  width: 220px;
  height: 220px;
  background: #4d84c4;
  bottom: -90px;
  left: -50px;
  animation-delay: 2s;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(-12px, 14px); }
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 640px;
}

.hero__eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.hero p {
  margin: 0 0 22px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14.5px;
  line-height: 1.6;
}

.hero__steps {
  list-style: none;
  display: flex;
  gap: 20px;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.hero__steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.hero__steps li span {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

@media (max-width: 600px) {
  .hero {
    padding: 28px 24px;
  }
  .hero__steps {
    gap: 10px;
  }
}

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.5s var(--ease) both;
}

.form-panel {
  animation-delay: 0.03s;
}

.preview-panel {
  animation-delay: 0.1s;
}

@media (min-width: 901px) {
  .preview-panel {
    position: sticky;
    top: 90px;
  }
}

.panel h2 {
  margin-top: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--navy);
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

/* ---- Form ---- */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.field {
  margin-bottom: 14px;
  animation: fadeIn 0.4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.field--small {
  min-width: 0;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink);
}

.field .optional {
  font-weight: 400;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.15s var(--ease);
}

.field input:hover,
.field select:hover {
  border-color: #b9c4d0;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 4px rgba(27, 58, 91, 0.12);
}

.field input.field-invalid,
.field select.field-invalid {
  border-color: var(--danger);
  animation: shake 0.35s var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

.error {
  display: block;
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  min-height: 14px;
}

.field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 2px;
  margin: 0 0 14px;
  transition: border-color 0.2s var(--ease);
  animation: fadeIn 0.4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.field-group:focus-within {
  border-color: var(--navy);
}

.field-group legend {
  font-size: 13px;
  font-weight: 600;
  padding: 0 6px;
}

/* ---- Buttons ---- */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  animation: fadeIn 0.4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.btn {
  position: relative;
  padding: 10px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease), opacity 0.18s var(--ease);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--primary {
  background: linear-gradient(180deg, #204670, var(--navy) 60%);
  color: #fff;
}

.btn--primary:hover {
  background: linear-gradient(180deg, #24507d, #1c4066 60%);
}

.btn--secondary {
  background: #fff;
  color: var(--navy);
  border-color: var(--border);
}

.btn--secondary:hover {
  border-color: var(--navy);
  background: #f7f9fb;
}

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

.btn--pulse {
  animation: popIn 0.4s var(--ease);
}

.btn--loading {
  color: transparent !important;
  pointer-events: none;
}

.btn--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn--secondary.btn--loading::after {
  border: 2px solid rgba(27, 58, 91, 0.25);
  border-top-color: var(--navy);
}

.form-status {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
  transition: color 0.2s var(--ease);
}

.form-status.status-animate {
  animation: slideDown 0.3s var(--ease);
}

.form-status.status-success {
  color: var(--success);
}

.form-status.status-error {
  color: var(--danger);
}

.hint {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.hint strong {
  color: var(--ink);
}

/* ---- Preview ---- */
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.preview-toolbar h2 {
  margin: 0;
  padding: 0;
  border: 0;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: livePulse 1.8s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 123, 69, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(30, 123, 69, 0); }
}

.preview-frame-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  transition: opacity 0.18s var(--ease), border-color 0.18s var(--ease);
}

.preview-frame-wrap.is-updating {
  opacity: 0.6;
  border-color: var(--navy);
}

.preview-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #eef1f4, #e4e8ec);
  border-bottom: 1px solid var(--border);
}

.chrome-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chrome-dot--red {
  background: #ED6A5E;
}

.chrome-dot--yellow {
  background: #F4BF4F;
}

.chrome-dot--green {
  background: #61C454;
}

.preview-body {
  padding: 20px;
  background: #fafbfc;
}

#preview-frame {
  width: 100%;
  height: 300px;
  border: 0;
  background: #fff;
  transition: opacity 0.2s var(--ease);
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px;
}

/* ==========================================================================
   Admin area
   ========================================================================== */

.admin-wrap {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 24px;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-topbar h1 {
  color: var(--navy);
  font-size: 20px;
  margin: 0;
}

.login-wrap {
  max-width: 380px;
  margin: 80px auto;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.4s var(--ease) both;
}

.login-wrap h1 {
  color: var(--navy);
  font-size: 18px;
  margin-top: 0;
}

.search-bar {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 4px rgba(27, 58, 91, 0.12);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

table.data-table th,
table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

table.data-table th {
  background: var(--bg);
  color: var(--navy);
  font-weight: 700;
}

table.data-table tbody tr {
  transition: background 0.15s var(--ease);
}

table.data-table tbody tr:hover {
  background: #f5f8fb;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

.sortable {
  color: var(--navy);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s var(--ease);
}

.sortable:hover {
  color: var(--gold);
}

.sortable--active {
  color: var(--navy-dark);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.sort-arrow {
  font-size: 9px;
  color: var(--gold);
}

.row-actions a,
.row-actions button {
  font-size: 12px;
  margin-right: 8px;
  text-decoration: none;
  color: var(--navy);
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s var(--ease);
}

.row-actions a:hover,
.row-actions button:hover {
  color: var(--gold);
}

.row-actions .link-danger {
  color: var(--danger);
}

.row-actions .link-danger:hover {
  color: #7a1912;
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-success {
  background: #E7F5EC;
  color: var(--success);
  border: 1px solid #BFE3CC;
}

.alert-error {
  background: #FBEAE9;
  color: var(--danger);
  border: 1px solid #F1C6C3;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  animation: fadeIn 0.4s var(--ease) both;
}
