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

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-dark: #121212;
  --bg-card: #1A1A1A;
  --text-primary: #EAEAEA;
  --text-secondary: #AAAAAA;
  --accent-gold: #B38B29;
  --accent-gold-hover: #CCA342;
  --border-color: #333333;
  --danger-color: #b91c1c;
  --success-color: #16a34a;
  --font-serif: 'Lora', serif;
  --font-sans: 'Roboto', sans-serif;
}

/* --- Base & Typography --- */
body, html {
  margin: 0;
  padding: 0;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  margin-top: 1rem;
  margin-bottom: 0.8rem;
}

h2 { border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
a { color: var(--accent-gold); text-decoration: none; }
a:hover { color: var(--accent-gold-hover); text-decoration: underline; }

/* --- Layout --- */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 1rem auto;
  padding: 1rem;
}

/* Make tables scroll horizontally inside their cards, not the whole page */
.table-responsive {
  overflow-x: auto;
  /* ensure it doesn't shrink below full width container */
  -webkit-overflow-scrolling: touch;
}
.service-details {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Header & Navigation --- */
.main-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  position: relative; /* Add this */
  z-index: 1001;      /* Add this */
}
.logo {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.logo a { color: inherit; text-decoration: none; }
.main-nav { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.main-nav a, .main-nav form button {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.main-nav a:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
  text-decoration: none;
}
.main-nav form button { background: none; border: none; cursor: pointer; font-size: inherit; font-family: inherit; }

/* --- Dropdown Menus --- */
.nav-item {
  position: relative;
}
.dropdown-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  min-width: 200px;
  padding: 0.5rem;
  z-index: 1000;

}
.dropdown-menu a {
  padding: 0.5rem;
  color: var(--text-secondary);
}
.dropdown-menu a:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}
.nav-item:hover > .dropdown-menu {
  display: block;
}

.nav-user {
  border-left: 1px solid var(--border-color);
  padding-left: 1rem;
  margin-left: 0.5rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Mobile Navigation --- */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 1rem;
}

@media (max-width: 600px) {
  .nav-toggle {
    display: block;
  }

  .main-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
  }

.main-nav.open {
    display: flex;
    align-items: stretch; /* This is the change */
}

  .nav-item {
    width: 100%;
  }

  .dropdown-menu {
    position: static;
    border: none;
    background: none;
    box-shadow: none;
    padding: 0;
    margin-top: 0.5rem;
  }

  .dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-transform: none;
    font-weight: 400;
    text-align: center;
  }


  /* Style welcome message & logout on mobile */
  .nav-user {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
    margin-left: 0;
    color: var(--text-secondary);
    text-align: center;
  }
  .logout-form {
    width: 100%;
    margin: 0;
    border-top: 1px solid var(--border-color);
  }
  .logout-form button {
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: center;
    color: var(--text-secondary);
  }

  .dropdown-toggle::after {
    content: '▼';
    margin-left: 0.25rem;
    font-size: 0.75rem;
  }
  .dropdown-menu.open {
    display: block;
  }

}

/* --- Buttons --- */
.btn {
  position: relative; /* Required for pseudo-element positioning */
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--accent-gold);
  background-color: var(--accent-gold);
  color: var(--bg-dark);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  overflow: hidden; /* Hides the pseudo-element when it's outside the button */
  transition: color 0.4s ease-in-out, background-color 0.4s ease-in-out;
  z-index: 1;
}

/* The "Glow" element for primary buttons */
.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 250px; /* Large size for a soft glow */
  height: 250px;
  background-image: radial-gradient(circle, var(--accent-gold-hover) 0%, rgba(255,255,255,0) 60%);
  transform: translate(-50%, -50%) scale(0); /* Start scaled down to nothing */
  opacity: 0;
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
  z-index: -1; /* Place it behind the button's text */
}

.btn:hover::before {
  transform: translate(-50%, -50%) scale(1); /* Scale up to full size */
  opacity: 1;
}

.btn:active {
  transform: scale(0.98); /* Adds a subtle press-down effect */
}

/* --- Secondary / Outline Button --- */
.btn-secondary {
  background-color: transparent;
  color: var(--accent-gold);
  transition: color 0.4s ease-in-out; /* Only transition color initially */
}

/* The "Wipe" element for secondary buttons */
.btn-secondary::before {
  /* Overwrite the glow with a solid color for the wipe effect */
  background-image: none;
  background-color: var(--accent-gold);
  transform: scaleX(0); /* Start as a vertical line in the center */
  transform-origin: center;
  transition: transform 0.4s cubic-bezier(0.78, 0.13, 0.15, 0.86); /* A more dynamic easing function */
}

.btn-secondary:hover {
  color: var(--bg-dark); /* Change text color on hover */
}

.btn-secondary:hover::before {
  transform: scaleX(1); /* Wipe across the full width */
  opacity: 1; /* Ensure it's visible */
}

/* --- Danger Button --- */
.btn-danger {
  background-color: var(--danger-color);
  border-color: var(--danger-color);
  color: var(--text-primary);
}

/* Apply the same glow effect to the danger button, but with a reddish hue */
.btn-danger::before {
    background-image: radial-gradient(circle, #ef4444 0%, rgba(255,255,255,0) 60%);
}

/* --- Forms & Inputs --- */
.form-group {
  margin-bottom: 1.25rem;
}
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 4px;
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
}
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
input[type="checkbox"] { width: auto; }

/* --- Cards & Sections --- */
.card {
  background-color: var(--bg-card);
  padding: 1.5rem;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}
.card-header {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.grid-2,
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

@media (max-width: 480px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

.user-card > * { min-width: 0; }

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

/* Responsive wrapper for wide tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* On narrow screens, prevent page overflow by allowing only the table itself to scroll */
@media (max-width: 600px) {
  .table-responsive {
    overflow-x: auto;
  }
  .table-responsive > table {
    width: max-content;
    min-width: 100%;
  }
}
.main-nav a {
    text-align: center;
}
th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
th {
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 0.5px;
}
tbody tr:hover {
  background-color: #2a2a2a;
}
td form {
  display: inline-block;
  margin: 0 0.2rem;
}

/* --- Alerts & Messages --- */
.alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  text-align: center;
  font-weight: 500;
}
.alert-success {
  background-color: #14532d;
  color: #bbf7d0;
  border: 1px solid var(--success-color);
}
.alert-error {
  background-color: #7f1d1d;
  color: #fecaca;
  border: 1px solid var(--danger-color);
}

/* --- Geo Status --- */
.geo-status { margin-top: 10px; font-weight: 500; padding: 8px; border-radius: 3px; }
.geo-status-locating { background-color: #3730a3; color: #e0e7ff; }
.geo-status-success { background-color: #14532d; color: #bbf7d0; }
.geo-status-error { background-color: #7f1d1d; color: #fecaca; }

/* --- Misc --- */
.text-center { text-align: center; }
.mb-2 { margin-bottom: 2rem; }
.mt-2 { margin-top: 2rem; }

/* --- Responsive Logged Services Table (Mobile) --- */
@media (max-width: 600px) {
  .services-scroll table,
  .services-scroll thead,
  .services-scroll tbody,
  .services-scroll th,
  .services-scroll td,
  .services-scroll tr {
    display: block;
  }

  .services-scroll thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  .services-scroll tr {
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    padding: 0.5rem;
  }
  .services-scroll td {
    border: none;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-left: 45%;
  }
  .services-scroll td:last-child {
    border-bottom: none;
  }
  .services-scroll td:before {
    position: absolute;
    top: 0.5rem;
    left: 0.75rem;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    content: attr(data-label);
    font-weight: 500;
    color: var(--text-secondary);
  }
}

/* --- Responsive Service History Table (Mobile) --- */
@media (max-width: 600px) {
  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr {
    display: block;
  }
  .responsive-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  .responsive-table tr {
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    padding: 0.5rem;
  }
  .responsive-table td {
    border: none;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-left: 45%;
  }
  .responsive-table td:last-child {
    border-bottom: none;
  }
  .responsive-table td:before {
    position: absolute;
    top: 0.5rem;
    left: 0.75rem;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    content: attr(data-label);
    font-weight: 500;
    color: var(--text-secondary);
  }
}

/* --- Immunity Token Shimmer Effect --- */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Make immunity token label uppercase, larger, with spinning coins */
 .immunity-shimmer,
 .immunity-activated {
  text-transform: uppercase;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
}

.immunity-shimmer::before,
.immunity-shimmer::after,
.immunity-activated::before,
.immunity-activated::after {
  content: '🪙';
  display: inline-block;
  margin: 0 0.3rem;
  animation: coin-spin 1.5s linear infinite;
}

@keyframes coin-spin {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(360deg); }
}

/* Enlarge checkbox and bold immunity labels on small screens */
@media (max-width: 600px) {
  #immunity1,
  #immunity2 {
    transform: scale(1.5);
    margin-right: 0.5rem;
  }
  .immunity-shimmer,
  .immunity-activated {
    font-weight: 700;
  }
}

.immunity-shimmer {
  /* brighter golden-yellow shimmer for visibility */
  color: #FFD700;
  background: linear-gradient(90deg, #FFD700 25%, #FFEA00 50%, #FFD700 75%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 1.5s linear infinite;
}

.immunity-activated {
  color: var(--text-secondary);
}

.financial-summary {
  font-size: 1.2em; /* Makes all text in the box larger */
}

.summary-line {
  display: flex;
  justify-content: space-between;
  line-height: 1.7;
}

.summary-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.summary-value {
  font-weight: bold;
}

.summary-value.value-positive {
  color: var(--success-color); /* Green color for dollar figures */
}

/* Colors adjustments based on value */
.summary-value.value-adjustment.positive {
   color: var(--success-color);
}
.summary-value.value-adjustment.negative {
   color: var(--danger-color);
}
/* Spinning Animation for Barber Pole */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  animation: spin 2s linear infinite;
}

/* --- Header & Navigation --- */
.main-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 1001;
}
.logo {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.logo a { color: inherit; text-decoration: none; }


.main-nav a, .main-nav form button {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.main-nav a:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
  text-decoration: none;
}
.main-nav form button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

/* --- Improved Mobile Layout for Service Entry Checkboxes --- */
@media (max-width: 600px) {
    .user-card .form-checkbox {
        display: flex;
        flex-wrap: nowrap; /* Prevent wrapping of direct children */
        align-items: flex-start; /* Align items to the top */
        margin-bottom: 1rem;
    }

    .user-card .form-checkbox .adjust-input,
    .user-card .form-checkbox .override-checkbox {
        /* Ensure checkboxes don't shrink */
        flex-shrink: 0;
        margin-top: 0.15rem; /* Minor adjustment to align with the first line of text */
    }

    .user-card .form-checkbox label {
        /* Allow the label to grow and wrap */
        flex-grow: 1;
        line-height: 1.3; /* Adjust line-height for wrapped text */
        text-align: left;
    }

    .user-card .form-checkbox .deduction-multiplier {
        flex-shrink: 0;
        margin: 0 0.5rem;
    }

    /* Target the container for the override checkbox and its label */
    .user-card .form-checkbox .override-container {
        display: flex;
        align-items: center;
        margin-left: auto; /* Push it to the far right */
        flex-shrink: 0;
    }

    }

      .badge-submitted       { color: #2d882d; font-weight: bold;
  }
  .badge-pending         { color: #c0392b; font-weight: bold;
  }
  .count-input           { width: 60px; text-align: right;
  }
  .adjust-input          { margin-right: 0.3rem;
  }
  .adjust-input:disabled:checked + label,
  .status-checkbox:disabled:checked + label {
    color: #f1c40f;
    font-weight: bold;
  }
  h4.section-title {
    color: #f1c40f;
    font-weight: bold;
  }

  .service-entry
  {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem;
  }
  .service-details       { display: flex; align-items: center; gap: 0.5rem;
  }
  .service-price         { color: #669;
  }
  .service-subtotal      {
  margin: 0 0 2rem 1.5rem;
  font-size: 0.9em;
  font-style: italic;
  color: #fff;
  }
  .submission-status .submission-line { margin-bottom: 0.5rem; }
  .submission-status strong            { margin-right: 0.5rem; }

  /* [1] Clamp the section so nothing can spill horizontally */
.section-users {
  max-width: 100%;
  overflow-x: clip;                /* modern iOS friendly */
}

/* [2] Kill Bootstrap-style negative margins inside cards/sections */
.section-users .row {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* [3] Let children shrink instead of forcing overflow */
.section-users *,
.section-users .card,
.section-users .card * {
  min-width: 0;
}

/* [4] Make sure media never exceed their container */
.section-users img,
.section-users video,
.section-users canvas,
.section-users svg {
  max-width: 100%;
  height: auto;
}

/* [5] (You already did the grid fix; this keeps it scoped) */
.section-users .grid-2,
.section-users .grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}
@media (max-width: 480px) {
  .section-users .grid-2,
  .section-users .grid-3 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* [S1] Service Entry: hide the Reset control */
#service-entry form[action="/admin/services/reset"] {
  display: none !important;
}

@media (max-width: 600px) {
  .actions-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .actions-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
  }

  /* Target all button-like elements within the container */
  .actions-container .btn,
  .actions-container button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    flex-shrink: 0;

    /* --- NEW RULES FOR CONSISTENT HEIGHT --- */
    height: 30px;                /* Set an explicit height for all buttons */
    box-sizing: border-box;      /* Ensure padding is included in the height */
    display: inline-flex;        /* Use flexbox for perfect text centering */
    align-items: center;         /* Vertically center the text */
  }

  /* Ensure forms don't add extra margin or interfere with height */
  .actions-container form {
    margin: 0;
    display: flex; /* Helps the form conform to the button size */
  }
}