/**
 * =========================================
 * QUESTION REVIEW - Component Styles
 * =========================================
 *
 * Specific styles for question voting and review page
 * Dependencies: main.css (loaded before this file)
 */

/* ============================================
 * ALERT COMPONENT
 * ============================================ */
.alert {
  padding: var(--spacing-md, 1em);
  border: 1px solid var(--color-warning, #ffc107);
  background-color: var(--color-warning-bg, #fff3cd);
  color: var(--color-warning-text, #856404);
  border-radius: var(--radius-sm, 0.25rem);
  text-align: center;
  font-size: var(--font-size-base, 1em);
}

/* ============================================
 * ACCORDION/MODAL HYBRID COMPONENT
 * Desktop: Accordion behavior
 * Mobile: Modal overlay behavior
 * ============================================ */

/* Mobile First: Modal Backdrop (hidden by default) */
.accordion-modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop, 1099);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.accordion-modal-backdrop.is-visible {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

/* Accordion Container */
.accordion {
  max-width: 300px;
  width: 100%;
  background: transparent;
  display: flex;
  flex-direction: column;
  position: relative;
}

.accordion-item {
  width: 100%;
  margin-bottom: 0.25em;
}

.accordion-button {
  background: var(--color-bg-tertiary, rgb(44, 41, 56));
  color: var(--color-text-primary, rgb(244, 244, 244));
  padding: 0.625em;
  font-weight: bold;
  font-size: clamp(0.5em, 1vw, .9em);
  cursor: pointer;
  text-align: center;
  border: none;
  border-radius: var(--radius-md, 0.5em);
  transition: var(--transition-color, background-color 0.3s);
  white-space: nowrap;
  position: relative;
}

.accordion-button:hover {
  background-color: var(--color-bg-elevated, rgb(91, 87, 109));
}

/* Desktop: Traditional Accordion Collapse */
.accordion-collapse {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
}

.accordion-body {
  background-color: var(--color-bg-secondary, rgb(51, 46, 54));
  padding: 15px;
  border: 1px solid var(--color-border-default, #ddd);
  border-top: none;
  border-radius: 0 0 var(--radius-sm, 5px) var(--radius-sm, 5px);
  line-height: 1.6;
  box-shadow: 0 2px 5px var(--color-shadow-sm, rgba(0, 0, 0, 0.1));
}

.accordion-body .info-text {
  font-size: 0.8em;
  color: var(--color-text-secondary, #e0cdcd);
  text-shadow: 2px 2px 4px rgba(220, 166, 225, 0.22);
  margin-bottom: 0.5em;
}

.accordion-body .info-text::before {
  content: "🔹 ";
  font-size: 1.2em;
  color: var(--color-info, #007BFF);
}

.accordion-header {
  border-radius: var(--radius-md, 10px) var(--radius-md, 10px) 0 0;
}

/* Mobile: Modal Behavior */
@media (max-width: 767px) {
  /* Transform accordion into modal cards */
  .accordion-modal-backdrop.is-visible .accordion {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--color-bg-primary, rgb(51, 46, 54));
    border-radius: var(--radius-lg, 12px);
    padding: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-content, 1100);
  }

  /* Modal mode: All accordions visible at once */
  .accordion-modal-backdrop.is-visible .accordion-collapse {
    max-height: none !important;
    overflow: visible;
    margin-bottom: 1rem;
  }

  /* Modal mode: Style adjustments */
  .accordion-modal-backdrop.is-visible .accordion-item {
    margin-bottom: 1rem;
  }

  .accordion-modal-backdrop.is-visible .accordion-button {
    background: var(--color-accent-purple, #6c5ce7);
    font-size: 1rem;
    padding: 0.875rem;
    pointer-events: none; /* No clicking in modal mode */
  }

  .accordion-modal-backdrop.is-visible .accordion-body {
    border: none;
    background: transparent;
    padding: 1rem 0.5rem;
  }

  /* Add close button in modal mode */
  .accordion-modal-backdrop::before {
    content: "✕";
    position: fixed;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    z-index: var(--z-modal-close, 1101);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: background 0.3s;
  }

  .accordion-modal-backdrop::before:hover {
    background: rgba(0, 0, 0, 0.8);
  }

  /* Hide normal accordion on mobile */
  .accordion:not(.accordion-modal-backdrop .accordion) {
    display: none;
  }

  /* Show "View Rules" button on mobile */
  .rules-trigger-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 1.5rem;
    padding: 1rem;
    background: var(--color-accent-purple, #6c5ce7);
    color: white;
    border: none;
    border-radius: var(--radius-md, 0.5em);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-button, background 0.3s);
  }

  .rules-trigger-btn:hover {
    background: var(--color-accent-purple-dark, #5b48c7);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
  }
}

/* Desktop: Hide mobile trigger button */
@media (min-width: 768px) {
  .rules-trigger-btn {
    display: none;
  }

  .accordion-modal-backdrop {
    display: none !important;
  }
}

/* ============================================
 * TABLE COMPONENT
 * ============================================ */
.table-wrapper {
  overflow-x: auto;
  padding: 0.75em;
  margin-bottom: 2rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

.table th,
.table td {
  padding: 8px;
  text-align: center;
  word-wrap: break-word;
  border: 1px solid var(--color-border-default, rgb(128, 127, 139));
}

td {
  background: var(--color-bg-tertiary, rgb(44, 41, 56));
}

.table>tbody>tr>td[data-label]::before {
  color: var(--color-accent-gold-dark, rgb(104, 90, 46));
}

/* ============================================
 * VOTING BUTTONS
 * ============================================ */
.upvote,
.downvote {
  background: rgba(60, 55, 75, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(108, 92, 231, 0.35);
  color: rgba(244, 244, 244, 0.9);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
  min-width: 40px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
  position: relative;
}

.upvote:hover:not(:disabled) {
  background: rgba(0, 184, 148, 0.35);
  border-color: rgba(0, 184, 148, 0.5);
  box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  color: rgba(129, 236, 236, 1);
}

.downvote:hover:not(:disabled) {
  background: rgba(214, 48, 49, 0.35);
  border-color: rgba(214, 48, 49, 0.5);
  box-shadow: 0 4px 12px rgba(214, 48, 49, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  color: rgba(255, 118, 117, 1);
}

.upvote:active:not(:disabled),
.downvote:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(108, 92, 231, 0.3);
}

/* Upvoted/Downvoted state - subtle colors */
.upvote.upvoted {
  background: rgba(0, 184, 148, 0.3);
  border-color: rgba(0, 184, 148, 0.45);
  color: rgba(129, 236, 236, 1);
  box-shadow: 0 2px 8px rgba(0, 184, 148, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.downvote.downvoted {
  background: rgba(214, 48, 49, 0.3);
  border-color: rgba(214, 48, 49, 0.45);
  color: rgba(255, 118, 117, 1);
  box-shadow: 0 2px 8px rgba(214, 48, 49, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.upvote.upvoted:hover:not(:disabled) {
  background: rgba(0, 206, 201, 0.45);
  border-color: rgba(0, 206, 201, 0.5);
  box-shadow: 0 4px 12px rgba(0, 206, 201, 0.3);
  transform: translateY(-3px);
}

.downvote.downvoted:hover:not(:disabled) {
  background: rgba(255, 118, 117, 0.45);
  border-color: rgba(255, 118, 117, 0.5);
  box-shadow: 0 4px 12px rgba(255, 118, 117, 0.3);
  transform: translateY(-3px);
}

/* Locked state - vote is permanently locked (past grace period or max changes) */
.upvote.locked,
.downvote.locked {
  cursor: not-allowed !important;
  opacity: 0.6;
  filter: grayscale(40%);
  position: relative;
}

.upvote.upvoted.locked {
  background: rgba(0, 184, 148, 0.2);
  border: 2px solid rgba(0, 184, 148, 0.4);
  box-shadow: 0 1px 4px rgba(0, 184, 148, 0.15);
}

.downvote.downvoted.locked {
  background: rgba(214, 48, 49, 0.2);
  border: 2px solid rgba(214, 48, 49, 0.4);
  box-shadow: 0 1px 4px rgba(214, 48, 49, 0.15);
}

/* Add lock icon to locked buttons */
.upvote.locked::before,
.downvote.locked::before {
  content: "🔒";
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 0.7em;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Locked buttons show reddish warning glow on hover/touch */
.upvote.locked:hover,
.downvote.locked:hover {
  transform: none !important;
  background: rgba(214, 48, 49, 0.25) !important;
  border-color: rgba(214, 48, 49, 0.5) !important;
  box-shadow: 0 0 12px rgba(214, 48, 49, 0.4) !important;
  color: rgba(255, 118, 117, 0.8) !important;
}

/* Disabled/locked state - keeps vote color but dimmed with distinct styling */
.upvote.upvoted:disabled {
  background: rgba(0, 184, 148, 0.15);
  border: 2px dashed rgba(0, 184, 148, 0.4);
  color: rgba(129, 236, 236, 0.6);
  cursor: not-allowed;
  opacity: 0.7;
  filter: grayscale(20%);
}

.downvote.downvoted:disabled {
  background: rgba(214, 48, 49, 0.15);
  border: 2px dashed rgba(214, 48, 49, 0.4);
  color: rgba(255, 118, 117, 0.6);
  cursor: not-allowed;
  opacity: 0.7;
  filter: grayscale(20%);
}

/* Generic disabled (during processing) */
.upvote:disabled:not(.upvoted):not(.downvoted),
.downvote:disabled:not(.upvoted):not(.downvoted) {
  background: rgba(40, 35, 50, 0.5);
  border: 1px solid rgba(252, 211, 77, 0.4);
  color: rgba(252, 211, 77, 0.7);
  cursor: wait;
  opacity: 0.8;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.6; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Voting Button Icons - subtle arrows */
.upvote::after {
  content: "▲";
  font-size: 0.9em;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.downvote::after {
  content: "▼";
  font-size: 0.9em;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Vote Count Display */
.vote_count.positive {
  color: var(--color-accent-gold, rgb(220, 188, 72));
  font-weight: bold;
}

.vote_count.negative {
  color: var(--color-accent-gold-dark, rgb(104, 90, 46));
  font-weight: bold;
}

/* ============================================
 * PAGINATION COMPONENT
 * ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  margin-bottom: 1em;
}

.pagination>input[type="number"] {
  max-width: 39px;
  background: none;
  border: 1px solid var(--color-border-default, #ddd);
  border-radius: var(--radius-sm, 5px);
  text-align: center;
  color: var(--color-text-primary, rgb(244, 244, 244));
  cursor: pointer;
  transition: var(--transition-color, background-color 0.3s, box-shadow 0.3s);
  margin-left: .6em;
  margin-right: .03em;
}

.pagination>input[type="number"]:focus {
  outline: none;
}

.pagination>input[type="submit"] {
  background: var(--color-bg-tertiary, rgb(44, 41, 56));
  color: var(--color-text-primary, rgb(244, 244, 244));
  border: none;
  padding: 11px;
  border-radius: var(--radius-sm, 5px);
  cursor: pointer;
  transition: var(--transition-button, background-color 0.3s, box-shadow 0.3s);
}

.pagination>input[type="submit"]:hover {
  background: var(--color-bg-elevated, rgb(91, 87, 109));
  box-shadow: 0 4px 8px var(--color-shadow-md, rgba(0, 0, 0, 0.2));
}

.pagination>input[type="submit"]:focus {
  outline: none;
}

/* Results Per Page Select */
#resultsPerPage {
  max-width: 43px;
  background: none;
  border: 1px solid var(--color-border-default, #ddd);
  border-radius: var(--radius-sm, 5px);
  text-align: center;
  color: var(--color-text-primary, rgb(244, 244, 244));
  cursor: pointer;
  transition: var(--transition-color, background-color 0.3s, box-shadow 0.3s);
  margin: 0 .6em;
}

#resultsPerPage:focus {
  outline: none;
}

#resultsPerPage>option {
  background: var(--color-bg-tertiary, rgb(44, 41, 56));
  color: var(--color-text-primary, rgb(244, 244, 244));
  border-radius: 0 0 var(--radius-sm, 5px) var(--radius-sm, 5px);
  cursor: pointer;
  transition: var(--transition-color, background-color 0.3s);
}

#resultsPerPage>option:hover {
  background: var(--color-bg-elevated, rgb(91, 87, 109));
}

/* Pagination Links */
.pagination a,
.pagination span {
  padding: 8px 14px;
  text-decoration: none;
  border: 1px solid var(--color-border-default, #ddd);
  border-radius: var(--radius-sm, 5px);
  color: var(--color-text-primary, rgb(244, 244, 244));
  cursor: pointer;
  transition: var(--transition-color, background-color 0.3s);
}

.pagination a:hover {
  background-color: var(--color-bg-hover, #f0f0f0);
}

.pagination .current {
  background-color: var(--color-success, #4CAF50);
  color: white;
  border: 1px solid var(--color-success, #4CAF50);
}

.pagination .disabled {
  color: var(--color-text-disabled, #ddd);
  cursor: not-allowed;
  border: 1px solid var(--color-border-disabled, #ddd);
}

/* Custom-pagination */
.custom-pagination a,
.custom-pagination .disabled {
  margin: 0 5px;
}

.custom-pagination a:hover {
  background-color: var(--color-bg-hover-light, #e0e0e0);
}

/* ============================================
 * RESPONSIVE BREAKPOINTS
 * ============================================ */

/* Mobile: Stack table cells */
@media (max-width: 678px) {
  .table>tbody>tr:first-child {
    display: none;
  }

  .table th,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
  }

  .table td {
    flex: 1 1 50%;
    position: relative;
    padding: 10px;
  }

  .table td::before {
    content: attr(data-label);
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
  }
}

/* Tablet: Accordion row layout */
@media (min-width: 600px) {
  .accordion {
    max-width: 90%;
    flex-direction: row;
    justify-content: space-between;
    margin: .9em auto;
  }

  .accordion-item {
    font-size: 1.2em;
    margin-bottom: 0;
  }

  .accordion-item:nth-child(2) {
    margin: 0 1em;
  }
}

/* Very small phones: Full width table cells */
@media (max-width: 280px) {
  .table td {
    flex: 1 1 100%;
  }
}

/* ============================================
 * OWN QUESTION STYLING
 * ============================================ */

/* Highlight user's own questions */
.own-question {
  background-color: rgba(133, 128, 114, 0.1) !important;
  border-left: 3px solid var(--color-accent-gold, #858072);
}

/* Badge to show "You" next to author name */
.you-badge {
  display: inline-block;
  background: var(--color-accent-gold, #858072);
  color: var(--color-text-inverse, #0f0f1f);
  padding: 0.15em 0.5em;
  border-radius: var(--radius-sm, 0.25rem);
  font-size: 0.75em;
  font-weight: bold;
  margin-left: 0.5em;
  vertical-align: middle;
}

/* Notice for own questions */
.own-question-notice {
  color: var(--color-text-tertiary, #8080a0) !important;
  font-style: italic;
  text-align: center;
  font-size: 0.9em;
}

/* Ensure own questions stand out on hover */
.own-question:hover {
  background-color: rgba(133, 128, 114, 0.15) !important;
}

/* ============================================
 * VOTE NOTIFICATION MODAL
 * ============================================ */

/* Modal backdrop */
.vote-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.vote-modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
}

/* Modal container */
.vote-modal {
  background: linear-gradient(135deg, #1a1a2e 0%, #2D1B69 100%);
  border: 2px solid;
  border-radius: 16px;
  padding: 2rem;
  max-width: 90%;
  width: 450px;
  box-shadow: 0 20px 60px rgba(108, 92, 231, 0.4);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  position: relative;
}

.vote-modal-backdrop.show .vote-modal {
  transform: scale(1) translateY(0);
}

/* Modal variants */
.vote-modal.success {
  border-color: #00b894;
}

.vote-modal.warning {
  border-color: #fdcb6e;
}

.vote-modal.info {
  border-color: #6c5ce7;
}

.vote-modal.locked {
  border-color: #d63031;
}

/* Modal icon */
.vote-modal-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
  animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Modal title */
.vote-modal-title {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 1rem;
  color: var(--color-text-primary, #f8f9fa);
}

/* Modal message */
.vote-modal-message {
  text-align: center;
  line-height: 1.6;
  color: var(--color-text-secondary, rgba(255, 255, 255, 0.85));
  margin-bottom: 1.5rem;
}

.vote-modal-message strong {
  color: var(--color-accent-gold, #FCD34D);
  font-weight: 600;
}

/* Modal timer */
.vote-modal-timer {
  background: linear-gradient(135deg, rgba(252, 211, 77, 0.15) 0%, rgba(251, 191, 36, 0.15) 100%);
  border: 1px solid rgba(252, 211, 77, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: rgba(252, 211, 77, 0.9);
}

.vote-modal-timer strong {
  background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  filter: drop-shadow(0 2px 8px rgba(252, 211, 77, 0.4));
}

/* Modal button */
.vote-modal-button {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #6c5ce7 0%, #9333EA 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.vote-modal-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(108, 92, 231, 0.4);
}

.vote-modal-button:active {
  transform: translateY(0);
}

/* Mobile responsive */
@media (max-width: 480px) {
  .vote-modal {
    padding: 1.5rem;
    width: 95%;
  }

  .vote-modal-icon {
    font-size: 2.5rem;
  }

  .vote-modal-title {
    font-size: 1.25rem;
  }
}
