/* =========================================
   FRAMEIT — Fresh Green & White Theme
   ========================================= */

:root {
  --bg-body: #f8fdf9;
  --bg-card: #ffffff;
  --bg-card-hover: #f0fdf4;
  --bg-input: #f9fafb;

  --accent: #10b981;
  --accent-hover: #059669;
  --accent-dim: rgba(16, 185, 129, .08);
  --accent-glow: rgba(16, 185, 129, .2);

  --whatsapp: #25d366;
  --whatsapp-hover: #1ebe57;

  --text-1: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;

  --border: #e5e7eb;
  --border-focus: #10b981;

  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;

  --radius: 16px;
  --radius-sm: 12px;
  --radius-full: 9999px;
  --transition: 200ms ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-1);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Server Banner ── */
.server-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  transform: translateY(-100%);
  transition: transform .35s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.server-banner.visible { transform: translateY(0); }
.server-banner.ready { background: rgba(16, 185, 129, .08); border-bottom-color: rgba(16,185,129,.2); }
.server-banner.ready .server-banner-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }

.server-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  font-size: .82rem;
  color: var(--text-2);
}

.server-banner-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s ease infinite;
  flex-shrink: 0;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── App Container ── */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  text-align: center;
  padding: 36px 0 28px;
  animation: fadeDown .5s ease both;
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.logo-mark {
  width: 34px;
  height: 34px;
}

.logo-text {
  font-family: 'Sora', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, #10b981, #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-3);
  font-size: .88rem;
  font-weight: 400;
  letter-spacing: .01em;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeUp .4s ease both;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }
.card:nth-child(4) { animation-delay: .15s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Input Section ── */
.input-row {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.input-row input {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-family: inherit;
  font-size: .92rem;
  color: var(--text-1);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.input-row input::placeholder { color: var(--text-3); }
.input-row input:focus {
  border-color: var(--accent);
  background: var(--bg-body);
}

.input-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-card);
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.input-action-btn svg { width: 18px; height: 18px; }
.input-action-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* Go Button */
.btn-go {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 4px 16px rgba(16, 185, 129, .25);
  position: relative;
  overflow: hidden;
}
.btn-go::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,.2) 100%);
  pointer-events: none;
}
.btn-go svg { width: 20px; height: 20px; }
.btn-go:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, .35);
}
.btn-go:active:not(:disabled) { transform: translateY(0); }
.btn-go:disabled { opacity: .6; cursor: not-allowed; }

/* ── Progress Strip ── */
.progress-strip {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.progress-strip-bar {
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-strip-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width .3s ease;
}

.progress-strip-text {
  font-size: .78rem;
  color: var(--text-2);
}

/* ── Preview Section ── */
.preview-container { margin-bottom: 16px; }

.frame-preview {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 9 / 16;
  max-height: 420px;
  margin: 0 auto;
  border: 1px solid var(--border);
}

.frame-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  z-index: 10;
  transition: opacity .2s ease;
}
.frame-overlay.visible { opacity: 1 !important; }

/* ── Frame Selector ── */
.frame-selector { margin-top: 4px; }

.frame-selector-label {
  font-family: 'Sora', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}

.frame-options {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-overflow-scrolling: touch;
}
.frame-options::-webkit-scrollbar { height: 4px; }
.frame-options::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }

.frame-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  min-width: 68px;
  flex-shrink: 0;
}
.frame-option:hover { background: var(--bg-card-hover); }
.frame-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.frame-thumb {
  width: 52px;
  height: 70px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.frame-thumb img { width: 100%; height: 100%; object-fit: cover; }
.frame-thumb.no-frame { color: var(--text-3); }
.frame-thumb.no-frame svg { width: 22px; height: 22px; }

.frame-option span {
  font-size: .68rem;
  color: var(--text-3);
  text-align: center;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.frame-option.selected span { color: var(--accent); font-weight: 600; }

.no-frames-msg {
  color: var(--text-3);
  font-size: .82rem;
  text-align: center;
  padding: 12px;
}

/* ── Action Section ── */
.btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--whatsapp);
  color: white;
  font-family: 'Sora', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: 0 4px 20px rgba(37, 211, 102, .2);
  margin-bottom: 10px;
}
.btn-whatsapp svg { width: 22px; height: 22px; }
.btn-whatsapp:hover:not(:disabled) {
  background: var(--whatsapp-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(37,211,102,.3);
}
.btn-whatsapp:active:not(:disabled) { transform: translateY(0); }
.btn-whatsapp:disabled { opacity: .5; cursor: not-allowed; }

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-2);
  font-family: inherit;
  font-size: .76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-action svg { width: 20px; height: 20px; }
.btn-action:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.btn-action:disabled { opacity: .4; cursor: not-allowed; }

/* ── Footer ── */
.footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  color: var(--text-3);
  font-size: .78rem;
}

/* ── Toasts ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: .85rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  animation: toastIn .3s ease;
  pointer-events: auto;
  text-align: center;
}
.toast.success { border-color: var(--success); background: rgba(34,197,94,.1); }
.toast.error { border-color: var(--error); background: rgba(239,68,68,.1); }
.toast.warning { border-color: var(--warning); background: rgba(245,158,11,.1); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Share Loading Modal ── */
.share-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(6px);
}
.share-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 300px;
  width: 90%;
  text-align: center;
  animation: fadeUp .25s ease;
}
.share-modal-content { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.share-spinner-large {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.share-modal-title { font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 600; color: var(--text-1); }
.share-modal-text { font-size: .85rem; color: var(--text-2); }
.share-modal-progress { width: 100%; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.share-modal-progress-bar { height: 100%; background: linear-gradient(90deg, #10b981, #059669); width: 0%; transition: width .3s ease; }

/* ── Spinner (inline) ── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* CSS Frame previews */
.frame-preview[data-frame="blue"] .frame-overlay {
  box-shadow: inset 0 0 0 10px #3b82f6;
  border-radius: var(--radius);
}
.frame-preview[data-frame="gold"] .frame-overlay {
  box-shadow: inset 0 0 0 10px #10b981;
  border-radius: var(--radius);
}
.frame-preview[data-frame="neon"] .frame-overlay {
  box-shadow: inset 0 0 0 4px #10b981, inset 0 0 20px rgba(16,185,129,.5);
  border-radius: var(--radius);
}
.frame-preview[data-frame="gradient"] .frame-overlay {
  border: 10px solid transparent;
  background: linear-gradient(#000,#000) padding-box, linear-gradient(135deg, #10b981, #059669, #047857) border-box;
  border-radius: var(--radius);
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .app { padding: 12px 12px 32px; }
  .card { padding: 16px; }
  .frame-preview { max-height: 360px; }
  .action-row { gap: 6px; }
  .btn-action { padding: 12px 6px; font-size: .72rem; }
}
