:root {
  --primary-color: #4F46E5;
  --primary-hover: #4338ca;
  --bg-color: #f3f4f6;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --input-bg: #f9fafb;
  --font-family: 'Outfit', sans-serif;
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end: #f1f5f9;
  --accent-tint: rgba(79, 70, 229, 0.03);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 80%, var(--accent-tint) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, var(--accent-tint) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, var(--accent-tint) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(79, 70, 229, 0.02) 2px, transparent 2px),
    radial-gradient(circle at 75% 75%, rgba(79, 70, 229, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 90% 10%, rgba(79, 70, 229, 0.01) 1.5px, transparent 1.5px);
  background-size: 80px 80px, 120px 120px, 60px 60px;
  background-position: 0 0, 40px 40px, 20px 20px;
  pointer-events: none;
  z-index: -1;
  opacity: 0.6;
  animation: subtle-float 20s ease-in-out infinite;
}

@keyframes subtle-float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  33% {
    transform: translateY(-5px) rotate(1deg);
  }
  66% {
    transform: translateY(5px) rotate(-1deg);
  }
}

/* Floating Background Elements */
.bg-shape {
  position: fixed;
  pointer-events: none;
  z-index: -1;
  opacity: 0.15;
  animation: float 25s ease-in-out infinite;
}

.bg-shape:nth-child(1) {
  top: 10%;
  left: 10%;
  width: 42px;
  height: 42px;
  background: var(--primary-color);
  border-radius: 50%;
  animation-delay: 0s;
}

.bg-shape:nth-child(2) {
  top: 60%;
  right: 15%;
  width: 68px;
  height: 68px;
  background: var(--primary-color);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation-delay: -8s;
}

.bg-shape:nth-child(3) {
  bottom: 20%;
  left: 20%;
  width: 23px;
  height: 23px;
  background: var(--primary-color);
  border-radius: 4px;
  animation-delay: -15s;
}

.bg-shape:nth-child(4) {
  top: 25%;
  right: 25%;
  width: 55px;
  height: 55px;
  background: var(--primary-color);
  border-radius: 50%;
  animation-delay: -5s;
}

.bg-shape:nth-child(5) {
  top: 40%;
  left: 5%;
  width: 31px;
  height: 31px;
  background: var(--primary-color);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation-delay: -12s;
}

.bg-shape:nth-child(6) {
  bottom: 35%;
  right: 5%;
  width: 47px;
  height: 47px;
  background: var(--primary-color);
  border-radius: 4px;
  animation-delay: -20s;
}

.bg-shape:nth-child(7) {
  top: 70%;
  left: 35%;
  width: 39px;
  height: 39px;
  background: var(--primary-color);
  border-radius: 50%;
  animation-delay: -3s;
}

.bg-shape:nth-child(8) {
  top: 15%;
  right: 40%;
  width: 64px;
  height: 64px;
  background: var(--primary-color);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation-delay: -18s;
}

.bg-shape:nth-child(9) {
  bottom: 50%;
  left: 50%;
  width: 27px;
  height: 27px;
  background: var(--primary-color);
  border-radius: 4px;
  animation-delay: -10s;
}

.bg-shape:nth-child(10) {
  top: 5%;
  right: 60%;
  width: 58px;
  height: 58px;
  background: var(--primary-color);
  border-radius: 50%;
  animation-delay: -7s;
}

.bg-shape:nth-child(11) {
  bottom: 10%;
  right: 35%;
  width: 36px;
  height: 36px;
  background: var(--primary-color);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation-delay: -22s;
}

.bg-shape:nth-child(12) {
  top: 50%;
  left: 70%;
  width: 49px;
  height: 49px;
  background: var(--primary-color);
  border-radius: 4px;
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) translateX(0px) scale(1);
  }
  25% {
    transform: translateY(-20px) translateX(10px) scale(1.1);
  }
  50% {
    transform: translateY(-10px) translateX(-15px) scale(0.9);
  }
  75% {
    transform: translateY(-25px) translateX(5px) scale(1.05);
  }
}

/* Mobile adjustments for background */
@media (max-width: 768px) {
  .bg-shape {
    opacity: 0.08; /* Reduce opacity on mobile instead of hiding */
  }
  
  body::after {
    opacity: 0.3; /* Reduce pattern opacity on mobile */
    background-size: 100px 100px, 150px 150px, 80px 80px;
  }
}

/* Header */
#header {
  padding: 1rem 2rem;
  display: flex;
  justify-content: flex-end;
  gap: 1.5rem;
}

#header a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

#header a:hover {
  color: var(--primary-color);
}

/* Main Container */
.container {
  max-width: 600px;
  margin: 0 auto 2rem;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Stats */
.stats-bar {
  display: flex;
  justify-content: space-around;
  gap: 3rem;
  margin-bottom: 2rem;
  color: var(--text-secondary);
  background: white;
  padding: 1rem 2rem;
  border-radius: 2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  text-transform: lowercase;
}

/* Card */
.card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  width: 98%;
}

/* Form Elements */
.input-group {
  margin-bottom: 1.5rem;
}

.input-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

input[type="text"], input[type="datetime-local"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.options-grid {
  display: grid;
  grid-template-columns: 6fr 4fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.options-full {
  grid-column: 1 / -1;
}

.alias-wrapper {
  position: relative;
}

#random {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  fill: var(--text-secondary);
  transition: fill 0.2s;
}

#random:hover {
  fill: var(--primary-color);
}

/* Buttons */
.btn-primary {
  display: block;
  width: 100%;
  padding: 0.875rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: center;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  color: var(--text-secondary);
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  margin-top: 1rem;
  display: block;
  text-align: center;
  width: 100%;
}

/* Result Section */
#output {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  display: none; /* JS will toggle block/none but current code might imply inline. I'll need to check JS display logic. */
}
/* The JS likely just changes innerHTML or visibility. Let's assume it doesn't force a display type heavily, or I'll override it.
   Actually, looking at the HTML, result is inline in the JSON block.
   I need to make sure the JS doesn't break. */
   
.result-box {
  background: var(--bg-color);
  padding: 1rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.short-url {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 1.25rem;
  cursor: pointer;
}

#qr {
  cursor: pointer;
  transition: transform 0.2s;
}

#qr:hover {
  transform: scale(1.1);
}

/* Error */
#error {
  margin-top: 1rem;
  color: #ef4444;
  text-align: center;
  display: none;
  background: #fef2f2;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #fee2e2;
}

/* Features List */
.features {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  width: 98%;
}

.feature-item {
  background: white;
  padding: 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.feature-item code {
  background: var(--bg-color);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-family: monospace;
  color: var(--primary-color);
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: auto;
}

.user-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.user-status img {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}

/* History Section */
#history {
  margin-top: 3rem;
  width: 98%;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  background: white;
  padding: 1rem 1.5rem 1rem 4rem;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.history-number {
  position: absolute;
  top: 50%;
  left: 1.2rem;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

.edit-btn {
  margin-left: auto;
}

.h-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.h-short {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 1.1rem;
  text-decoration: none;
}

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

.h-long {
  font-size: 0.9rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  display: block;
}

.h-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.action-btn {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  background: var(--bg-color);
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
}

.action-btn:hover {
  background: #e5e7eb;
}

.action-btn svg {
  top: 1.5px;
  position: relative;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  background: white;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--primary-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.pagination-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.total-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Navigation Header */
#header {
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between; /* Space out left and right items */
  align-items: center;
}

.h-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.h-right {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white; /* Optional: adds a background for the badge */
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 2rem;
  /* box-shadow: 0 1px 2px rgba(0,0,0,0.05); Optional shadow */
}

.user-pic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-pic-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #e5e7eb;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%239ca3af" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  background-size: 24px;
  background-position: center;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-info span {
  font-size: 0.9rem;
  color: var(--text-main);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
}

.login-link {
  color: var(--primary-color);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.9rem;
}

.login-link:hover {
  text-decoration: underline;
}


/* Material Design 3 Input Styles */
/* Container for input and label */
.md-input-group {
    position: relative;
    margin-bottom: 1.5rem;
    padding-top: 6px; /* Space for label to float into */
    border-bottom: 1px solid var(--border-color); /* Underline style for MD3 mostly uses background + underline */
    background-color: var(--input-bg);
    border-radius: 4px 4px 0 0; /* Rounded top corners */
    transition: border-color 0.2s, background-color 0.2s;
}

/* Specific static container for date inputs usually */
.md-input-group-static {
    position: relative;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--input-bg);
}

.md-input-group:focus-within {
    border-bottom: 2px solid var(--primary-color);
    background-color: #eef2ff; /* Slight tint on focus */
}

/* The Input Field */
.md-input-group input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 1.5rem 1rem 0.5rem 1rem; /* Top padding pushes text down */
    font-size: 1rem;
    outline: none;
    font-family: inherit;
    color: var(--text-main);
    box-shadow: none !important; /* Remove previous styles */
}

/* The Label */
.md-input-group label {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1rem;
    pointer-events: none; /* Let clicks pass through to input */
    transition: all 0.2s ease-out;
}

/* Floating State: When input has focus OR has content (placeholder mismatch trick) */
.md-input-group input:focus + label,
.md-input-group input:not(:placeholder-shown) + label {
    top: 0.5rem; /* Move to top area */
    transform: none;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Restore color for non-focused but filled inputs */
.md-input-group input:not(:focus):not(:placeholder-shown) + label {
     color: var(--text-secondary);
}

/* Special handling for options grid to make sure borders look right */
.options-grid .md-input-group {
    margin-bottom: 0; /* Grid handles spacing */
    border-radius: 4px 4px 0 0;
}

/* Ensure placeholder is hidden so the :placeholder-shown trick works. 
   We put a single space in HTML placeholder=" " */
.md-input-group input::placeholder {
    color: transparent;
}

/* Static label for date inputs or specific cases */
.static-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.md-input-group-static input {
    border: none;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

/* Adjust Alias Random Icon position */
.alias-wrapper #random {
    right: 1rem;
    top: 50%;
}

/* Feature Icons */
.feature-icon {
  margin-bottom: 1rem;
  color: var(--primary-color);
  width: 48px;
  height: 48px;
  background: rgba(79, 70, 229, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-icon svg {
  width: 24px;
  height: 24px;
}

/* Feature Header */
.feature-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.feature-icon {
  margin-bottom: 0;
}

/* History Title */
.history-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.total-links {
  color: var(--primary-color);
  font-weight: 600;
  font-size: 1.3rem;
  cursor: pointer;
}

#random, .shorten, .timer, .padlock {
  -webkit-tap-highlight-color: transparent;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.shorten {
  cursor: pointer;
}

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

  #header {
    padding: 0.5rem 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .h-left {
    order: 2;
  }

  .h-right {
    order: 1;
  }

  .h-right {
    gap: 1rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .stats-bar {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .card {
    padding: 1.5rem;
  }

  .options-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .alias-wrapper {
    grid-column: 1 / -1;
  }

  .options-full {
    grid-column: 1 / -1;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .history-item {
    padding: 1rem;
  }

  .history-number {
    left: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.7rem;
    display: none;
  }

  .edit-btn {
    right: 0.5rem;
  }

  .pagination {
    flex-direction: column;
    gap: 0.5rem;
  }

  .total-count {
    order: -1;
  }
}

/* Floating Legacy UI Switch Button */
.floating-btn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: 2rem;
  background: var(--primary-color);
  border: none;
  color: white;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-family);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transition: all 0.3s ease;
  z-index: 1000;
  opacity: 0.9;
  white-space: nowrap;
}

.floating-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
  opacity: 1;
}

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

/* Mobile adjustments for floating button */
@media (max-width: 768px) {
  .floating-btn {
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
}
