@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Cosmic Dark Palette */
  --bg-color: #080512;
  --panel-bg: rgba(255, 255, 255, 0.03);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-glow: rgba(108, 92, 231, 0.3);
  
  --color-text-primary: #ffffff;
  --color-text-secondary: rgba(255, 255, 255, 0.5);
  --color-accent: #8e2de2;
  --color-accent-glow: #4a00e0;
  --color-success: #00f2fe;
  
  color-scheme: dark;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--color-text-primary);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glows */
.bg-ambient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  animation: float 20s infinite alternate;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: var(--color-accent);
  top: -10%;
  left: -10%;
  animation-duration: 25s;
}

.blob-2 {
  width: 600px;
  height: 600px;
  background: var(--color-accent-glow);
  bottom: -15%;
  right: -10%;
  animation-duration: 30s;
}

.blob-3 {
  width: 400px;
  height: 400px;
  background: var(--color-success);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.08;
  animation-duration: 20s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5%, 10%) scale(1.1); }
  100% { transform: translate(-5%, -5%) scale(0.95); }
}

/* Main Container */
.app-container {
  width: 100%;
  max-width: 650px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  padding: 40px;
  border-radius: 28px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), 
              inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 1;
}

/* Header Styles */
.header {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.badge {
  font-size: 0.72rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--color-success);
  font-weight: 700;
  text-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #fff 0%, #a3a3a3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Navigation Tabs */
.tabs-nav {
  display: flex;
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 6px;
  margin-bottom: 30px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  font-family: var(--font-sans);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  padding: 12px;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-glow) 100%);
  box-shadow: 0 4px 15px rgba(142, 45, 226, 0.25);
}

/* Tab Panels */
.tab-panel {
  display: none;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

.tab-panel.active {
  display: flex;
}

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

/* Textarea & Inputs */
.textarea-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

.textarea-input {
  width: 100%;
  min-height: 140px;
  max-height: 240px;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  color: #fff;
  font-size: 0.98rem;
  resize: vertical;
  line-height: 1.5;
  transition: all 0.3s;
}

.textarea-input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 20px rgba(142, 45, 226, 0.15);
}

.char-counter {
  position: absolute;
  bottom: 12px;
  right: 18px;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
}

/* iOS Style Switch/Toggle */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  margin-bottom: 24px;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.toggle-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-glow) 100%);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Share Result Board */
.result-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 24px 0;
  text-align: center;
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.code-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.code-display {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 25px rgba(142, 45, 226, 0.4);
  font-feature-settings: "tnum";
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: #fff;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

/* Link Box */
.link-box-container {
  display: flex;
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 6px 6px 6px 16px;
  align-items: center;
  margin-bottom: 30px;
  gap: 12px;
}

.link-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

/* Countdown Bar */
.expiry-container {
  width: 100%;
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expiry-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}

.expire-countdown {
  font-weight: 700;
  color: var(--color-success);
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-success) 100%);
  border-radius: 3px;
  transition: width 1s linear;
}

/* PIN Input Boxes */
.pin-input-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 30px 0;
}

.pin-box {
  width: 64px;
  height: 72px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  transition: all 0.3s;
}

.pin-box:focus {
  outline: none;
  border-color: var(--color-accent);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 15px rgba(142, 45, 226, 0.25);
  transform: translateY(-2px);
}

/* Output Area */
.output-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.4s ease;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.output-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-text-secondary);
}

.output-text-area {
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.95rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

.output-actions {
  display: flex;
  gap: 12px;
}

.output-actions .btn {
  flex: 1;
}

/* Global Buttons */
.btn {
  font-family: var(--font-sans);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-glow) 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(142, 45, 226, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(142, 45, 226, 0.45);
}

.btn-primary:active { transform: translateY(0); }

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  color: var(--color-text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-secondary:active { transform: translateY(0); }

.icon-svg {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
}

/* Spinner/Loader Styles */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 16px;
}

.loader-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  border-top-color: var(--color-accent);
  animation: spin 1s linear infinite;
}

.loader-text {
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.toast-container.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast {
  background: rgba(8, 5, 18, 0.9);
  border: 1px solid rgba(0, 242, 254, 0.3);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 12px 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 242, 254, 0.15);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
}

.toast.toast-error {
  border-color: rgba(255, 76, 76, 0.3);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 76, 76, 0.15);
}

/* Shake Animation (for errors) */
.shake {
  animation: shakeAnimation 0.4s ease;
}

@keyframes shakeAnimation {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .app-container {
    padding: 24px 16px;
    border-radius: 20px;
    margin: 10px;
  }
  
  .title { font-size: 2rem; }
  .code-display { font-size: 3rem; }
  .pin-box {
    width: 50px;
    height: 60px;
    font-size: 1.5rem;
  }
  
  .pin-input-row { gap: 8px; }
  .tabs-nav { margin-bottom: 20px; }
  .tab-btn { font-size: 0.85rem; padding: 10px; }
}

/* Expiry Preset Grid & Buttons */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.btn-preset {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
}

.btn-preset:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-preset.active {
  background: linear-gradient(135deg, rgba(142, 45, 226, 0.25) 0%, rgba(74, 0, 224, 0.25) 100%);
  border-color: var(--color-accent);
  color: #fff;
  box-shadow: 0 0 15px rgba(142, 45, 226, 0.2);
}

@media (max-width: 600px) {
  .preset-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}
