/* ShareTXT Modern Design System & Styles */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: rgba(15, 23, 42, 0.8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --primary-accent: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --send-accent: #6366f1;
  --send-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --send-glow: rgba(99, 102, 241, 0.4);
  
  --receive-accent: #10b981;
  --receive-gradient: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --receive-glow: rgba(16, 185, 129, 0.4);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --danger-color: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-main: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.5) 0%, transparent 100%);
  background-attachment: fixed;
}

/* Header Component */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 4px 14px var(--send-glow);
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

/* App Main Container */
.main-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 5;
}

/* Screens Wrapper */
.screen {
  width: 100%;
  display: none;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  transform: translateY(0);
}

/* View 1: Selection Screen (2 Large Screen-Relative Buttons) */
.selection-container {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

.hero-text {
  text-align: center;
  max-width: 650px;
}

.hero-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--text-muted);
  line-height: 1.6;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  width: 100%;
}

.action-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: clamp(2.5rem, 5vh, 4rem) 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  min-height: clamp(280px, 35vh, 380px);
}

.action-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 1.5px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.action-card.send-card:hover {
  transform: translateY(-8px);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 20px 40px -10px var(--send-glow);
  background: rgba(30, 27, 75, 0.4);
}

.action-card.receive-card:hover {
  transform: translateY(-8px);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 20px 40px -10px var(--receive-glow);
  background: rgba(6, 78, 59, 0.4);
}

.card-icon-wrapper {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  transition: var(--transition-smooth);
}

.send-card .card-icon-wrapper {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.send-card:hover .card-icon-wrapper {
  background: var(--send-gradient);
  color: white;
  transform: scale(1.1) rotate(-4deg);
}

.receive-card .card-icon-wrapper {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.receive-card:hover .card-icon-wrapper {
  background: var(--receive-gradient);
  color: white;
  transform: scale(1.1) rotate(4deg);
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.card-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 280px;
}

.card-btn {
  margin-top: 1.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.send-card .card-btn {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.1);
}

.send-card:hover .card-btn {
  color: white;
  background: var(--send-accent);
}

.receive-card .card-btn {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.1);
}

.receive-card:hover .card-btn {
  color: white;
  background: var(--receive-accent);
}

/* Common View Layouts */
.view-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 100%;
  max-width: 750px;
  box-shadow: var(--shadow-main);
  position: relative;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.view-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.view-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.send-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.receive-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.view-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Send Screen Specifics */
.textbox-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.text-input {
  width: 100%;
  min-height: 220px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  color: var(--text-main);
  font-family: 'Fira Code', monospace, sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: var(--transition-fast);
}

.text-input:focus {
  border-color: var(--send-accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.textbox-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.textbox-tools {
  display: flex;
  gap: 0.75rem;
}

.btn-tool {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.btn-tool:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.char-counter {
  color: var(--text-muted);
  font-family: 'Fira Code', monospace;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.char-counter.warning {
  color: var(--warning-color);
}

.char-counter.limit {
  color: var(--danger-color);
}

.btn-primary {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: var(--transition-smooth);
}

.btn-send {
  background: var(--send-gradient);
  color: white;
  box-shadow: 0 8px 20px -4px var(--send-glow);
}

.btn-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px -4px var(--send-glow);
  opacity: 0.95;
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Result Box for Code Output */
.code-result-container {
  margin-top: 1.5rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1.5px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.code-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #a5b4fc;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.code-display-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.code-display {
  font-family: 'Fira Code', monospace;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: 4px;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.9);
  padding: 0.75rem 2rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5), 0 0 20px rgba(99, 102, 241, 0.2);
}

.btn-copy-code {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
}

.btn-copy-code:hover {
  background: var(--send-accent);
  color: white;
}

.instruction-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: #818cf8;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.6);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

/* Receive Screen Specifics */
.code-input-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.code-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.code-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.5rem;
  color: var(--text-main);
  font-family: 'Fira Code', monospace;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  outline: none;
  transition: var(--transition-fast);
}

.code-input:focus {
  border-color: var(--receive-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.btn-receive {
  background: var(--receive-gradient);
  color: white;
  box-shadow: 0 8px 20px -4px var(--receive-glow);
}

.btn-receive:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px -4px var(--receive-glow);
  opacity: 0.95;
}

/* Receive Output Result Box */
.receive-result-container {
  margin-top: 1.75rem;
  animation: fadeIn 0.4s ease;
}

.text-output-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  position: relative;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.output-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #34d399;
  font-weight: 600;
  font-size: 0.9rem;
}

.received-text-box {
  font-family: 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1.5px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  color: #fca5a5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.error-icon {
  width: 48px;
  height: 48px;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.error-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #f87171;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideInRight 0.3s ease;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}

/* Modal for API Config */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-main);
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.modal-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  margin: 0.75rem 0 1.25rem 0;
  outline: none;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.footer {
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  z-index: 5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
  .action-card {
    min-height: 220px;
    padding: 2.5rem 1.5rem;
  }
  .view-card {
    padding: 1.5rem;
  }
}
