/* ==========================================================================
   Modern TikTok Downloader Styles - Enhanced & Cool
   ========================================================================== */

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

:root {
  --primary-color: #fe2c55; /* TikTok Red */
  --primary-dark: #d91a3a;
  --secondary-color: #25f4ee; /* TikTok Cyan */
  --tertiary-color: #fff; /* White for contrast */
  --background: #0a0a0a;
  --surface: #161616;
  --surface-light: #1f1f1f;
  --surface-glass: rgba(255, 255, 255, 0.05);
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --error: #ff4757;
  --success: #00d2d3;
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* New variables for enhanced effects */
  --glow-primary: 0 0 20px rgba(254, 44, 85, 0.5);
  --glow-secondary: 0 0 20px rgba(37, 244, 238, 0.5);
  --shadow-large: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--surface);
}
::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Animated gradient background */
  background-image: radial-gradient(
      at 40% 20%,
      rgba(254, 44, 85, 0.15) 0px,
      transparent 50%
    ),
    radial-gradient(at 80% 0%, rgba(37, 244, 238, 0.1) 0px, transparent 50%),
    radial-gradient(at 0% 50%, rgba(120, 119, 198, 0.1) 0px, transparent 50%);
  animation: backgroundShift 20s ease infinite;
}

@keyframes backgroundShift {
  0%,
  100% {
    background-size: 200% 200%, 150% 150%, 100% 100%;
  }
  50% {
    background-size: 100% 100%, 200% 200%, 150% 150%;
  }
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 50px;
  animation: fadeInDown 0.8s ease-out;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo svg {
  color: var(--primary-color);
  filter: drop-shadow(0 0 10px var(--primary-color));
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.logo h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 400;
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 50px;
}

/* Download Card */
.download-card {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 40px;
  box-shadow: var(--shadow-large);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.8s ease-out;
  position: relative;
  overflow: hidden;
}

.download-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary-color),
    transparent
  );
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.download-form {
  margin-bottom: 30px;
}

.input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

#urlInput {
  flex: 1;
  padding: 16px 24px;
  background: var(--surface-light);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

#urlInput:focus {
  outline: none;
  border-color: var(--primary-color);
  background: rgba(254, 44, 85, 0.05);
  box-shadow: var(--glow-primary);
}

#urlInput::placeholder {
  color: var(--text-secondary);
}

.submit-btn {
  padding: 16px 32px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.submit-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.submit-btn:hover::before {
  left: 100%;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(254, 44, 85, 0.4), var(--glow-primary);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(-1px) scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.submit-btn.loading .btn-text {
  display: none;
}

.submit-btn.loading .spinner {
  display: block;
}

/* Error Message */
.error-message {
  color: var(--error);
  font-size: 0.9rem;
  display: none;
  animation: shake 0.5s ease-in-out;
  padding: 12px;
  background: rgba(255, 71, 87, 0.1);
  border-left: 3px solid var(--error);
  border-radius: 8px;
}

.error-message.show {
  display: block;
}

/* Result Container */
.result-container {
  animation: fadeIn 0.5s ease-out;
}

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

.video-preview {
  display: flex;
  gap: 24px;
  margin-bottom: 30px;
  padding: 24px;
  background: var(--surface-light);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition);
}

.video-preview:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#thumbnail {
  width: 220px;
  height: 390px; /* 9:16 aspect ratio */
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.video-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.author-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.author-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-color);
  padding: 2px;
  background: var(--background);
}

.author-name {
  font-weight: 700;
  font-size: 1.2rem;
}

.author-username {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.video-description {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-stats {
  display: flex;
  gap: 24px;
  margin-top: auto;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.stat svg {
  color: var(--primary-color);
}

/* Download Buttons */
.download-buttons {
  display: flex;
  gap: 16px;
}

.download-btn {
  flex: 1;
  padding: 16px 24px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

.download-btn.primary {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  color: white;
  box-shadow: 0 4px 15px rgba(254, 44, 85, 0.3);
}

.download-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(254, 44, 85, 0.4), var(--glow-primary);
}

.download-btn.secondary {
  background: var(--surface-light);
  color: var(--text-primary);
  border: 2px solid var(--surface-light);
}

.download-btn.secondary:hover {
  background: var(--surface);
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

.feature {
  text-align: center;
  padding: 30px;
  background: var(--surface);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition);
  animation: fadeInUp 0.8s ease-out backwards;
}
.feature:nth-child(1) {
  animation-delay: 0.1s;
}
.feature:nth-child(2) {
  animation-delay: 0.2s;
}
.feature:nth-child(3) {
  animation-delay: 0.3s;
}

.feature:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-large);
  border-color: var(--primary-color);
}

.feature svg {
  color: var(--primary-color);
  margin-bottom: 16px;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 0 8px var(--primary-color));
}

.feature h3 {
  margin-bottom: 10px;
  font-size: 1.2rem;
  font-weight: 700;
}

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

/* Footer */
.footer {
  text-align: center;
  padding: 30px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: auto;
}

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

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

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

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

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  .logo h1 {
    font-size: 2rem;
  }
  .download-card {
    padding: 24px;
  }
  .input-group {
    flex-direction: column;
  }
  .video-preview {
    flex-direction: column;
    align-items: center;
  }
  #thumbnail {
    width: 100%;
    max-width: 300px;
    height: auto;
  }
  .download-buttons {
    flex-direction: column;
  }
  .features {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .video-stats {
    flex-wrap: wrap;
    gap: 12px;
  }
  .logo h1 {
    font-size: 1.8rem;
  }
}
.fab-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
}

.fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(254, 44, 85, 0.5);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: var(--surface);
  margin: 15% auto;
  padding: 30px;
  border: 1px solid var(--surface-light);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 400px;
  text-align: center;
  animation: fadeInUp 0.3s ease-out;
}

.close-btn {
  color: var(--text-secondary);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
}

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

.share-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.share-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.share-link.twitter {
  background: #1da1f2;
  color: white;
}
.share-link.whatsapp {
  background: #25d366;
  color: white;
}
.share-link.copy {
  background: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid var(--surface-light);
}

.share-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

/* Riwayat Panel */
.history-panel {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.history-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.clear-btn {
  background: var(--error);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.clear-btn:hover {
  background: #d63031;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.history-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--surface-light);
  border-radius: 12px;
  transition: var(--transition);
  position: relative;
}

.history-item:hover {
  background: var(--background);
}

.history-item img {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.history-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 0.9rem;
}

.history-item-author {
  font-weight: 600;
  color: var(--primary-color);
}

.history-item-desc {
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.remove-history-item {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}

.history-item:hover .remove-history-item {
  opacity: 1;
}

.empty-history {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
}
