/* 1. Theming & Variables */

:root {
  --brand: #0ea5e9;
  --link-color: #2563eb;
  --brand-highlight: #0ea5e92b;

  --background-primary: #f8fafc;
  --background-secondary: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --table-header-color: #64748b;

  --chip-bg: #f1f5f9;
  --chip-border: #e2e8f0;
  --chip-text: #475569;

  --score-badge-bg: #f1f5f9;
  --score-badge-border: #e2e8f0;
}

html[data-theme="dark"] {
  --link-color: #93c5fd;
  --brand-highlight: #0ea5e938;

  --background-primary: #0b1220;
  --background-secondary: #0f172a;
  --text-primary: #e5e7eb;
  --text-secondary: #d1d5db; /* Lighter grey for better contrast */
  --border-color: #334155;
  --table-header-color: #9ca3af;

  --chip-bg: #334155; /* Was too dark, now slate-700 */
  --chip-border: #475569; /* Was too dark, now slate-600 */
  --chip-text: #f1f5f9; /* Brighter text, slate-100 */

  --score-badge-bg: #1f2937;
  --score-badge-border: #334155;
}

/* Ensure .text-secondary is always visible in dark mode */
html[data-theme="dark"] .text-secondary {
  color: var(--text-secondary) !important;
}

/* Ensure outline buttons are visible in dark mode */
html[data-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: var(--text-secondary);
  --bs-btn-border-color: var(--border-color);
  --bs-btn-hover-color: var(--text-primary);
  --bs-btn-hover-bg: var(--border-color);
  --bs-btn-hover-border-color: var(--border-color);
  --bs-btn-active-bg: #475569; /* A slightly darker shade for active state */
}

/* FAQ Accordion Dark Mode Fixes */
html[data-theme="dark"] .accordion-button::after {
  /* Use a light-colored SVG for the arrow icon */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23d1d5db'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

html[data-theme="dark"] .accordion-button:not(.collapsed) {
  color: var(--text-primary);
  background-color: var(--background-secondary);
}

html[data-theme="dark"] .accordion-body {
  color: var(--text-secondary);
}

/* ==========================================================================
   2. Base & Global Styles
   ========================================================================== */

html {
  /* Adjust base font size to make the site appear slightly smaller at 100% zoom */
  font-size: 93.75%; /* 15px base, down from 16px */
}

body {
  background: var(--background-primary);
  color: var(--text-primary);
  transition: background-color 0.2s, color 0.2s;
}

a {
  color: var(--link-color);
}

/* ==========================================================================
   3. Components
   ========================================================================== */

/* Navbar & Footer */
.navbar,
.footer {
  background: var(--background-secondary);
  transition: background-color 0.2s;
}

.navbar .navbar-brand,
.navbar .nav-link {
  color: var(--text-primary);
}

.navbar .navbar-brand:hover {
  color: var(--text-primary);
}

.navbar .nav-link.active {
  color: var(--brand);
  font-weight: 600;
}

.navbar .nav-link:hover {
  color: var(--brand); /* Use the brand color or any blue you prefer */
}

/* Make navbar toggler icon visible in dark mode */
html[data-theme="dark"] .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(229, 231, 235, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}


.footer a:hover {
  color: var(--brand);
}

.navbar .navbar-brand:hover {
  text-decoration: none; /* Remove the hover effect */
}

/* Ensure SVG inside the theme toggle transitions smoothly */
#theme-toggle svg {
  transition: stroke 0.2s;
}

.hero h1 {
  font-size: 2.5rem; /* Adjust this value as needed */
}


.footer-link {
    color: var(--text-primary);
}

/* Table */
.table {
  --bs-table-bg: var(--background-secondary);
  --bs-table-border-color: var(--border-color);
  --bs-table-color: var(--text-primary);
  --bs-table-hover-color: var(--text-primary);
}

.table-hover > tbody > tr:hover > * {
  --bs-table-accent-bg: rgba(0, 0, 0, 0.04);
}

html[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  --bs-table-accent-bg: rgba(255, 255, 255, 0.04);
}

.table thead th {
  color: var(--table-header-color);
}

.table thead th:not([class*="text-"]) {
  text-align: center;
}


/* Hero Section */
.hero {
  background: radial-gradient(1200px 400px at 50% -10%, #f1f5f9, var(--background-primary));
}

html[data-theme="dark"] .hero {
  background: linear-gradient(110deg, #1e293b 0%, #0f172a 80%);
}

.tagline {
  font-weight: 700;
}

/* Chips & Badges */
.chip {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  padding: 0.2rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.8rem; /* Increased font size */
  display: inline-block;
  color: var(--chip-text);
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: default;
  user-select: none; /* Prevent text selection cursor */
}

.chip:hover {
  background-color: var(--brand-highlight);
  border-color: var(--brand);
  box-shadow: 0 0 8px var(--brand-highlight);
}

.hero-chip {
  cursor: pointer;
}

.hero-chip.active {
  background-color: var(--brand);
  color: white;
  border-color: var(--brand);
}

.chip-promoted {
  background: #facc15; /* Golden yellow */
  color: #422006;
  border-color: #facc15;
  font-weight: 600;
}

.score-badge {
  background: var(--score-badge-bg);
  border: 1px solid var(--score-badge-border);
  color: var(--text-primary);
  font-weight: 600;
}

/* Vote Buttons */
.vote-btn {
  border: 1px solid transparent;
  padding: 0.2rem 0.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.vote-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.vote-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.vote-up { background-color: #22c55e33; color: #166534; }
.vote-down { background-color: #ef444444; color: #991b1b; }
.vote-up:hover:not(:disabled) { background-color: #22c55e55; }
.vote-down:hover:not(:disabled) { background-color: #ef444466; }

html[data-theme="dark"] .vote-up { color: #86efac; }
html[data-theme="dark"] .vote-down { color: #fca5a5; }

.voted .vote-btn {
  opacity: 0.5; /* Fade out both buttons */
  cursor: not-allowed;
}

.voted .vote-btn.voted-up {
  background-color: #22c55e; /* Solid green for the one they clicked */
  color: white;
  opacity: 1;
}

/* Animation for row re-sorting */
@keyframes pop-row {
  0% {
    background-color: transparent;
    transform: scale(1);
  }
  50% {
    background-color: var(--brand-highlight);
    transform: scale(1.01);
  }
  100% {
    background-color: transparent;
    transform: scale(1);
  }
}

.row-pop {
  animation: pop-row 1.2s ease-out;
}

/* Affiliate Button */
.btn-get-deal {
  background: linear-gradient(45deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.3rem 0.8rem;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap; /* Prevent the button text from wrapping */
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);
}
.btn-get-deal:hover {
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.08);
}

/* Article Tile (for Blog/Reviews) */
.article-card-horizontal {
  background: var(--background-secondary);
  border-color: var(--border-color);
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  overflow: hidden; /* Ensures rounded corners are respected on child images */
}

.article-card-horizontal:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

html[data-theme="dark"] .article-card-horizontal:hover {
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.article-card-vertical {
  background: var(--background-secondary);
  border-color: var(--border-color);
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.article-card-vertical:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

html[data-theme="dark"] .article-card-vertical:hover {
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.article-card-vertical .card-img-top {
  height: 220px;
  object-fit: cover;
}

.article-card-vertical .card-title a {
  color: var(--text-primary);
  transition: color 0.2s;
}

.article-card-vertical:hover .card-title a {
  color: var(--brand);
}

.featured-article-card {
  background-color: var(--background-secondary);
  border: 1px solid var(--border-color);
  transition: box-shadow 0.2s ease-in-out;
}

.featured-article-card:hover {
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.featured-article-card .row {
  min-height: 400px; /* Set a minimum height for the card content */
}

.featured-article-card .col-lg-6:first-child {
  position: relative; /* Needed for absolute positioning of the image */
}

.featured-article-card .img-fluid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%; /* Make the image fill the container */
  object-fit: cover;
}

/* Truncate long excerpts in featured cards to prevent overflow */
.featured-article-card .card-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Limit the excerpt to 4 lines */
.featured-article-card .card-text.text-secondary {
  -webkit-line-clamp: 4;
}

/* Fix for carousel text visibility in dark mode */
html[data-theme="dark"] .featured-article-card .card-body {
  color: var(--text-primary);
}
html[data-theme="dark"] .featured-article-card .card-body .text-secondary {
  color: var(--text-secondary) !important;
}

.article-card-horizontal .col-md-3 {
  max-height: 200px; /* Set a max-height for the image container */
}

.article-card-horizontal .img-fluid {
  height: 100%;
  object-fit: cover;
}

.article-card-horizontal .text-secondary {
  color: var(--text-secondary) !important;
}

.article-card-horizontal .card-title {
  color: var(--text-primary);
}

/* Article Page Specific Styles */
.article-hero {
  position: relative;
  height: 40vh;
  min-height: 300px;
  background-size: cover;
  background-position: center;
  color: white;
}

.article-hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.1) 100%);
  display: flex;
  align-items: flex-end;
  padding-bottom: 3rem;
}

.article-content {
  font-size: 1rem;
  line-height: 1.7;
}

.article-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.article-content h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.article-content ul {
  padding-left: 1.5rem;
}

.author-box {
  background-color: var(--background-secondary);
  border: 1px solid var(--border-color);
}

.verdict-box {
  background-color: var(--chip-bg);
  border-left: 4px solid var(--brand);
}

html[data-theme="dark"] .verdict-box {
  background-color: #0f172a; /* Slightly darker than secondary bg */
}

.figure-caption {
  color: var(--text-secondary);
}

/* Pros and Cons Styling */
.pros-cons h2 {
  position: relative;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.pros-cons h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  width: 100%;
  border-radius: 2px;
}

.pros-cons .col-md-6:first-child h2::after {
  background-color: #16a34a; /* Darker Green */
}

.pros-cons .col-md-6:last-child h2::after {
  background-color: #dc2626; /* Darker Red */
}

.pros-list, .cons-list {
  list-style-type: none;
  padding-left: 0;
}

.pros-list li, .cons-list li {
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 0.5rem;
}

.pros-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  font-weight: bold;
  color: #16a34a; /* Green */
}

.cons-list li::before {
  content: '×';
  position: absolute;
  left: 0;
  font-weight: bold;
  color: #dc2626; /* Red */
}

/* Review Page Enhancements */
.scorecard-box, .summary-box {
  background-color: var(--background-secondary);
  border: 1px solid var(--border-color);
}

.scorecard-box .progress-bar {
  background-color: var(--brand);
}

.summary-table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border-color);
  font-size: 0.9rem;
}

.summary-table th {
  font-weight: 600;
  width: 45%;
}

.summary-table td, .summary-table th {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.summary-table tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Star Rating */
.star-rating {
  display: inline-block;
  font-size: 1.5rem;
  line-height: 1;
}

.star-icon {
  color: #ddd;
  font-size: 1.5rem;
  position: relative;
  display: inline-block;
}

.star-icon.full {
  color: gold;
}

.star-icon.half {
  background: linear-gradient(90deg, gold 50%, #ddd 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.star-icon.half::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  /* Use a CSS variable for the fill percentage, with a 50% fallback */
  background: linear-gradient(to right, #facc15 var(--fill-percentage, 50%), var(--border-color) var(--fill-percentage, 50%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html[data-theme="dark"] .star-icon.half::before {
  background: linear-gradient(to right, #facc15 var(--fill-percentage, 50%), #4b5563 var(--fill-percentage, 50%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Sticky sidebar for articles */
.sticky-sidebar {
  position: sticky;
  top: 2rem;
}

/* Prevent tagline from wrapping on desktop table view */
.vpn-info-cell small {
  white-space: nowrap;
}

/* --- Navigation Bar: Brand & IP Info --- */
.navbar-brand-stack {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  margin-right: auto; /* Pushes other items to the right */
}

.brand-text {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--text-primary);
}

.ip-info-block {
  font-size: 0.85rem; /* Base font size for the entire IP block */
  color: var(--text-secondary);
}

.ip-addr {
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-weight: 600;
  color: var(--text-primary);
}

.location-info {
  margin-left: 0.75rem;
  font-weight: 500;
}

.location-info svg {
  color: #ef4444; /* A noticeable red color */
  vertical-align: -0.1em; /* Better align icon with text */
}

.ip-status {
  color: #ffbf50;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 0.5rem; /* Add space after the IP address */
}

/* On mobile, hide the IP address to save space */
@media (max-width: 991.98px) {
  .ip-address-part {
    display: none;
  }
}

.article-hero {
  position: relative;
  height: 40vh;
  min-height: 300px;
  background-size: cover;
  background-position: center;
  color: white;
}


/* ==========================================================================
   4. Media Queries & Utilities
   ========================================================================== */

@media (max-width: 767px) {
  .article-card-horizontal .img-fluid {
    height: 200px;
    width: 100%;
  }
}

/* Reduce hero padding and font size on small screens */
@media (max-width: 767.98px) {
  .hero {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
  .hero h1 {
    font-size: 2rem; /* Reduce font size from display-5/6 */
  }
  .hero h1 .tagline {
    display: block; /* Force tagline to a new line on small screens */
  }
}

/* Admin Login Page Dark Mode Fix */
/* Target the card directly to override Bootstrap defaults */
html[data-theme="dark"] .admin-login-page .card {
  color: var(--text-primary);
  background-color: var(--background-secondary);
}

/* Fix for form labels in dark mode */
html[data-theme="dark"] .form-label {
    color: var(--text-primary);
}

/* Column Toggle Controls */
.column-toggle-controls {
  display: flex;
  align-items: center; /* Vertically align "Show Columns:" text with checkboxes */
}

.checkbox-group-mobile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px; /* Give dropdown some width */
}

.checkbox-group-desktop {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.column-toggle-controls .form-check-label {
    cursor: pointer;
    transition: color 0.2s ease-in-out;
}

.column-toggle-controls .form-check-label:hover {
    color: var(--brand);
}

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

/* Ensure dropdown text is visible in dark mode */
html[data-theme="dark"] .dropdown-menu .form-check-label {
    color: var(--text-primary);
}

/* Fix for invisible unchecked checkboxes */
/* When unchecked, ensure the border is visible against the background */
.form-check-input:not(:checked) {
    background-color: transparent;
    border-color: var(--text-secondary);
}

@media (max-width: 768px) {
  .hide-sm {
    display: none;
  }
  .table-responsive {
    border: 0;
  }

  /* Card-based layout for table on small screens */
  #vpntable {
    border: none;
  }

  #vpntable thead {
    display: none; /* Hide table headers */
  }

  #vpntable tr {
    display: block;
    background-color: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  }

  html[data-theme="dark"] #vpntable tr {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  #vpntable td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border: none;
    border-bottom: 1px solid var(--border-color);
  }

  #vpntable tr td:last-child {
    border-bottom: none;
  }

  /* Add labels using ::before pseudo-element */
  #vpntable td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    padding-right: 1rem;
  }
  /* Ensure the content inside the TD is right-aligned */
  #vpntable td > * {
    text-align: right;
    margin-left: auto; /* Pushes content to the right in a flex container */
  }

  /* --- Special handling for specific columns in card view --- */

  /* VPN Name/Logo column */
  #vpntable td.vpn-info-cell {
    display: block; /* Override flex for this cell */
    padding-bottom: 1rem;
  }
  #vpntable td.vpn-info-cell::before {
    display: none; /* No label needed */
  }

  /* Override right-alignment for the main VPN info block */
  #vpntable td.vpn-info-cell > * {
    text-align: left;
    margin-left: 0;
  }

  /* Votes column */
  #vpntable td.votes-cell {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  #vpntable td.votes-cell .d-flex {
    transform: scale(1.15); /* Make buttons and counts slightly larger */
  }

  /* Score column */
  #vpntable td.score-cell .score-badge {
    transform: scale(1.1);
  }

  /* Hide columns that are not needed in card view */
  #vpntable td[data-col-name="features"],
  #vpntable td[data-col-name="platform"],
  #vpntable td[data-label="Deal"] {
    display: none !important; /* Use important to override inline styles from JS */
  }
}

/* Loading Animation Styles */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7); /* Light semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10; /* Ensure it's on top */
    border-radius: inherit;
}

html[data-theme="dark"] .loading-overlay {
    background-color: rgba(0, 0, 0, 0.7); /* Dark semi-transparent background */
}

.loader {
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid var(--brand);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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

/* Dark Mode Adjustments for the Loader */
html[data-theme="dark"] .loader {
    border-color: #333; /* Darker grey */
    border-top-color: var(--brand);
}

/* Custom alert for unbiased review text */
.unbiased-review-alert {
  background-color: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand);
  color: var(--text-primary);
  padding: 1.25rem; /* Reduced padding */
  border-radius: 0.5rem;
}
.unbiased-review-alert .alert-heading {
  font-size: 1.5rem; /* Adjusted font size for balance */
}

/* Vote Prompt Modal Icon Color */
.vote-modal-icon {
  color: var(--brand);
}

/* Make the modal icon theme-aware for dark mode */
html[data-theme="dark"] .vote-modal-icon {
  color: var(--text-primary);
}