/* ===================================
   CSS VARIABLES & RESET
   =================================== */
:root {
  /* BetterWorx Palette */
  --primary-color: #519ab3;       /* Primary Teal */
  --secondary-color: #303d45;     /* Dark Teal/Slate */
  --primary-light: #ebf5f7;       /* Light Teal Background */
  
  --light-bg: #f5f5f5;
  --white: #fcfcfc;
  --text-color: #333333;
  --text-secondary: #666666;
  --border-color: #e0e0e0;
  --message-bg: #f0f0f0;
  --black: #1c242e;
  --desktop-sidebar-width: 320px;
  --max-content-width: 1200px;
  --header-height: 71px;
  --footer-height: 110px;
  --border-radius: 10px;
  --transition-speed: 0.3s;
}

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

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--white);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

body.chat-active {
  overflow: hidden;
}

body.chat-active .footer,
body.chat-active .footer-divider {
  display: none;
}

.admin-skip-link {
  position: fixed;
  z-index: 2000;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.7rem 0.9rem;
  border: 2px solid #245f73;
  border-radius: 6px;
  color: #173943;
  background: var(--white);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(calc(-100% - 1rem));
}

.admin-skip-link:focus-visible {
  outline: 3px solid #245f73;
  outline-offset: 2px;
  transform: translateY(0);
}

#admin-main-content:focus-visible {
  outline: 3px solid #245f73;
  outline-offset: -3px;
}

/* ===================================
   SHARED COMPONENTS
   =================================== */

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--white);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
  display: block;
  width: clamp(132px, 8vw, 160px);
  height: auto;
  cursor: pointer;
}

.header-actions {
  display: flex;
  gap: 15px;
  align-items: center;
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn .icon-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--white);
  border: 1px solid var(--border-color);
  transition: all var(--transition-speed) ease;
}

.header-btn:hover .icon-circle {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}

.header-btn .icon-circle i {
  color: var(--primary-color);
}

.header-btn span {
  display: none;
}

.header-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
  display: none;
}

@media (min-width: 768px) {
  .header-link { display: inline; }
}

.header-link:hover {
  color: var(--primary-color);
}

.auth-btn {
  background-color: var(--primary-color);
  color: #ffffff; /* Ensure white text on primary button */
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-speed) ease;
}

.auth-btn:hover {
  background-color: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(81, 154, 179, 0.25); /* Adjusted to new Primary RGB */
}

.auth-btn i {
  color: #ffffff;
}

.user-avatar-btn {
  position: relative;
  isolation: isolate;
  width: 44px;
  height: 44px;
  margin: -4px;
  border-radius: 50%;
  border: 4px solid transparent;
  /* Deeper brand teal: keeps 4.5:1 contrast for the smaller initials. */
  background-color: #397b91;
  background-clip: padding-box;
  color: #ffffff;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  padding: 0;
}

/* Footer */
.footer-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0;
}

.footer {
  padding: 15px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  margin-top: auto;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  margin: 0 10px;
}

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

/* --- Search Component --- */
.search-input-container {
    position: relative;
}
.search-input-icon {
    position: absolute;
    left: 0.9375rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none; 
}
.search-input-field {
    width: 100%;
    padding: 0.625rem 0.9375rem 0.625rem 2.5rem; 
    border: 1px solid var(--border-color);
    border-radius: 0.375rem; 
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(81, 154, 179, 0.2);
}
.search-input-field:focus + .search-input-icon {
    color: var(--primary-color);
}

/* Auth Form */
.auth-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: left;
}

.form-input {
  padding: 12px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  font-size: 16px;
  width: 100%;
}


.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-submit {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: 5px;
  padding: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
}

.form-footer {
  text-align: center;
  margin-top: 15px;
  font-size: 14px;
  color: var(--text-secondary);
}

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

/* ===================================
   LEGAL & SETTINGS STYLES
   =================================== */
.legal-content {
    max-width: 760px;
    margin: 0 auto;
    padding: calc(var(--header-height) + 1.25rem) 1.25rem 3rem;
    line-height: 1.7;
    color: var(--text-color);
    font-size: 16px;
}
.legal-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--secondary-color);
}
.legal-content h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 2.5rem 0 0.75rem;
    padding: 0.5rem 0 0.5rem 0.875rem;
    border-left: 3px solid var(--primary-color);
    color: var(--secondary-color);
    line-height: 1.3;
}
.legal-content p,
.legal-content ul {
    margin: 0 0 1rem;
}
.legal-content ul {
    padding-left: 1.25rem;
}
.legal-content li {
    margin-bottom: 0.5rem;
}
.legal-content a {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Meta block (effective date / contact) sits just under H1 */
.legal-meta {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    margin-bottom: 2rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.legal-meta strong {
    color: var(--text-color);
}

/* TL;DR callout at the top of each legal page */
.legal-tldr {
    background: var(--primary-light);
    border-radius: var(--border-radius);
    padding: 1.25rem 1.25rem 1rem;
    margin-bottom: 2.5rem;
}
.legal-tldr-title {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin: 0 0 0.75rem;
}
.legal-tldr ul {
    margin: 0;
    padding-left: 1.125rem;
}
.legal-tldr li {
    margin-bottom: 0.375rem;
    color: var(--text-color);
}
.legal-tldr li:last-child {
    margin-bottom: 0;
}

.citations-page {
    max-width: 920px;
}

.citations-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    text-decoration: none;
}

.citations-back-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.citations-back-link i {
    color: currentColor;
}

.citation-list {
    list-style: none;
    padding: 0;
    margin: 2rem 0 0;
    counter-reset: citation;
}

.citation-item {
    counter-increment: citation;
    padding: 1.25rem 0;
    border-top: 1px solid var(--border-color);
}

.citation-item:last-child {
    border-bottom: 1px solid var(--border-color);
}

.citation-item h2 {
    margin: 0 0 0.75rem;
    padding: 0;
    border-left: none;
    font-size: 1.05rem;
}

.citation-item h2 a {
    color: var(--primary-color);
    text-decoration: none;
    margin-right: 0.35rem;
}

.citation-description {
    color: var(--text-color);
    margin-bottom: 0.875rem;
}

.citation-pending {
    color: var(--text-secondary);
    font-style: italic;
}

.citation-meta {
    display: grid;
    gap: 0.65rem;
    margin: 0;
}

.citation-meta div {
    display: grid;
    gap: 0.1rem;
}

.citation-meta dt {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.citation-meta dd {
    margin: 0;
    color: var(--text-color);
}

.citations-unavailable p:last-child {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .legal-content {
        padding: calc(var(--header-height) + 2rem) 2rem 3rem;
    }
    .legal-content h1 {
        font-size: 2rem;
    }
    .legal-content h2 {
        font-size: 1.25rem;
    }
    .citation-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.legal-links-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    border-top: none;
    margin-top: auto;
}
.legal-links-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    margin: 0 0.5rem;
}
.legal-links-footer a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}


/* ===================================
   UTILITIES & GLOBALS
   =================================== */
.loader-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--white);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
}

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--light-bg);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

.error-message {
  background-color: #ffebee;
  border: 1px solid #ffcdd2;
  color: #c62828;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  font-size: 14px;
}

.form-input.input-error {
  border-color: #c62828;
}

.field-error {
  color: #c62828;
  font-size: 0.78rem;
  margin-top: 0.3rem;
  display: none;
}

.success-message {
  background-color: #e8f5e9;
  border: 1px solid #c8e6c9;
  color: #2e7d32;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.fas, .fab, .fa {
  color: var(--primary-color);
}

.user-avatar {
  background-color: var(--primary-color);
  color: #ffffff;
}

.icon-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--white);
  border: 1px solid var(--border-color);
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Password rules checklist */
.password-rules {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s ease, opacity 0.4s ease, padding 0.5s ease;
}

.password-rules.visible {
  max-height: 200px;
  opacity: 1;
  padding: 0.5rem 0 0;
}

.password-rule {
  color: var(--text-secondary);
  transition: color 0.2s ease, transform 0.2s ease;
}

.password-rule .rule-icon {
  font-size: 0.65rem;
  margin-right: 0.35rem;
  color: #ccc;
  transition: color 0.2s ease;
}

.password-rule.passed {
  color: #2e7d32;
}

.password-rule.passed .rule-icon {
  color: #2e7d32;
}

/* ===================================
   DESKTOP RESPONSIVE (COMMON)
   =================================== */
@media (min-width: 768px) {
  .header {
    padding: 1rem 2rem;
  }
  .logo {
    width: clamp(132px, 8vw, 160px);
    height: auto;
  }
  .header-btn {
    font-size: 1.125rem;
  }
  .header-btn span {
    display: inline-block;
    font-size: 0.875rem;
  }
  .auth-btn {
    padding: 0.5rem 1.5rem;
    font-size: 0.875rem;
  }
  
  .footer {
    padding: 1.5rem 2rem;
  }
  .footer a {
    margin: 0 1rem;
  }
  .mobile-only {
    display: none !important;
  }
}
