/* Custom styles for Opinora */

:root {
  --primary-color: #198754;
  --user-primary-color: #198754;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --info-color: #17a2b8;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
}

/* Font family customization */
[data-font-family="serif"] {
  font-family: Georgia, 'Times New Roman', Times, serif;
}

[data-font-family="monospace"] {
  font-family: 'Courier New', Courier, monospace;
}

[data-font-family="default"] {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Font size customization */
[data-font-size="small"] {
  font-size: 14px;
}

[data-font-size="medium"] {
  font-size: 16px;
}

[data-font-size="large"] {
  font-size: 18px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Link styles */
a {
  color: #0d9488;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #0f766e;
  text-decoration: none;
}

/* Apply user primary color where primary color is used */
.navbar-dark.bg-success {
  background-color: var(--user-primary-color) !important;
}

.btn-success {
  background-color: var(--user-primary-color);
  border-color: var(--user-primary-color);
}

.btn-success:hover {
  background-color: color-mix(in srgb, var(--user-primary-color) 85%, black);
  border-color: color-mix(in srgb, var(--user-primary-color) 80%, black);
}

.btn-outline-success {
  color: var(--user-primary-color);
  border-color: var(--user-primary-color);
}

.btn-outline-success:hover {
  background-color: var(--user-primary-color);
  border-color: var(--user-primary-color);
}

.text-success {
  color: var(--user-primary-color) !important;
}

.bg-success {
  background-color: var(--user-primary-color) !important;
}

.card-header.bg-success {
  background-color: var(--user-primary-color) !important;
}

.text-muted a:hover {
  color: var(--user-primary-color);
}

main {
  flex: 1;
}

.navbar-brand {
  font-weight: bold;
  font-size: 1.5rem;
}

.card {
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
}

.card-header {
  border-bottom: 2px solid rgba(0,0,0,0.1);
}

.entry-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.entry-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.list-group-item {
  border-left: none;
  border-right: none;
}

.list-group-item:first-child {
  border-top: none;
}

.list-group-item:last-child {
  border-bottom: none;
}

.list-group-item-action:hover {
  background-color: #f8f9fa;
  border-color: rgba(0,0,0,0.125);
}

footer {
  margin-top: auto;
  border-top: 1px solid #dee2e6;
}

.text-muted a {
  color: inherit;
}

/* Loading spinner */
.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--user-primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Form styles */
textarea.form-control {
  min-height: 150px;
  resize: vertical;
}

.form-label {
  font-weight: 500;
}

/* Vote buttons */
.vote-buttons {
  min-width: 40px;
}

.vote-btn {
  padding: 0;
  color: #6c757d;
  text-decoration: none;
  transition: color 0.2s;
  line-height: 1;
}

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

.vote-btn.active.upvote-btn {
  color: var(--success-color);
}

.vote-btn.active.downvote-btn {
  color: var(--danger-color);
}

.vote-score {
  font-size: 0.9rem;
  margin: 0.25rem 0;
  min-width: 30px;
  text-align: center;
}

/* Entry drawer styles */
.entry-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  z-index: 1000;
  max-height: 70vh;
  overflow-y: auto;
}

.entry-drawer.open {
  transform: translateY(0);
}

.entry-drawer-header {
  position: sticky;
  top: 0;
  background: var(--user-primary-color);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  z-index: 1;
}

.entry-drawer-header:hover {
  background: color-mix(in srgb, var(--user-primary-color) 85%, black);
}

.entry-drawer-content {
  padding: 1.5rem;
}

.entry-drawer-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.entry-drawer-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.entry-drawer-toggle.hidden {
  display: none;
}

/* Backdrop for drawer */
.entry-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  display: none;
}

.entry-drawer-backdrop.show {
  display: block;
}

/* Adjust body padding when drawer is present */
body.has-entry-drawer {
  /* padding-bottom: 80px; */
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .navbar-brand {
    font-size: 1.2rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .entry-drawer {
    max-height: 80vh;
  }
  
  .entry-drawer-toggle {
    bottom: 15px;
    right: 15px;
    width: 55px;
    height: 55px;
    font-size: 1.3rem;
  }
}

/* Entry link styles */
.entry-link {
  color: var(--user-primary-color);
  text-decoration: none;
  word-break: break-all;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.entry-link:hover {
  color: color-mix(in srgb, var(--user-primary-color) 85%, black);
  border-bottom-color: color-mix(in srgb, var(--user-primary-color) 85%, black);
}

/* Dark mode styles */
[data-theme="dark"] {
  --secondary-color: #adb5bd;
  --success-color: #28a745;
  --info-color: #17a2b8;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --light-color: #343a40;
  --dark-color: #f8f9fa;
  --bg-color: #1a1a1a;
  --card-bg: #2d2d2d;
  --text-color: #e9ecef;
  --text-muted: #adb5bd;
  --border-color: #495057;
}

[data-theme="dark"] body {
  background-color: var(--bg-color);
  color: var(--text-color);
}

[data-theme="dark"] .navbar {
  background-color: color-mix(in srgb, var(--user-primary-color) 40%, black) !important;
}

[data-theme="dark"] .card {
  background-color: var(--card-bg);
  color: var(--text-color);
}

[data-theme="dark"] .card-header {
  background-color: #343a40;
  color: var(--text-color);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .list-group-item {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

[data-theme="dark"] .list-group-item-action:hover {
  background-color: #3a3a3a;
}

[data-theme="dark"] footer {
  background-color: var(--card-bg) !important;
  border-top-color: var(--border-color);
}

[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

[data-theme="dark"] a {
  color: #5eead4;
}

[data-theme="dark"] a:hover {
  color: #99f6e4;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #343a40;
  color: var(--text-color);
  border-color: var(--border-color);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #3a3a3a;
  color: var(--text-color);
  border-color: var(--user-primary-color);
}

[data-theme="dark"] .dropdown-menu {
  background-color: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
  color: var(--text-color);
}

[data-theme="dark"] .dropdown-item:hover {
  background-color: #3a3a3a;
  color: var(--text-color);
}

[data-theme="dark"] .dropdown-divider {
  border-top-color: var(--border-color);
}

[data-theme="dark"] .entry-drawer {
  background-color: var(--card-bg);
}

[data-theme="dark"] .entry-drawer-header {
  background-color: color-mix(in srgb, var(--user-primary-color) 40%, black);
}

[data-theme="dark"] .entry-drawer-header:hover {
  background-color: color-mix(in srgb, var(--user-primary-color) 30%, black);
}

/* Dark mode toggle button */
.theme-toggle {
  position: relative;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle i {
  font-size: 1.2rem;
}

/* Markdown content styles */
.markdown-content p {
  margin-bottom: 0.75rem;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

.markdown-content ul {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.markdown-content li {
  margin-bottom: 0.25rem;
}

.markdown-content strong {
  font-weight: 600;
  color: inherit;
}

.markdown-content em {
  font-style: italic;
}

.markdown-preview p {
  margin-bottom: 0.75rem;
}

.markdown-preview p:last-child {
  margin-bottom: 0;
}

.markdown-preview ul {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.markdown-preview li {
  margin-bottom: 0.25rem;
}

.markdown-preview strong {
  font-weight: 600;
}

.markdown-preview em {
  font-style: italic;
}

/* Dark mode markdown styles */
[data-theme="dark"] .markdown-preview {
  background-color: #343a40 !important;
  color: var(--text-color);
}

[data-theme="dark"] .markdown-content strong {
  color: var(--text-color);
}

/* Dark mode breadcrumb styles */
[data-theme="dark"] .breadcrumb-item {
  color: var(--text-muted);
}

[data-theme="dark"] .breadcrumb-item.active {
  color: var(--text-color);
}

[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
  color: var(--text-muted);
}

/* Entry author styles */
.entry-author-info {
  padding: 0.5rem 0;
}

.author-link {
  color: inherit;
  transition: all 0.2s ease;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
}

.author-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
  transform: translateX(3px);
}

.author-link .author-avatar {
  color: var(--user-primary-color);
  transition: transform 0.2s ease;
}

.author-link:hover .author-avatar {
  transform: scale(1.15) rotate(-5deg);
}

.author-name {
  color: #495057;
  font-size: 0.95rem;
}

.author-link:hover .author-name {
  color: var(--user-primary-color);
}

/* Dark mode author styles */
[data-theme="dark"] .author-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .author-name {
  color: var(--text-color);
}

[data-theme="dark"] .author-link:hover .author-name {
  color: #5eead4;
}

/* Favorite button animations */
.favorite-btn {
  position: relative;
  transition: transform 0.2s ease;
}

.favorite-btn:hover {
  transform: scale(1.1);
}

.favorite-btn.favoriting {
  animation: heartBeat 0.6s ease-in-out;
}

.favorite-btn.unfavoriting {
  animation: heartBreak 0.4s ease-out;
}

@keyframes heartBeat {
  0% {
    transform: scale(1);
  }
  15% {
    transform: scale(1.3) rotate(-15deg);
  }
  30% {
    transform: scale(0.9) rotate(15deg);
  }
  45% {
    transform: scale(1.2) rotate(-10deg);
  }
  60% {
    transform: scale(0.95) rotate(10deg);
  }
  75% {
    transform: scale(1.1) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes heartBreak {
  0% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(0.8) rotate(-20deg);
  }
  50% {
    transform: scale(1.1) rotate(20deg);
  }
  75% {
    transform: scale(0.9) rotate(-10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* Particle effect for favorite */
.favorite-particle {
  position: absolute;
  pointer-events: none;
  font-size: 12px;
  animation: particleFloat 1s ease-out forwards;
  z-index: 1000;
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.5) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(360deg);
  }
}

/* Pinned Channels Widget Dark Mode Fixes */
[data-theme="dark"] .bg-primary.bg-opacity-10 {
  background-color: rgba(13, 202, 240, 0.15) !important;
}

[data-theme="dark"] .border-primary.border-opacity-25,
[data-theme="dark"] .border-primary.border-opacity-10 {
  border-color: rgba(13, 202, 240, 0.3) !important;
}

[data-theme="dark"] .text-primary {
  color: #5eead4 !important;
}

[data-theme="dark"] .list-group-item.bg-transparent {
  background-color: transparent !important;
  color: var(--text-color);
}

[data-theme="dark"] .list-group-item .text-dark {
  color: var(--text-color) !important;
}

[data-theme="dark"] .badge.bg-white.text-primary {
  background-color: #2d2d2d !important;
  color: #5eead4 !important;
  border-color: rgba(13, 202, 240, 0.3) !important;
}

/* Dark mode nav-tabs styles */
[data-theme="dark"] .nav-tabs {
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .nav-tabs .nav-link {
  color: var(--text-muted);
  border-color: transparent;
}

[data-theme="dark"] .nav-tabs .nav-link:hover {
  border-color: transparent transparent var(--border-color) transparent;
  color: #5eead4;
}

[data-theme="dark"] .nav-tabs .nav-link.active,
[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
  color: #5eead4;
  background-color: var(--card-bg);
  border-color: var(--border-color) var(--border-color) var(--card-bg) var(--border-color);
}

[data-theme="dark"] .card-header-tabs {
  margin-bottom: -1px;
}

[data-theme="dark"] .card-header-tabs .nav-link.active {
  border-bottom-color: var(--card-bg);
}
