@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* ========================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ======================================== */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --soft-blue: #667eea;
  --dark-bg: #0f0f1a;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #b8c6db;
  --text-muted: #8892b0;
  --shadow-primary: 0 20px 40px rgba(0, 0, 0, 0.3);
  --shadow-secondary: 0 10px 30px rgba(103, 126, 234, 0.2);
  --shadow-hover: 0 30px 60px rgba(0, 0, 0, 0.4);
  --glow: 0 0 30px rgba(103, 126, 234, 0.3);
  --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ========================================
   BASE STYLES
   ======================================== */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  letter-spacing: 1.5px;
}

body {
  font-family: 'Playfair Display', serif;
  background: var(--dark-bg);
  background-image:
    radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(120, 200, 255, 0.2) 0%, transparent 50%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ========================================
   LAYOUT STRUCTURE
   ======================================== */
.header-wrapper {
  position: sticky;
  z-index: 100;
  top: 0;
  width: 100%;
}

.main-container-wrapper {
  max-width: 1200px;
  padding: 0.4em 0.25em;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 25px;
  margin-bottom: 6rem;
}

.footer-wrapper {
  position: absolute;
  bottom: 0;
  width: 100%;
}

/* ========================================
   CARD COMPONENTS
   ======================================== */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.5em;
  box-shadow: var(--shadow-primary);
  transition: var(--transition);
  height: 100%;
  position: relative;
  overflow: hidden;
}

.card:before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(103, 126, 234, 0.1) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.card:hover:before {
  opacity: 1;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover), var(--glow);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
.main-intro {
  font-size: clamp(1.4rem, 1.7rem + 0.5vw, 2rem);
  margin-bottom: 25px;
  background: var(--accent-gradient);
  position: relative;
  display: inline-block;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 15px;
}

.main-intro:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 70px;
  height: 4px;
  border-radius: 4px;
  background: var(--accent-gradient);
}

.hidden-intro {
  display: none;
}

h2 {
  font-size: clamp(1.5rem, 1.8rem + 0.2vw, 2.2rem);
  margin-bottom: 15px;
  color: var(--text-primary);
  font-weight: 600;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
form {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: clamp(1rem, 1.2rem + 0.2vw, 1.3rem);
}

label i {
  font-size: 1.3rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

input,
textarea {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 17px 20px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  transition: var(--transition);
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(103, 126, 234, 0.5);
  box-shadow: var(--shadow-secondary);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

/* ========================================
   BUTTON STYLES
   ======================================== */
#refresh-quotes {
  width: 100%;
}

.btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  padding: clamp(10px, 2vw, 14px) clamp(5px, 1vw, 7px);
  font-size: clamp(1rem, 1.2rem + 0.5vw, 1.5rem);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 10px;
  box-shadow: var(--shadow-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.btn:after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  transform: scale(0);
  transition: transform 0.6s ease;
}

.btn:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover), var(--glow);
}

.btn:hover:after {
  transform: scale(1);
}

#search-quote-btn {
  margin-top: 15px;
  width: 100%;
}

/* ========================================
   QUOTE ITEM STRUCTURE (UPDATED)
   ======================================== */
.quote-item {
  background: var(--card-bg);
  border-radius: 16px;
  padding: .6rem;
  margin-bottom: 2rem;
  border-left: 4px solid var(--soft-blue);
  transition: var(--transition);
  position: relative;
  box-shadow: var(--shadow-primary);

  /* overflow: hidden; */
  /* padding: 1.5rem; */
}

.quote-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover), var(--glow);
}

.quote-text {
  font-style: italic;
  font-size: clamp(1.2rem, 1.3vw, 1.5rem);
  line-height: 1.6;
  position: relative;
  z-index: 2;
  margin-bottom: 1.5rem;
  padding: 0 1rem;
  color: var(--text-primary);
}

.quote-text:before {
  content: "„";
  position: absolute;
  right: 0.32em;
  top: -1.5rem;
  font-size: 5rem;
  opacity: 0.2;
}

.quote-author {
  text-align: right;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 2;
  padding-right: 1rem;
}

.quote-meta {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--card-border);
  padding-top: 1rem;
  position: relative;
  z-index: 2;
}

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

/* ========================================
   QUOTE ACTIONS (EDIT FUNCTIONALITY)
   ======================================== */
.quote-actions {
  margin-top: 1.5rem;
  position: relative;
  z-index: 2;
}

.edit-quote-btn {
  background: var(--secondary-gradient);
  width: 100%;
  padding: 0.8rem;
  font-size: 1.1rem;
}

.edit-quote-form {
  display: grid;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.2);
  padding: .5rem;
  border-radius: 12px;
  margin-top: 1rem;
  animation: fadeIn 0.4s ease;

  /* padding: 1.5rem; */
}

.edit-quote-form textarea {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  padding: 0.8rem 1.2rem;
  font-size: 1rem;
  color: var(--text-primary);
  resize: none;
  overflow: hidden;
  min-height: 2.5rem;
  width: 100%;
  /* for responsiveness */
  border-radius: 8px;
  margin-bottom: 0.6rem;
}


.edit-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-align: center;
  font-style: italic;
}

.edit-quote-form .form-actions {
  display: flex;
  justify-content: space-between;

  /* margin-top: 1rem; */
}

.edit-quote-form .form-actions button {
  flex: 1;
  margin: 0 5px;
  padding: 0.8rem;
  font-size: .8rem;
}

/* ========================================
   TOOLTIP ENHANCEMENTS
   ======================================== */
.quote-submitter-tooltip-wrapper {
  position: relative;
  display: inline-block;
}

.quote-submitter {
  position: relative;
  cursor: pointer;
  color: #8892b0;
  transition: all 0.3s ease;
}

.quote-submitter:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.quote-submitter .tooltip-content {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #232634;
  border: 1px solid #3a3f5e;
  border-radius: 12px;
  padding: 15px;
  width: 250px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  display: flex;
  gap: 15px;
}

.quote-submitter:hover .tooltip-content {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-10px);
}

.submitter-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--soft-blue);
}

.tooltip-info {
  flex: 1;
  font-size: 0.85rem;
}

.tooltip-info p {
  margin: 0.3rem 0;
}

/* ========================================
   RESPONSE MESSAGES
   ======================================== */
#response-message {
  display: none;
  padding: 16px;
  margin: 20px auto;
  border-radius: 10px;
  text-align: center;
  font-weight: 500;
  font-size: 1.05rem;
  border: 1px solid;
  transition: all 0.4s ease;
  max-width: 600px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.success {
  background: rgba(152, 223, 138, 0.15);
  color: #2e7d32;
  border-color: rgba(76, 175, 80, 0.2);
}

.error {
  background: rgba(255, 205, 210, 0.15);
  color: #c62828;
  border-color: rgba(244, 67, 54, 0.2);
}

/* ========================================
   SEARCH FUNCTIONALITY
   ======================================== */
#search-query {
  width: 100%;
  margin-top: .5rem;
  margin-bottom: 20px;
  padding-left: 50px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%238892b0" width="24" height="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
  background-repeat: no-repeat;
  background-position: 15px center;
  background-size: 22px;
}

/* 🌀 Spinner Loader */
#loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto;
}

#loading-spinner::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 102, 255, 0.2);
  border-top-color: #0066ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ========================================
   LOADING ANIMATION
   ======================================== */
.loader {
  text-align: center;
  padding: 1rem;
  font-size: 1.1rem;
  color: #666;
}

/* ========================================
   BACK TO TOP BUTTON
   ======================================== */
.back-to-top-quote {
  background-color: var(--primary-gradient);
  box-shadow: 0 4px 12px var(--soft-blue);
  border: 2px solid var(--text-primary);
}

/* ========================================
   FLOATING LOGO
   ======================================== */
.logo {
  font-size: 3.5rem;
  margin-bottom: 15px;
  margin-right: 1.2rem;
  display: inline-block;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: float 5s ease-in-out infinite;
}

/* ========================================
   INFO ICON & TOOLTIP
   ======================================== */
.info-icon {
  position: absolute;
  top: 0.4375em;
  right: 0.5625em;
  background: transparent;
  padding: 0;
  margin: 0;
  border: none;
  z-index: 10;
}

.info-icon button {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
}

.lottie-icon {
  width: 54px;
  height: 54px;
  background: transparent;
  margin: 0;
  padding: 0;
}

/* Fixed tooltip positioning to prevent cutoff */
.tooltip-text {
  position: absolute;
  top: -34px;
  right: 0;
  /* Changed from 7px to 0 to align with button edge */
  padding: 8px 12px;
  background: #66c4ff;
  color: var(--text-primary);
  letter-spacing: 1.3px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  z-index: 99;
  pointer-events: none;
  transition: var(--transition);
  box-shadow: var(--shadow-secondary);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  /* Add these properties to prevent cutoff */
  min-width: max-content;
  transform: translateX(0);
}

/* Alternative approach - position tooltip to the left if it gets cut off */
.tooltip-text-left {
  position: absolute;
  top: -34px;
  left: 0;
  right: auto;
  padding: 8px 12px;
  background: #66c4ff;
  color: var(--text-primary);
  letter-spacing: 1.3px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  z-index: 99;
  pointer-events: none;
  transition: var(--transition);
  box-shadow: var(--shadow-secondary);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  transform: translateX(-100%);
}

/* Adjust the arrow position for left-aligned tooltip */
.tooltip-text-left::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 12px;
  /* Changed from right to left */
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #66c4ff transparent transparent transparent;
}

/* Update the main tooltip arrow positioning */
.tooltip-text::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 12px;
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #66c4ff transparent transparent transparent;
}

/* Ensure the info icon container doesn't clip the tooltip */
.info-icon {
  position: absolute;
  top: 0.4375em;
  right: 0.5625em;
  background: transparent;
  padding: 0;
  margin: 0;
  border: none;
  z-index: 10;
  overflow: visible;
  /* Add this to prevent clipping */
}

/* Alternative: Center the tooltip above the button */
.tooltip-text-center {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: #66c4ff;
  color: var(--text-primary);
  letter-spacing: 1.3px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  z-index: 99;
  pointer-events: none;
  transition: var(--transition);
  box-shadow: var(--shadow-secondary);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.tooltip-text-center::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #66c4ff transparent transparent transparent;
}

/* ========================================
   MODAL COMPONENTS
   ======================================== */
.rules-modal[hidden] {
  display: none;
}

.rules-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 26, 0.98);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.4s ease;
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 0.125em;
  border-radius: 16px;
  box-shadow: var(--shadow-hover);
  max-width: 520px;
  width: 94%;
  animation: fadeIn 0.4s ease;
  font-family: 'Segoe UI', sans-serif;
  line-height: 1.3;
  overflow-y: auto;
  max-height: 80vh;
}

.close {
  position: absolute;
  top: 0;
  right: 7px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.close:hover {
  color: #ff6b6b;
  transform: scale(1.3);
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 22px;
  margin-top: 12px;
  color: var(--soft-blue);
  text-align: center;
  font-weight: 600;
}

.modal-content ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-content li {
  background: rgb(13 15 22 / 94%);
  padding: 1px;
  border-left: 2px solid var(--soft-blue);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.modal-content li:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.modal-content a {
  color: var(--accent-gradient);
  text-decoration: underline;
  transition: color 0.3s;
}

.modal-content a:hover {
  color: #4facfe;
}

.modal-content .note {
  margin-top: 10px;
  font-style: italic;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--card-border);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }

  100% {
    transform: translateY(0px);
  }
}

/* .fade-in {
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
}


.fade-out {
  animation: fadeOut 0.6s ease forwards;
} */

.add-quote-container {
  animation: fadeIn 0.6s ease-out;
}

.quote-display-container {
  animation: fadeIn 0.8s ease-out;
}

.search-quote-container {
  animation: fadeIn 1s ease-out;
}

.floating {
  animation: float 6s ease-in-out infinite;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (min-width: 300px) {
  .main-container-wrapper {
    grid-template-columns: 1fr;
    padding: .6em 0.5em;
    margin-bottom: 6rem;
  }

  .add-quote-container,
  .quote-display-container,
  .search-quote-container {
    width: 100%;
    margin-bottom: 1.5rem;
  }

  .modal-content h2 {
    font-size: 20px;
    margin-bottom: 22px;
    margin-top: 12px;
  }

  .modal-content li {
    padding: 3px;
    /* border-left: 2px solid var(--soft-blue); */
    font-size: 13px;
  }
}

@media (min-width: 400px) {
  .modal-content h2 {
    font-size: 20px;
    margin-bottom: 22px;
    margin-top: 12px;
  }

  .modal-content li {
    padding: 4px;
    border-left: 3px solid var(--soft-blue);
  }
}

@media (min-width: 560px) {
  .main-container-wrapper {
    padding: 1.65em 1.55em;
  }

  .card {
    padding: 1.5em;
  }


  .modal-content ul {
    padding: 0 1.5rem;
  }


}

@media (min-width: 992px) {
  .main-container-wrapper {
    grid-template-columns: 1fr 1fr;
    margin-top: 0.5em;
    margin-bottom: 5rem;
  }

  .add-quote-container {
    display: flex;
    flex-direction: column;
    grid-row: 1;
    align-items: stretch;
    justify-content: center;
  }

  .add-quote-container label {
    margin-bottom: 0.5rem;
  }

  .quote-display-container {
    grid-row: 1;
    grid-column: 2;
  }

  .quote-item {
    padding: 1rem;
  }

  .search-quote-container {
    grid-column: span 2;
  }
}