/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --text: #e5e7eb;
  --text-light: #9ca3af;
  --border: #374151;
  --bg: #1f2937;
  --bg-secondary: #111827;
  --bg-card: #1f2937;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: #0f172a;
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* Container */
.container {
  max-width: 700px;
  margin: 0 auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text);
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.95;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.toggle-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:hover {
  background: var(--bg-secondary);
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
}

/* Cards */
.card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.success-card {
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid var(--success);
}

.card h2, .card h3 {
  margin-bottom: 1.25rem;
  color: var(--text);
}

.card h2 {
  font-size: 1.5rem;
}

.card h3 {
  font-size: 1.25rem;
}

/* Form Elements */
textarea,
input[type="text"] {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 1rem;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

textarea {
  min-height: 150px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Textarea Container with Counter */
.textarea-container {
  position: relative;
  margin-bottom: 1rem;
}

.textarea-container textarea {
  margin-bottom: 0;
  padding-bottom: 2.5rem; /* Make space for counter */
}

.char-counter {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-light);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  pointer-events: none;
  user-select: none;
}

/* Buttons */
.primary-btn,
.secondary-btn,
.danger-btn {
  padding: 0.875rem 2rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

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

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.secondary-btn {
  background: var(--bg-secondary);
  color: var(--text);
  border: 2px solid var(--border);
}

.secondary-btn:hover {
  background: white;
}

.danger-btn {
  background: var(--danger);
  color: white;
}

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

.icon-btn {
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-secondary);
  transform: scale(1.1);
}

/* Button Group */
.button-group {
  display: flex;
  gap: 0.75rem;
}

.button-group .secondary-btn,
.button-group .danger-btn {
  flex: 1;
  width: auto;
}

/* Session ID Display */
.session-id-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 2px solid var(--success);
}

.session-id-display code {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  letter-spacing: 0.05em;
}

/* QR Code Container */
.qr-code-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.qr-code {
  display: flex;
  justify-content: center;
  align-items: center;
}

.qr-code img {
  border-radius: 8px;
}

.qr-info {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--bg-secondary);
  font-weight: 500;
}

/* Text Display */
.text-display {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  max-height: 400px;
  overflow-y: auto;
}

.text-display pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0;
}

/* Result Header */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.result-header h3 {
  margin: 0;
}

/* Info Text */
.info-text {
  color: var(--text-light);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 1rem;
}

/* Mode Sections */
.mode-section {
  display: none;
}

.mode-section.active {
  display: block;
}

/* Result Sections */
.result.hidden {
  display: none;
}

/* Messages */
.error-message,
.success-message {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 500;
  text-align: center;
  animation: slideIn 0.3s ease-out;
}

.error-message {
  background: #fef2f2;
  color: var(--danger);
  border: 2px solid var(--danger);
}

.success-message {
  background: #ecfdf5;
  color: var(--success);
  border: 2px solid var(--success);
}

.error-message.hidden,
.success-message.hidden {
  display: none;
}

/* Loading Spinner */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading.hidden {
  display: none;
}

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

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  color: white;
  opacity: 0.9;
  font-size: 0.9rem;
}

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

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

/* Cookie Consent Banner */
#cookie-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 3px solid var(--primary);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  animation: slideUp 0.4s ease-out;
  border: 1px solid var(--border);
  border-bottom: none;
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.cookie-text {
  flex: 1;
}

.cookie-text p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.cookie-text strong {
  font-size: 1.1rem;
  color: var(--text);
}

.cookie-text a {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 500;
}

.cookie-buttons {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cookie-accept {
  background: var(--primary);
  color: white;
}

.cookie-accept:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.cookie-decline {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}

.cookie-decline:hover {
  background: var(--bg-secondary);
  border-color: var(--text-light);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Legal Pages */
.legal-page {
  background: #0f172a;
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  min-height: 100vh;
  padding: 2rem 1rem;
}

.legal-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 3rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.legal-container h1 {
  color: var(--text);
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 1rem;
}

.legal-container .subtitle {
  color: var(--text-light);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.legal-container .last-updated {
  color: var(--text-light);
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: 2rem;
}

.legal-container section {
  margin-bottom: 2.5rem;
}

.legal-container h2 {
  color: var(--text);
  font-size: 1.75rem;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

.legal-container h3 {
  color: var(--text);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
}

.legal-container p {
  margin-bottom: 1rem;
  line-height: 1.8;
}

.legal-container ul,
.legal-container ol {
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.legal-container li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.legal-container a {
  color: var(--primary);
  text-decoration: underline;
}

.legal-container a:hover {
  color: var(--primary-hover);
}

.legal-container strong {
  font-weight: 600;
  color: var(--text);
}

.back-link {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border);
}

.back-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.back-link a:hover {
  color: var(--primary-hover);
  transform: translateX(-5px);
}

.faq-item {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--primary);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-left-color: var(--primary);
}

.faq-item h2 {
  margin-top: 0;
  font-size: 1.35rem;
  color: var(--primary);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.footer-links a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
  .cookie-content {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem 1.5rem;
    gap: 1.25rem;
  }

  .cookie-buttons {
    width: 100%;
  }

  .cookie-btn {
    flex: 1;
  }

  .legal-container {
    padding: 2rem 1.5rem;
  }

  .legal-container h1 {
    font-size: 2rem;
  }
}

@media (max-width: 640px) {
  body {
    padding: 1rem 0.5rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .card {
    padding: 1.5rem;
  }

  .mode-toggle {
    gap: 0.5rem;
  }

  .toggle-btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .session-id-display {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .session-id-display code {
    font-size: 1.25rem;
    text-align: center;
  }

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

  .button-group {
    width: 100%;
  }

  .legal-container {
    padding: 1.5rem 1rem;
  }

  .legal-container h1 {
    font-size: 1.75rem;
  }

  .legal-container h2 {
    font-size: 1.5rem;
  }

  .cookie-text p {
    font-size: 0.9rem;
  }
}

/* Ad Containers */
.ad-container {
  max-width: 728px;
  margin: 2rem auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ad-container ins {
  background: transparent !important;
}

@media (max-width: 768px) {
  .ad-container {
    min-height: 50px;
  }
}

/* Confirmation Modal */
.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: background 0.2s ease;
}

.confirm-modal-overlay.active {
  background: rgba(0, 0, 0, 0.8);
}

.confirm-modal-overlay.closing {
  background: rgba(0, 0, 0, 0);
}

.confirm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 450px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.2s ease;
}

.confirm-modal-overlay.active .confirm-modal {
  transform: scale(1);
  opacity: 1;
}

.confirm-modal-overlay.closing .confirm-modal {
  transform: scale(0.9);
  opacity: 0;
}

.confirm-modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 2px solid var(--border);
}

.confirm-modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text);
}

.confirm-modal-body {
  padding: 2rem;
}

.confirm-modal-body p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}

.confirm-modal-footer {
  padding: 1.5rem 2rem;
  border-top: 2px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.confirm-btn-cancel,
.confirm-btn-confirm {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.confirm-btn-cancel {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}

.confirm-btn-cancel:hover {
  background: var(--bg-secondary);
  border-color: var(--text-light);
}

.confirm-btn-confirm {
  background: var(--danger);
  color: white;
}

.confirm-btn-confirm:hover {
  background: var(--danger-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

@media (max-width: 640px) {
  .confirm-modal-header,
  .confirm-modal-body,
  .confirm-modal-footer {
    padding: 1.25rem 1.5rem;
  }

  .confirm-modal-footer {
    flex-direction: column-reverse;
  }

  .confirm-btn-cancel,
  .confirm-btn-confirm {
    width: 100%;
  }
}
