/* Reset and Base styles */
:root {
  --bg-color: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-hover: #e5e5e5;
  --text-color: #333333;
  --text-muted: #666666;
  --primary-color: #8b4513; /* Brown */
  --primary-hover: #6b3410;
  --card-bg: #fff;
  --border-color: #e0e0e0;
  --error-color: #dc3545;
  --error-hover: #c82333;
  --success-color: #4caf50;
  --candle-color: #f39c12;
  --header-height: 80px;
  --footer-height: 50px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme='dark'] {
  --text-color: #f5f5f5;
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --border-color: #333;
}

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

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Button Styles */
button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 16px;
  transition: background-color 0.3s, opacity 0.3s;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button.primary {
  background-color: var(--primary-color);
  color: white;
  margin-top: 1rem;
}

.button.primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.button.primary-blue {
  background-color: #2563eb;
  color: white;
  margin-top: 1rem;
}

.button.primary-blue:hover:not(:disabled) {
  background-color: #1d4ed8;
}

.button.secondary {
  background-color: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.button.secondary:hover:not(:disabled) {
  background-color: rgba(139, 69, 19, 0.1);
}

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

.button.danger:hover:not(:disabled) {
  background-color: #b71c1c;
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
  width: 100%;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 16px;
  background-color: var(--card-bg);
  color: var(--text-color);
  transition: border-color 0.3s;
}

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

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.char-counter {
  text-align: right;
  font-size: 14px;
  margin-top: 0.25rem;
  color: var(--text-color);
}

.text-red-500 {
  color: var(--error-color);
}

/* Layout */
.content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--footer-height);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--bg-color);
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.logo-container {
  display: flex;
  align-items: center;
}

.logo {
  height: 120px;
  transition: transform 0.3s ease;
}

.light-logo {
  display: block;
  filter: drop-shadow(0 0 10px rgba(139, 69, 19, 0.5));
}

.dark-logo {
  display: none;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

[data-theme='dark'] .light-logo {
  display: none;
}

[data-theme='dark'] .dark-logo {
  display: block;
}

.logo:hover {
  transform: scale(1.05);
}

.tagline {
  flex-grow: 1;
  text-align: center;
  font-size: 24px;
  color: var(--primary-color);
  margin: 0 1rem;
}

/* Theme toggle button */
.theme-toggle {
  margin-left: 1rem;
}

#theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s;
}

#theme-toggle-btn:hover {
  background-color: var(--hover-color);
}

#theme-icon {
  font-size: 1.5rem;
  transition: transform 0.3s;
}

#theme-toggle-btn:hover #theme-icon {
  transform: rotate(30deg);
}

/* Hide the icon that doesn't match the current theme */
[data-theme='dark'] .light-icon,
[data-theme='light'] .dark-icon {
  display: none;
}

.confession-form-container, .confessions-container {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

#confession-form {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(139, 69, 19, 0.15);
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  transition: box-shadow 0.3s ease;
}

#confession-form:hover {
  box-shadow: 0 6px 20px rgba(139, 69, 19, 0.2);
}

.error-message {
  color: var(--error-color);
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  background-color: rgba(211, 47, 47, 0.1);
}

/* Confessions Wall */
.sort-container {
  padding: 0 2rem;
  max-width: 800px;
  margin: 1rem auto 0;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

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

.confessions-wall {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.confession-card {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(139, 69, 19, 0.15);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  position: relative;
  transition: all 0.3s ease;
}

.confession-card:hover {
  box-shadow: 0 6px 20px rgba(139, 69, 19, 0.2);
  transform: translateY(-2px);
}

.confession-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 14px;
}

.confession-handle {
  font-weight: bold;
  color: var(--primary-color);
}

.confession-time {
  color: #666;
}

.confession-content {
  flex-grow: 1;
  margin-bottom: 1rem;
  word-break: break-word;
}

.confession-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.candle-button {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--candle-color);
  padding: 0.25rem 0.5rem;
}

.candle-button:hover {
  background-color: rgba(243, 156, 18, 0.1);
  border-radius: 4px;
}

.candle-icon {
  font-size: 18px;
}

.confession-edit-delete {
  display: flex;
  gap: 0.5rem;
}

.edit-button, .delete-button {
  padding: 0.25rem 0.5rem;
  font-size: 14px;
}

.no-confessions {
  text-align: center;
  padding: 2rem;
  background-color: var(--card-bg);
  border-radius: 8px;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(139, 69, 19, 0.15);
}

/* Footer */
footer {
  width: 100%;
  background-color: var(--bg-color);
  padding: 1rem 2rem;
  text-align: center;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
}

.footer-text {
  max-width: 800px;
  margin: 0 auto;
}

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

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: var(--bg-color);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 90%;
  color: var(--text-color);
}

.age-gate-content,
.terms-acceptance-content {
  text-align: center;
}

.age-gate-content h2,
.terms-acceptance-content h2 {
  color: var(--text-color);
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.age-gate-content p,
.terms-acceptance-content p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.button-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

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

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

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-color);
}

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

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

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

/* Fading Effect Based on Age */
.age-1 {
  opacity: 0.95;
}

.age-2 {
  opacity: 0.9;
}

.age-3 {
  opacity: 0.85;
}

.age-4 {
  opacity: 0.8;
}

.age-5 {
  opacity: 0.75;
}

.age-6 {
  opacity: 0.7;
}

.age-7 {
  opacity: 0.65;
}

/* Error State */
.error-state {
  padding: 2rem;
  text-align: center;
  background-color: rgba(211, 47, 47, 0.1);
  border-radius: 8px;
  color: var(--error-color);
  margin-top: 2rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  header {
    padding: 1rem;
    flex-direction: column;
  }
  
  .logo {
    height: 80px;
  }
  
  .tagline {
    font-size: 20px;
    margin: 0.5rem 0;
  }
  
  .confession-form-container, .confessions-container, .sort-container {
    padding: 1rem;
  }
  
  .age-gate-content {
    padding: 1.5rem;
  }
  
  .age-gate-buttons {
    flex-direction: column;
    gap: 1rem;
  }
  
  .modal-content {
    padding: 1.5rem;
  }
  
  .modal-buttons {
    flex-wrap: wrap;
  }
}

/* Dark Mode Specific Adjustments */
[data-theme='dark'] .logo {
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

[data-theme='dark'] .confession-card {
  box-shadow: 0 4px 16px rgba(255, 170, 120, 0.15);
}

[data-theme='dark'] .confession-card:hover {
  box-shadow: 0 6px 20px rgba(255, 170, 120, 0.2);
}

[data-theme='dark'] #confession-form {
  box-shadow: 0 4px 16px rgba(255, 170, 120, 0.15);
}

[data-theme='dark'] #confession-form:hover {
  box-shadow: 0 6px 20px rgba(255, 170, 120, 0.2);
}

[data-theme='dark'] .no-confessions {
  box-shadow: 0 4px 16px rgba(255, 170, 120, 0.15);
}

[data-theme='dark'] .modal-content {
  box-shadow: 0 8px 30px rgba(255, 170, 120, 0.25);
}

[data-theme='dark'] .age-gate-content {
  box-shadow: 0 8px 30px rgba(255, 170, 120, 0.25);
}

[data-theme='dark'] .button.primary-blue {
  background-color: #3b82f6;
}

[data-theme='dark'] .button.primary-blue:hover:not(:disabled) {
  background-color: #2563eb;
}

[data-theme='dark'] .loading-overlay {
  background-color: rgba(0, 0, 0, 0.7);
}

[data-theme='dark'] .loading-spinner {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary-color);
}

[data-theme='dark'] .confession-time {
  color: #aaa;
}