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

:root {
  --primary-blue: #3b82f6;
  --primary-purple: #8b5cf6;
  --primary-violet: #7c3aed;
  --bg-light: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 50%, #f3e8ff 100%);
  --bg-dark: linear-gradient(135deg, #1f2937 0%, #581c87 50%, #6b21a8 100%);
  --glass-light: rgba(255, 255, 255, 0.7);
  --glass-dark: rgba(255, 255, 255, 0.1);
  --border-light: rgba(255, 255, 255, 0.5);
  --border-dark: rgba(255, 255, 255, 0.2);
  --text-light: #1f2937;
  --text-dark: #ffffff;
  --text-muted-light: #6b7280;
  --text-muted-dark: #d1d5db;
  --shadow-light: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-dark: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body {
  font-family: "Inter", sans-serif;
  min-height: 100vh;
  background: var(--bg-light);
  color: var(--text-light);
  transition: all 0.5s ease;
  overflow-x: hidden;
}

body.dark {
  background: var(--bg-dark);
  color: var(--text-dark);
}

.app {
  position: relative;
  min-height: 100vh;
}

.background-elements {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-element {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  opacity: 0.2;
  filter: blur(60px);
  transition: all 0.5s ease;
}

.bg-element-1 {
  top: -160px;
  right: -160px;
  background: var(--primary-blue);
}

.bg-element-2 {
  bottom: -160px;
  left: -160px;
  background: var(--primary-purple);
}

body.dark .bg-element-1 {
  background: var(--primary-purple);
}

body.dark .bg-element-2 {
  background: var(--primary-violet);
}

.container {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  animation: slideInFromTop 1s ease-out;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo i {
  font-size: 2rem;
  color: var(--primary-blue);
  transition: color 0.3s ease;
}

body.dark .logo i {
  color: var(--primary-purple);
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.theme-toggle {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.theme-toggle i {
  font-size: 1.25rem;
  color: inherit;
}

/* Main Content */
.main-content {
  max-width: 1000px;
  margin: 0 auto;
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 3rem;
  animation: slideInFromTop 1s ease-out 0.2s both;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  line-height: 1.1;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.dark .gradient-text {
  background: linear-gradient(135deg, var(--primary-purple), var(--primary-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted-light);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

body.dark .hero-subtitle {
  color: var(--text-muted-dark);
}

/* Glass Card */
.glass-card {
  background: var(--glass-light);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid var(--border-light);
  border-radius: 24px;
  box-shadow: var(--shadow-light);
  transition: all 0.5s ease;
}

body.dark .glass-card {
  background: var(--glass-dark);
  border-color: var(--border-dark);
  box-shadow: var(--shadow-dark);
}

/* Shortener Card */
.shortener-card {
  padding: 2rem;
  margin-bottom: 2rem;
  animation: slideInFromBottom 1s ease-out 0.4s both;
}

.input-section {
  margin-bottom: 1.5rem;
}

.input-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.url-input {
  flex: 1;
  height: 56px;
  padding: 0 1.5rem;
  border: 2px solid rgba(156, 163, 175, 0.3);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  transition: all 0.3s ease;
  outline: none;
  -webkit-appearance: none; /* Remove iOS default styling */
  -moz-appearance: none; /* Remove Firefox default styling */
  appearance: none; /* Remove default styling */
  box-sizing: border-box; /* Ensure padding is included in width */
  width: 100%; /* Ensure full width */
}

.url-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body.dark .url-input {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

body.dark .url-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

body.dark .url-input:focus {
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.shorten-btn {
  height: 56px;
  padding: 0 2rem;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-width: 140px;
}

.shorten-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
}

body.dark .shorten-btn {
  background: linear-gradient(135deg, var(--primary-purple), var(--primary-violet));
}

body.dark .shorten-btn:hover {
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.3);
}

.shorten-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.loading-spinner {
  display: none;
}

.shorten-btn.loading .btn-text {
  opacity: 0;
}

.shorten-btn.loading .loading-spinner {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-left: 0.5rem;
  min-height: 1.25rem;
}

/* Result Section */
.result-section {
  animation: slideInFromTop 0.5s ease-out;
}

.result-card {
  padding: 1.5rem;
  border: 2px dashed rgba(59, 130, 246, 0.5);
  border-radius: 16px;
  background: rgba(59, 130, 246, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

body.dark .result-card {
  border-color: rgba(139, 92, 246, 0.5);
  background: rgba(139, 92, 246, 0.05);
}

.result-content {
  flex: 1;
  min-width: 0;
}

.result-label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted-light);
}

body.dark .result-label {
  color: var(--text-muted-dark);
}

.result-url {
  font-family: "Courier New", monospace;
  font-size: 1.125rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  color: var(--primary-blue);
  word-break: break-all;
}

body.dark .result-url {
  background: rgba(255, 255, 255, 0.1);
  color: var(--primary-purple);
}

.copy-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  background: var(--primary-blue);
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn:hover {
  background: #2563eb;
  transform: scale(1.05);
}

body.dark .copy-btn {
  background: var(--primary-purple);
}

body.dark .copy-btn:hover {
  background: #7c3aed;
}

/* Recent URLs */
.recent-urls {
  padding: 2rem;
  margin-bottom: 2rem;
  animation: slideInFromBottom 1s ease-out 0.6s both;
}

.recent-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.recent-item {
  padding: 1rem;
  border: 1px solid rgba(156, 163, 175, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.recent-item:hover {
  transform: scale(1.02);
  background: rgba(255, 255, 255, 0.8);
}

body.dark .recent-item {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark .recent-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.recent-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.recent-item-header i {
  color: var(--primary-blue);
}

body.dark .recent-item-header i {
  color: var(--primary-purple);
}

.recent-short-url {
  font-family: "Courier New", monospace;
  font-size: 0.875rem;
  color: var(--primary-blue);
}

body.dark .recent-short-url {
  color: var(--primary-purple);
}

.recent-original-url {
  font-size: 0.875rem;
  color: var(--text-muted-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark .recent-original-url {
  color: var(--text-muted-dark);
}

.recent-item-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.recent-item-info {
  flex: 1;
  min-width: 0;
}

.recent-item-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: rgba(156, 163, 175, 0.2);
}

.action-btn.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Examples Section */
.examples-section {
  text-align: center;
  animation: slideInFromBottom 1s ease-out 0.8s both;
}

.examples-label {
  font-size: 0.875rem;
  color: var(--text-muted-light);
  margin-bottom: 1rem;
}

body.dark .examples-label {
  color: var(--text-muted-dark);
}

.examples-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.example-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-muted-light);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.example-btn:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: scale(1.05);
}

body.dark .example-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted-dark);
}

body.dark .example-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Toast Notification */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  z-index: 1000;
  max-width: 300px;
}

.toast.show {
  transform: translateX(0);
}

body.dark .toast {
  background: #374151;
  color: white;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-icon {
  font-size: 1.25rem;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.toast-description {
  font-size: 0.875rem;
  color: var(--text-muted-light);
}

body.dark .toast-description {
  color: var(--text-muted-dark);
}

/* Animations */
@keyframes slideInFromTop {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .header {
    margin-bottom: 2rem;
  }

  .hero-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
  }

  .hero-subtitle {
    font-size: 1.125rem;
    margin-bottom: 2rem;
  }

  .shortener-card {
    padding: 1.5rem;
  }

  .input-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .url-input {
    width: 100%;
    height: 52px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0 1rem;
  }

  .shorten-btn {
    width: 100%;
    height: 52px;
    min-width: auto;
  }

  .result-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 1rem;
  }

  .result-url {
    font-size: 1rem;
    padding: 1rem;
    word-break: break-all;
    overflow-wrap: break-word;
  }

  .copy-btn {
    width: 100%;
    justify-content: center;
  }

  .recent-urls {
    padding: 1.5rem;
  }

  .recent-item {
    padding: 1rem;
  }

  .recent-item-content {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .recent-item-actions {
    justify-content: center;
  }

  .examples-buttons {
    flex-direction: column;
    align-items: center;
  }

  .example-btn {
    width: 100%;
    max-width: 300px;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }

  .hero-title {
    font-size: 2rem;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .shortener-card {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
  }

  .url-input {
    height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0 0.875rem;
  }

  .shorten-btn {
    height: 48px;
    font-size: 0.9rem;
  }

  .recent-urls {
    padding: 1.25rem;
  }

  .recent-title {
    font-size: 1.25rem;
  }

  .recent-item {
    padding: 0.875rem;
  }

  .recent-original-url {
    font-size: 0.8rem;
  }

  .examples-section {
    margin-top: 1.5rem;
  }
}

/* Fix for iOS Safari input styling */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .url-input {
    -webkit-appearance: none;
    border-radius: 16px;
  }
}

/* Additional mobile fixes */
@media (max-width: 768px) {
  .url-input:focus {
    transform: none; /* Prevent any transform that might cause issues */
  }

  /* Ensure proper touch targets */
  .shorten-btn,
  .copy-btn,
  .action-btn,
  .example-btn,
  .theme-toggle {
    min-height: 44px; /* iOS recommended minimum touch target */
  }

  /* Fix for Android Chrome input zoom */
  .url-input,
  input[type="url"] {
    font-size: 16px !important;
  }
}
