/* =========================================================
   Pegasus — Mobile-first styles (Android PWA)
   ========================================================= */

:root {
  --color-primary:       #4f46e5;
  --color-primary-dark:  #4338ca;
  --color-primary-light: #e0e7ff;
  --color-bg:            #f3f4f6;
  --color-surface:       #ffffff;
  --color-text:          #111827;
  --color-text-muted:    #6b7280;
  --color-border:        #e5e7eb;
  --color-error:         #dc2626;
  --color-error-bg:      #fef2f2;
  --color-error-border:  #fecaca;
  --color-success:       #059669;
  --radius:              12px;
  --radius-sm:           8px;
  --shadow:              0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:           0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;        /* prevent pull-to-refresh on Android */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ----- Screens ----- */
.screen { display: none; flex-direction: column; min-height: 100dvh; }
.screen.active { display: flex; }

/* =========================================================
   Login Screen
   ========================================================= */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem 1.5rem;
  gap: 0.75rem;
  text-align: center;
}

.login-logo { margin-bottom: 0.25rem; }
.login-logo img { border-radius: 22px; box-shadow: var(--shadow-md); }

.login-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* Google Sign-In button */
.btn-google {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  margin-top: 0.75rem;
  min-height: 52px;
  font-family: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
}
.btn-google:active { transform: scale(0.97); box-shadow: none; }
.google-icon { flex-shrink: 0; }

/* =========================================================
   App Bar
   ========================================================= */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-bar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.app-bar-icon { border-radius: 7px; }
.app-bar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary);
}

.app-bar-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.user-name {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   Content
   ========================================================= */
.content {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* =========================================================
   Cards
   ========================================================= */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card.hidden { display: none; }

.card-error {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
}
.card-error p {
  font-size: 0.875rem;
  color: var(--color-error);
}

/* =========================================================
   Form Fields
   ========================================================= */
.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge-optional {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.field {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field:focus { border-color: var(--color-primary); }
.field::placeholder { color: var(--color-text-muted); }

.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.6;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* URL field with clear button */
.url-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.url-wrap .field { padding-right: 2.5rem; }

.btn-icon-clear {
  position: absolute;
  right: 0.625rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  padding: 0.9rem 1.5rem;
  min-height: 52px;
  box-shadow: var(--shadow);
  letter-spacing: 0.01em;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }

/* Secondary */
.btn-secondary {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 1rem;
  padding: 0.9rem 1.5rem;
  min-height: 52px;
}
.btn-secondary:hover:not(:disabled) { background: #c7d2fe; }

/* Text / ghost */
.btn-text {
  background: none;
  color: var(--color-primary);
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
}

.btn-sm { font-size: 0.8rem; min-height: unset; }
.btn-full { width: 100%; }

.btn-icon-left { flex-shrink: 0; }

/* Spinner inside primary button */
.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Result
   ========================================================= */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.draft-output {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  min-height: 64px;
}

/* =========================================================
   Footer
   ========================================================= */
.app-footer {
  padding: 0.625rem 1rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* =========================================================
   Utility
   ========================================================= */
.hidden { display: none !important; }
