/* style.css */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&family=Lato:wght@400;600;700&display=swap');

:root {
  /* Design System Colors */
  --brown: #693D30;
  --brown-near-black: #160601;
  --slate: #1E293B;
  --slate-gray: #334155;
  --pale-blue: #F0F5FA;
  --white: #FFFFFF;
  --gray-blue: #ADB6BE;
  --ink: #111111;
  --tan: #C99E89;
  --rose: #D4A496;
  --beige: #F1E9E5;
  --light-gray: #F1F1F1;
  --off-white: #FBFAFA;
  --green: #2E9935;
  --error-red: #D32F2F;
  --error-bg: #FFEBEE;
  
  /* Fonts */
  --sans: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --alt: "Lato", "Helvetica Neue", Arial, sans-serif;
  
  /* Layout */
  --maxw: 875px;
}

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

html, body {
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--slate);
  background: var(--pale-blue);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header Layout ---- */
.header-hero {
  background: linear-gradient(135deg, var(--brown-near-black) 0%, var(--brown) 100%);
  color: var(--white);
  padding: 16px 24px;
  box-shadow: 0 4px 12px rgba(22, 6, 1, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-wrap {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: auto;
}

.logo-left img {
  height: 48px;
  max-width: 120px;
  object-fit: contain;
  filter: brightness(1) contrast(1.1);
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 8px;
  border-radius: 6px;
}

.logo-right img {
  height: 38px;
  max-width: 120px;
  object-fit: contain;
}

.header-title {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  flex-grow: 1;
  letter-spacing: 0.5px;
  color: var(--white);
}

/* ---- Main Container ---- */
.main-content {
  flex: 1;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* ---- Card Styling ---- */
.card {
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(105, 61, 48, 0.06);
  border: 1px solid rgba(201, 158, 137, 0.2);
  margin-bottom: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: 0 12px 35px rgba(105, 61, 48, 0.1);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--brown);
  margin-bottom: 18px;
  font-family: var(--sans);
  border-bottom: 2px solid var(--beige);
  padding-bottom: 8px;
}

/* ---- Form Controls ---- */
.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-gray);
  margin-bottom: 8px;
  font-family: var(--alt);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: var(--sans);
  color: var(--slate);
  background-color: var(--off-white);
  border: 1px solid var(--gray-blue);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.input-control:focus {
  border-color: var(--brown);
  box-shadow: 0 0 0 3px rgba(105, 61, 48, 0.15);
  background-color: var(--white);
}

.input-control:disabled {
  background-color: var(--light-gray);
  color: var(--gray-blue);
  cursor: not-allowed;
  border-color: var(--light-gray);
}

select.input-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27%23693D30%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpolyline%20points%3D%276%209%2012%2015%2018%209%27%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  padding-right: 40px;
}

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

/* ---- Loader and Spinner ---- */
.loader-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  margin: 12px 0;
  font-weight: 500;
  color: var(--brown);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(105, 61, 48, 0.2);
  border-top-color: var(--brown);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--brown-near-black);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--gray-blue);
  color: var(--white);
  cursor: not-allowed;
  opacity: 0.7;
}

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

.btn-secondary:hover {
  background: rgba(105, 61, 48, 0.05);
}

/* ---- Participant Details Box ---- */
.participant-details {
  background: var(--beige);
  border-left: 4px solid var(--brown);
  border-radius: 0 8px 8px 0;
  padding: 16px;
  margin-bottom: 24px;
  animation: fadeIn 0.4s ease-out;
}

.participant-details h4 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--brown);
  margin-bottom: 12px;
  font-family: var(--alt);
  letter-spacing: 0.5px;
}

.detail-row {
  display: flex;
  margin-bottom: 8px;
  font-size: 14px;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-label {
  width: 150px;
  font-weight: 600;
  color: var(--slate-gray);
  flex-shrink: 0;
}

.detail-value {
  color: var(--brown-near-black);
}

/* ---- Alerts and Cues ---- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.3s ease-out;
}

.alert-error {
  background-color: var(--error-bg);
  border-left: 4px solid var(--error-red);
  color: var(--error-red);
  font-weight: 500;
}

.alert-success {
  background-color: rgba(46, 153, 53, 0.1);
  border-left: 4px solid var(--green);
  color: var(--green);
  font-weight: 500;
}

.alert-info {
  background-color: var(--beige);
  border-left: 4px solid var(--brown);
  color: var(--brown);
  font-weight: 500;
}

/* ---- Form Expansion Styles ---- */
.form-section {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s cubic-bezier(0, 1, 0, 1), opacity 0.4s ease;
}

.form-section.visible {
  max-height: 20000px;
  overflow: visible;
  opacity: 1;
  transition: max-height 0.8s cubic-bezier(0.1, 1, 0.1, 1), opacity 0.5s ease-in 0.1s;
}

/* ---- Success Panel ---- */
.success-panel {
  text-align: center;
  animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-icon {
  width: 64px;
  height: 64px;
  background: rgba(46, 153, 53, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--green);
  font-size: 32px;
}

.success-title {
  font-size: 22px;
  color: var(--brown);
  margin-bottom: 12px;
  font-weight: 600;
}

.success-details {
  background: var(--off-white);
  border: 1px solid var(--light-gray);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  margin: 20px 0;
}

.success-details-title {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--slate-gray);
  margin-bottom: 8px;
  font-weight: 600;
  border-bottom: 1px solid var(--light-gray);
  padding-bottom: 4px;
}

/* ---- Referral History Table ---- */
.history-heading {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--brown);
  margin-bottom: 12px;
  font-family: var(--alt);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.history-empty {
  color: var(--slate-gray);
  font-size: 14px;
  padding: 16px;
  text-align: center;
  background: var(--off-white);
  border-radius: 8px;
  border: 1px dashed var(--gray-blue);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 4px;
}

.history-table th {
  background: var(--brown);
  color: var(--white);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  font-family: var(--alt);
  letter-spacing: 0.3px;
}

.history-table th:first-child {
  border-radius: 8px 0 0 0;
}

.history-table th:last-child {
  border-radius: 0 8px 0 0;
}

.history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--light-gray);
  color: var(--slate);
}

.history-table tbody tr:nth-child(even) {
  background: var(--off-white);
}

.history-table tbody tr:hover {
  background: var(--beige);
}

/* Clickable search result rows */
.search-result-row {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.search-result-row:hover {
  background: var(--beige) !important;
}

.search-result-row:active {
  background: var(--rose) !important;
}

/* Mobile: stack rows as cards */
@media (max-width: 600px) {
  .history-table thead {
    display: none;
  }

  .history-table,
  .history-table tbody,
  .history-table tr,
  .history-table td {
    display: block;
    width: 100%;
  }

  .history-table tr {
    background: var(--off-white);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    padding: 8px 0;
    margin-bottom: 10px;
  }

  .history-table td {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid var(--light-gray);
    text-align: right;
  }

  .history-table td:last-child {
    border-bottom: none;
  }

  .history-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--slate-gray);
    text-align: left;
    flex-shrink: 0;
    margin-right: 12px;
  }
}

/* ---- Footer ---- */
footer {
  background: var(--ink);
  color: var(--gray-blue);
  padding: 20px 0;
  font-size: 13px;
  font-family: var(--alt);
  text-align: center;
  margin-top: auto;
}

footer .footer-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---- Unauthorized overlay ---- */
.unauthorized-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 24px;
  text-align: center;
}

.unauthorized-card {
  max-width: 400px;
  padding: 40px 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  border-radius: 12px;
  border: 1px solid var(--beige);
  background: var(--off-white);
}

.unauthorized-icon {
  font-size: 48px;
  color: var(--brown);
  margin-bottom: 16px;
}

.unauthorized-card h1 {
  font-size: 22px;
  color: var(--brown-near-black);
  margin-bottom: 12px;
}

.unauthorized-card p {
  color: var(--slate-gray);
  font-size: 15px;
  margin-bottom: 24px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ---- Login Dialog ---- */
#login-dialog {
  margin: auto;
  top: 0;
}

#login-dialog::backdrop {
  background: rgba(22, 6, 1, 0.4);
  backdrop-filter: blur(3px);
}

/* ---- Responsiveness ---- */
@media (max-width: 600px) {
  .header-wrap {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
  
  .header-title {
    order: -1;
    font-size: 18px;
  }
  
  .logo-left img {
    height: 38px;
  }
  
  .logo-right img {
    height: 30px;
  }
  
  .card {
    padding: 20px;
  }
  
  footer .footer-wrap {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  
  .detail-row {
    flex-direction: column;
  }
  
  .detail-label {
    width: auto;
    margin-bottom: 2px;
  }
}
