:root {
  --bg-dark: #090a0f;
  --panel-bg: rgba(22, 26, 38, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #ec4899;
  --accent-cyan: #06b6d4;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --success: #10b981;
  --danger: #ef4444;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --font-main: 'Outfit', 'Inter', -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-x: hidden;
  position: relative;
}

/* Background Ambient Lighting Effect */
.background-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, rgba(236, 72, 153, 0.12) 40%, rgba(0, 0, 0, 0) 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(60px);
}

.container {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Glassmorphism Panel Utility */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Header */
.header {
  text-align: center;
}

.logo {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  color: var(--primary);
  filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.6));
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Main Card Form */
.main-card {
  padding: 32px;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.main-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.shorten-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  position: relative;
  align-items: center;
  gap: 10px;
}

.input-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.input-group input[type="url"] {
  width: 100%;
  padding: 16px 16px 16px 48px;
  background: rgba(10, 12, 18, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: all 0.25s ease;
}

.input-group input[type="url"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(10, 12, 18, 0.9);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  border: none;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

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

/* Alias Accordion */
.alias-accordion {
  margin-top: 4px;
}

.toggle-alias-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: color 0.2s ease;
  padding: 4px 0;
}

.toggle-alias-btn:hover {
  color: var(--text-main);
}

.chevron-icon {
  font-size: 0.75rem;
  transition: transform 0.3s ease;
}

.toggle-alias-btn.active .chevron-icon {
  transform: rotate(180deg);
}

.alias-content {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeIn 0.3s ease forwards;
}

.alias-content.hidden {
  display: none;
}

.alias-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(10, 12, 18, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 0 14px;
  overflow: hidden;
}

.domain-prefix {
  color: var(--accent-cyan);
  font-size: 0.95rem;
  font-weight: 500;
  user-select: none;
}

.alias-input-wrapper input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  padding: 12px 8px;
  font-size: 0.95rem;
  width: 100%;
  font-family: inherit;
}

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

/* Toast Alert */
.toast {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  animation: slideDown 0.3s ease;
}

.toast.hidden {
  display: none;
}

.toast.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.toast.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

/* Result Card */
.result-card {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  animation: fadeInUp 0.4s ease;
}

.result-card.hidden {
  display: none;
}

.result-header {
  margin-bottom: 14px;
}

.badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.result-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.short-url-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 12, 18, 0.8);
  border: 1px dashed rgba(99, 102, 241, 0.5);
  padding: 14px 18px;
  border-radius: var(--radius-md);
}

.short-url-box i {
  color: var(--accent-cyan);
}

.short-url-text {
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  word-break: break-all;
}

.short-url-text:hover {
  text-decoration: underline;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn-action {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-copy:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-qr:hover {
  background: rgba(236, 72, 153, 0.2);
  border-color: var(--secondary);
  color: var(--secondary);
}

.btn-open:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* History Section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header h2 i {
  color: var(--secondary);
}

.btn-clear {
  display: none !important;
}

.btn-action-sm {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-action-sm:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 16px;
}

.item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.item-short-url {
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.item-short-url:hover {
  text-decoration: underline;
}

.item-original-url {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 450px;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clicks-tag {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 6px;
}

.btn-icon-only {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.empty-history {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-history.hidden {
  display: none;
}

.empty-icon {
  font-size: 2.5rem;
  color: rgba(255, 255, 255, 0.2);
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.modal-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.close-btn:hover {
  color: #fff;
}

.modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.qr-container {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.qr-container img, .qr-container canvas {
  display: block;
}

.qr-url-text {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  word-break: break-all;
  text-align: center;
  font-weight: 500;
}

.btn-full {
  width: 100%;
}

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 10px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

/* Responsive Media Queries */
@media (max-width: 640px) {
  body {
    padding: 20px 12px;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .input-icon {
    top: 16px;
  }
  
  .btn-primary {
    width: 100%;
  }

  .action-buttons {
    flex-direction: column;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .item-meta {
    width: 100%;
    justify-content: space-between;
  }

  .item-original-url {
    max-width: 100%;
  }
}
