/* --------- 1. Configuração Global e Variáveis --------- */
:root {
  --primary: #0b84ff; /* Main theme color */
  --primary-dark: #066bd1;
  --parking-primary: #0a937c; /* Parking specific color */
  --parking-primary-dark: #037965;
  --danger: #e53935;
  --danger-dark: #d32f2f;
  --success: #0a9d84;
  --success-dark: #037965;
  --warning: #ffcc00;
  --disponivel: var(--success);
  --reservado: var(--warning);
  --ocupado: var(--danger);

  --bg-light: #f7f9fc;
  --bg-dark: #0d1117;
  --text-light: #1e1e1e;
  --text-dark: #e6edf3;
  --border-light: #dfe4e8;
  --border-dark: #30363d;
  --card-bg-light: #ffffff; /* Use solid white for cards */
  --card-bg-dark: #161b22; /* Slightly lighter dark card */

  --radius-sm: 6px; /* Slightly smaller radius */
  --radius-md: 12px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.1);

  /* Default Light Mode */
  --bg: var(--bg-light);
  --text: var(--text-light);
  --border: var(--border-light);
  --card-bg: var(--card-bg-light);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--bg-dark);
    --text: var(--text-dark);
    --border: var(--border-dark);
    --card-bg: var(--card-bg-dark);
  }
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  font-size: 16px; /* Base font size */
}

/* --------- 2. Estilo da Página de Login (index.html) --------- */
body.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #e9f0ff 0%, #fdfbff 100%);
}
@media (prefers-color-scheme: dark) {
  body.login-page { background: linear-gradient(135deg, #0a0a0f, #151b25); }
}
.login-wrapper { width: 100%; max-width: 420px; }
.login-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px); /* Slightly less blur */
  border-radius: var(--radius-md);
  padding: 35px 30px;
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: fadeIn 0.5s ease-out;
  border: 1px solid var(--border);
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.login-card .logo { width: 100%; max-width: 250px; margin-bottom: 25px; border-radius: var(--radius-sm); }
.welcome-message { font-size: 1rem; line-height: 1.5; margin-bottom: 30px; color: var(--text); }
.welcome-message strong { color: var(--primary-dark); }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.input-group { position: relative; text-align: left; }
.input-group input {
  width: 100%; padding: 15px 14px; font-size: 1rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); outline: none; background: transparent; /* Cleaner look */
  color: var(--text); transition: all 0.2s ease;
}
.input-group label {
  position: absolute; top: 15px; left: 15px; color: var(--text); opacity: 0.6;
  font-size: 1rem; pointer-events: none; transition: all 0.2s ease;
}
.input-group input:focus { border-color: var(--primary); background: rgba(11, 132, 255, 0.05); } /* Subtle focus background */
.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
  top: -10px; left: 12px; font-size: 0.75rem; background: var(--card-bg);
  padding: 0 5px; color: var(--primary); opacity: 1;
}
/* Hide placeholder when focused or filled */
.input-group input:focus::placeholder { color: transparent; }
.input-group input:not(:placeholder-shown) { padding-top: 20px; padding-bottom: 10px; } /* Adjust padding when label moves */
.input-group input:not(:placeholder-shown) + label { top: 6px; } /* Fine-tune label position when filled */


/* --------- 3. Layout Geral dos Painéis (Admin/Booking/Parking) --------- */
.admin-container { /* Can be reused for booking/parking containers */
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}
@media (min-width: 768px) { .admin-container { padding: 30px; } }

/* --------- 4. Componentes Comuns --------- */

/* Títulos */
h1, h2, h3 { font-weight: 700; margin-bottom: 1rem; color: var(--text); }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); color: var(--primary); border-bottom: none; padding-bottom: 0; }
h2 {
    font-size: clamp(1.3rem, 4vw, 1.7rem); margin-top: 2rem; padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary); /* Use primary color for H2 border */
}
h3 { font-size: clamp(1.1rem, 3vw, 1.3rem); margin-top: 1.5rem; border-bottom: none; padding-bottom: 0; }

/* Formulários Gerais */
form {
  display: flex; flex-direction: column; gap: 1rem; background: var(--card-bg);
  padding: 25px; border-radius: var(--radius-md); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); margin-bottom: 1.5rem; /* Add space below forms */
}

/* Labels Gerais */
label { font-weight: 600; font-size: 0.9rem; margin-bottom: -0.25rem; /* Pull label closer to input */ }

/* Inputs e Selects Gerais (Aplicado a todos os painéis) */
input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
input[type="date"], input[type="time"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%; padding: 12px 14px; font-size: 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none; /* Remove default styling */ -webkit-appearance: none;
}
/* Style for placeholder text */
input::placeholder, textarea::placeholder { color: var(--text); opacity: 0.5; }

/* Focus styles for inputs/selects */
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus,
input[type="tel"]:focus, input[type="date"]:focus, input[type="time"]:focus,
input[type="number"]:focus, input[type="search"]:focus,
select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.25);
}
/* Add dropdown arrow for selects */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23${'var(--text)'.slice(4,-1)}'%3E%3Cpath fill-rule='evenodd' d='M8 11.5a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 0 1 .708-.708L8 10.293l3.646-3.647a.5.5 0 0 1 .708.708l-4 4A.5.5 0 0 1 8 11.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1.2em 1.2em;
    padding-right: 2.5rem; /* Make space for arrow */
}
/* Select text color fix */
select { color: var(--text); }
select option { background: var(--bg); color: var(--text); }


/* Botões Gerais */
button, .btn { /* Use .btn class for non-button elements styled as buttons */
  display: inline-block; /* Allows width auto */
  width: auto; /* Default to auto width */
  padding: 12px 25px; font-size: 1rem; font-weight: 600; border: none;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease;
  text-align: center; text-decoration: none; line-height: 1.4;
  /* Default Primary Button Style */
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 3px 8px rgba(11, 132, 255, 0.25);
}
button:hover, .btn:hover {
  background: linear-gradient(145deg, var(--primary-dark), var(--primary));
  transform: translateY(-2px); box-shadow: 0 5px 15px rgba(11, 132, 255, 0.3);
}
button:active, .btn:active { transform: translateY(0); box-shadow: 0 2px 5px rgba(11, 132, 255, 0.2); }
button:disabled, .btn:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; transform: none; background: #ccc; }

/* Full Width Button Modifier */
button.full-width { width: 100%; }

/* Botão de Logout/Excluir (Danger) */
.logout-btn, .delete-btn, .btn-danger {
  background: linear-gradient(145deg, var(--danger), var(--danger-dark));
  box-shadow: 0 3px 8px rgba(229, 57, 53, 0.25);
}
.logout-btn:hover, .delete-btn:hover, .btn-danger:hover {
  background: linear-gradient(145deg, var(--danger-dark), var(--danger));
  box-shadow: 0 5px 15px rgba(229, 57, 53, 0.3);
}
.logout-btn:active, .delete-btn:active, .btn-danger:active { box-shadow: 0 2px 5px rgba(229, 57, 53, 0.2); }

/* Botão Success */
.btn-success {
    background: linear-gradient(145deg, var(--success), var(--success-dark));
    box-shadow: 0 3px 8px rgba(10, 157, 132, 0.25);
}
.btn-success:hover {
    background: linear-gradient(145deg, var(--success-dark), var(--success));
    box-shadow: 0 5px 15px rgba(10, 157, 132, 0.3);
}
.btn-success:active { box-shadow: 0 2px 5px rgba(10, 157, 132, 0.2); }


/* Button Group */
.button-group { display: flex; gap: 0.75rem; flex-wrap: wrap; /* Allow wrapping */ }
/* Specific button group inside tables needs alignment */
td .button-group { justify-content: flex-start; /* Default align left in table cells */ }


/* --------- 5. Componentes Específicos --------- */

/* Tabelas (Desktop First Styles) */
.table-container {
  width: 100%; overflow-x: auto; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); margin-top: 1rem; /* Space above table */
}
table {
  width: 100%; border-collapse: collapse; font-size: 0.95rem;
}
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; /* Prevent wrapping by default */ }
th {
  background-color: var(--bg-light); /* Lighter header */ font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--primary); /* Header text primary color */
}
tr:last-child td { border-bottom: none; }
tr:hover { background-color: rgba(128, 128, 128, 0.04); }

/* DataTables Controls Wrapper */
.dataTables_wrapper { padding: 15px; background: var(--card-bg); border-radius: var(--radius-md); border: 1px solid var(--border); margin-bottom: 1.5rem; }
.dataTables_length, .dataTables_filter { margin-bottom: 1rem; } /* Space below controls */
.dataTables_info, .dataTables_paginate { margin-top: 1rem; font-size: 0.9rem; }
/* Style DataTables controls like general form inputs */
.dataTables_length label, .dataTables_filter label { font-weight: 600; font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.dataTables_length select, .dataTables_filter input[type="search"] {
    width: 100%; /* Default full width */ max-width: 250px; /* Limit width on desktop */
    /* Inherit base input styles */
    padding: 10px 12px; font-size: 0.95rem;
}
.dataTables_filter input[type="search"] { margin-left: 0 !important; } /* Override DT inline style */

/* Pagination Buttons */
.dataTables_paginate .paginate_button {
    padding: 8px 14px; margin: 0 4px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; background: var(--bg-light); color: var(--text); transition: all 0.2s;
    font-size: 0.9rem;
}
.dataTables_paginate .paginate_button:hover { background: var(--border-light); border-color: var(--border); }
.dataTables_paginate .paginate_button.current { background: var(--primary); color: white; border-color: var(--primary-dark); }
.dataTables_paginate .paginate_button.disabled { opacity: 0.5; cursor: not-allowed; background: var(--bg-light); color: #aaa; }


/* Modais */
.modal, .modaledit {
  display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); display: flex; justify-content: center;
  align-items: center; padding: 20px; animation: fadeInModal 0.3s ease-out;
}
@keyframes fadeInModal { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--card-bg); padding: 30px; border-radius: var(--radius-md); width: 100%;
  max-width: 550px; box-shadow: var(--shadow-md); position: relative; border: 1px solid var(--border);
  max-height: 90vh; overflow-y: auto; /* Allow scrolling */
}
.close, .close-modal {
  position: absolute; top: 12px; right: 18px; font-size: 2rem; font-weight: 700;
  color: var(--text); opacity: 0.4; cursor: pointer; transition: opacity 0.2s; line-height: 1;
}
.close:hover, .close-modal:hover { opacity: 0.8; }
.modal-content h2 { margin-top: 0; border-bottom-color: var(--primary); } /* Style modal title */
.modal-buttons { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem; }
@media (min-width: 768px) { .modal-buttons { flex-direction: row; justify-content: flex-end; } }
.modal-buttons button { width: 100%; } /* Full width buttons on mobile */
@media (min-width: 768px) { .modal-buttons button { width: auto; } } /* Auto width on desktop */


/* Modal de Termos */
.terms-box {
  background: rgba(255, 238, 204, 0.15); padding: 20px; border-left: 5px solid var(--warning);
  border-radius: var(--radius-sm); margin: 20px 0; text-align: left; border: 1px solid rgba(255, 204, 0, 0.3);
}
.terms-box p { font-size: 0.95rem; margin-bottom: 12px; line-height: 1.7; }
#acceptTermsBtn { background: var(--success); }
#acceptTermsBtn:hover { background: var(--success-dark); }
.terms-label { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 1rem; cursor: pointer; margin-top: 1rem; }
.terms-label input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; accent-color: var(--primary); }
.terms-label a { color: var(--primary); text-decoration: none; font-weight: 600; }
.terms-label a:hover { text-decoration: underline; }

/* Estatísticas */
#statsContainer, .booking-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); /* Slightly wider items */
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-item, .booking-stats p {
  padding: 20px; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); text-align: center; font-size: 0.95rem; font-weight: 600;
  box-shadow: var(--shadow-sm); transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-item:hover, .booking-stats p:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-item span, .booking-stats span {
  display: block; font-size: 2rem; color: var(--primary); font-weight: 700; margin-top: 5px;
}
#refreshStats { width: auto; padding: 10px 20px; margin-top: -0.5rem; /* Pull up slightly */ margin-bottom: 1.5rem; }


/* Filtros da Agenda (booking.html) */
.filters {
  display: flex; flex-direction: column; gap: 1rem; padding: 20px; background: var(--card-bg);
  border-radius: var(--radius-md); margin-bottom: 1.5rem; border: 1px solid var(--border);
}
.filter-group { display: flex; flex-direction: column; gap: 0.5rem; }
.filters label { font-weight: 600; font-size: 0.9rem; margin-bottom: 0; }
.filters select { width: 100%; min-width: 0; /* Override general select style */ }
@media (min-width: 768px) {
  .filters { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .filter-group { flex: 1 1 180px; /* Allow growth but set basis */ }
}

/* Calendário Lista (booking.html - antigo) */
.calendar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 1.5rem; }
.calendar-day {
  padding: 14px 10px; font-size: 0.95rem; font-weight: 600; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text); cursor: pointer;
  transition: all 0.2s ease; text-align: center; box-shadow: var(--shadow-sm);
}
.calendar-day:hover { background: var(--bg-light); border-color: var(--primary); transform: translateY(-2px); }
.calendar-day.selected {
  background: var(--primary); color: #fff; border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(11, 132, 255, 0.3); transform: scale(1.03) translateY(-1px);
}

/* Informações do Usuário (booking.html) */
.user-info {
  background: var(--card-bg); border: 1px solid var(--border); padding: 25px;
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.user-info h2 { margin-top: 0; border-bottom: none; }
.user-info p { margin-bottom: 0.5rem; font-size: 1rem; }
.user-info span { font-weight: normal; opacity: 0.9; }

/* Mensagens de Erro */
.error-msg, #loginError, #bookingError, #timeslotError {
  color: var(--danger-dark); margin-top: 1rem; font-size: 0.9rem; font-weight: 600;
  background: rgba(229, 57, 53, 0.1); padding: 12px 15px; border-radius: var(--radius-sm);
  border: 1px solid rgba(229, 57, 53, 0.3); display: block; /* Ensure it's block */
}
.error-msg:empty, #loginError:empty, #bookingError:empty, #timeslotError:empty { display: none; } /* Hide if empty */


/* --------- 6. Componente de Navegação (booking.html -> parking) --------- */
.nav-link-container { margin: 1.5rem 0; }
.nav-link-button {
  display: flex; align-items: center; gap: 1rem; padding: 18px 22px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--text); transition: all 0.2s ease; cursor: pointer;
}
.nav-link-button:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary);
}
.nav-link-icon { font-size: 2rem; }
.nav-link-text { flex-grow: 1; display: flex; flex-direction: column; }
.nav-link-text strong { font-size: 1.15rem; font-weight: 600; color: var(--primary-dark); }
.nav-link-text small { font-size: 0.9rem; opacity: 0.7; }
.nav-link-arrow { font-size: 1.8rem; font-weight: 700; color: var(--primary); transition: transform 0.2s ease; }
.nav-link-button:hover .nav-link-arrow { transform: translateX(5px); }


/* --------- 7. Calendário Moderno (booking.html) --------- */
.modern-calendar {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 20px; box-shadow: var(--shadow-sm); max-width: 380px; /* Slightly narrower */ margin: 1.5rem auto;
}
.mc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.mc-month-year { font-size: 1.15rem; font-weight: 600; color: var(--primary-dark); }
.mc-header button {
  width: 38px; height: 38px; padding: 0; font-size: 1.4rem; font-weight: 600; border-radius: 50%;
  background: transparent; color: var(--primary); border: 1px solid var(--border); box-shadow: none; line-height: 1;
}
.mc-header button:hover:not(:disabled) { background: var(--primary); color: #fff; border-color: var(--primary-dark); transform: scale(1.05); }
.mc-header button:disabled { opacity: 0.4; cursor: not-allowed; background: var(--bg-light); border-color: var(--border); color: #aaa; }
.mc-weekdays, .mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.mc-weekdays { margin-bottom: 0.75rem; font-size: 0.75rem; font-weight: 600; text-align: center; opacity: 0.6; }
.mc-day {
  width: 100%; aspect-ratio: 1 / 1; padding: 0; margin: 0; font-size: 0.9rem; font-weight: 500;
  border-radius: 50%; border: 2px solid transparent; background: transparent; color: var(--text);
  cursor: pointer; transition: all 0.15s ease-in-out; display: flex; align-items: center; justify-content: center;
}
.mc-day.today { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.mc-day:not(.disabled):hover { background: rgba(11, 132, 255, 0.1); border-color: rgba(11, 132, 255, 0.3); }
.mc-day.selected {
  background: var(--primary) !important; color: #fff !important; border-color: var(--primary-dark) !important;
  transform: scale(1.08); box-shadow: var(--shadow-sm); font-weight: 700;
}
.mc-day.disabled { opacity: 0.35; cursor: not-allowed; text-decoration: line-through; pointer-events: none; }
.mc-day.blank { background: transparent; cursor: default; pointer-events: none; }


/* --------- 8. FINAL Mobile Responsive Table (Admin Panel) --------- */
@media screen and (max-width: 768px) {

  /* 8a. Hide Desktop Table Header */
  .admin-container .table-container thead { display: none; }

  /* 8b. Style Rows as Cards */
  .admin-container .table-container tr {
    display: block; margin-bottom: 1.25rem; border: 1px solid var(--border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
    background: var(--card-bg); padding: 10px 15px; white-space: normal;
  }
  .admin-container .table-container table { white-space: normal; } /* Ensure wrapping */

  /* 8c. Style Cells (td) using Flexbox */
  .admin-container .table-container td {
    display: flex; justify-content: space-between; align-items: flex-start; /* Align top for long content */
    padding: 10px 0; border-bottom: 1px dashed var(--border);
    min-height: 2.5em; width: 100%; gap: 10px; /* Space between label & content */
  }
  .admin-container .table-container td:last-child { border-bottom: none; padding-bottom: 5px; }

  /* 8d. Style the Label (::before) */
  .admin-container .table-container td::before {
    content: attr(data-label); font-weight: 600; /* Slightly less bold */
    text-transform: uppercase; color: var(--primary); text-align: left;
    white-space: normal; font-size: 0.75rem; flex-shrink: 0; /* Prevent shrinking */
    padding-right: 5px; /* Minimal space */
    width: 35%; /* Fixed width for label */
  }

  /* 8e. Style Data Content Area */
  /* Target direct children (content) excluding buttons */
  .admin-container .table-container td > *:not(style):not(.button-group):not(button) {
    text-align: right; word-break: break-word; overflow-wrap: break-word;
    margin-left: auto; /* Push content right */ flex-grow: 1; /* Allow content to grow */
    min-width: 0; /* Allow shrinking */ font-size: 0.9rem; /* Slightly smaller content text */
  }
  /* Ensure status badges align right */
  .admin-container .table-container td span.status {
    margin-left: auto; white-space: nowrap; text-align: right;
    font-size: 0.8rem; /* Match label size */ padding: 3px 6px;
  }


  /* 8f. Correct Action Button Layout */
  .admin-container .table-container td[data-label="Ação"] {
      padding-top: 12px; /* Less space above buttons */
      /* Label takes 35%, buttons align right in remaining space */
  }
  .admin-container .table-container td[data-label="Ação"] .button-group {
    display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px;
    justify-content: flex-end; /* Align buttons right */
    width: auto; /* Group takes needed width */ margin-left: auto; /* Push group right */
  }
  .admin-container .table-container td[data-label="Ação"] .button-group button {
    width: auto; padding: 6px 10px; font-size: 0.85rem; margin: 0; flex-shrink: 0;
  }

 /* 8g. Style DataTables Inputs (Show Entries / Search) */
  .dataTables_wrapper { padding: 15px 0; } /* Remove side padding */
  .dataTables_length, .dataTables_filter {
    width: 100%; text-align: left; margin-bottom: 20px; /* Space below */
  }
  .dataTables_length label, .dataTables_filter label {
    display: flex; flex-direction: column; gap: 6px; /* Reduced gap */
    font-weight: 600; font-size: 0.9rem;
  }
  .dataTables_length select, .dataTables_filter input[type="search"] {
    width: 100%; padding: 10px 12px; font-size: 1rem; /* Match other inputs */
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg); color: var(--text); box-shadow: none;
    margin-top: 0; appearance: none; -webkit-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .dataTables_length select { /* Add arrow again */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23${'var(--text)'.slice(4,-1)}'%3E%3Cpath fill-rule='evenodd' d='M8 11.5a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 0 1 .708-.708L8 10.293l3.646-3.647a.5.5 0 0 1 .708.708l-4 4A.5.5 0 0 1 8 11.5z'/%3E%3C/svg%3E");
        background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.2em 1.2em; padding-right: 2.5rem;
  }
  .dataTables_filter input[type="search"] { margin-left: 0; }
  .dataTables_length select:focus, .dataTables_filter input[type="search"]:focus {
     outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.25);
  }
  .dataTables_info, .dataTables_paginate {
       margin-top: 1rem; width: 100%; text-align: center; font-size: 0.85rem;
  }
   .dataTables_paginate { padding-bottom: 10px; }
   .dataTables_paginate .paginate_button {
       padding: 5px 10px; margin: 0 2px; border: 1px solid var(--border); border-radius: var(--radius-sm);
       cursor: pointer; background: var(--bg-light); color: var(--text); transition: all 0.2s;
   }
   .dataTables_paginate .paginate_button:hover { background: var(--border-light); }
   .dataTables_paginate .paginate_button.current { background: var(--primary); color: white; border-color: var(--primary-dark); }
   .dataTables_paginate .paginate_button.disabled { opacity: 0.5; cursor: not-allowed; }

  /* Prevent horizontal scroll */
  .admin-container .table-container { overflow-x: hidden; border: none; padding: 0; background: none; box-shadow: none; }
  .admin-container .table-container table { table-layout: fixed; width: 100%; border: none; box-shadow: none; background: none;}

} /* End of @media screen and (max-width: 768px) */




/* --------- 14. FINAL DataTables Controls Styling (Admin Panel) --------- */

/* --- A. Base Styles (Apply Everywhere) --- */

/* Style the wrapper containing controls */
.admin-container .dataTables_wrapper { 
  padding: 1rem 0; /* Add vertical padding */
  margin-bottom: 1rem; /* Space below the controls wrapper */
  /* background: var(--card-bg); /* Optional: Give wrapper a card background */
  /* border: 1px solid var(--border); /* Optional: Add border */
  /* border-radius: var(--radius-md); /* Optional: Add radius */
  /* box-shadow: var(--shadow-sm); /* Optional: Add shadow */
}

/* Style the "Show Entries" and "Search" sections */
.admin-container .dataTables_length,
.admin-container .dataTables_filter {
  margin-bottom: 1.5rem; /* Space below each control section */
  /* Default alignment (changes on mobile) */
   width: auto; /* Allow them to sit side-by-side on desktop if space allows */
   float: left; /* Float length left */
}
.admin-container .dataTables_filter {
   float: right; /* Float search right */
   text-align: right;
}

/* Clear floats after controls */
.admin-container .dataTables_wrapper::after {
  content: "";
  display: table;
  clear: both;
}


/* Style the labels within controls */
.admin-container .dataTables_length label,
.admin-container .dataTables_filter label {
  display: flex; 
  align-items: center; /* Align label text and input vertically */
  gap: 0.5rem; /* Space between label text and input/select */
  font-weight: 600;
  font-size: 0.9rem; 
  color: var(--text);
}

/* **KEY:** Style the select and search input like general form inputs */
.admin-container .dataTables_length select,
.admin-container .dataTables_filter input[type="search"] {
  /* Dimensions and Spacing */
  width: auto; /* Default auto width */
  min-width: 80px; /* Minimum width for select */
  padding: 10px 12px; /* Adjusted padding */
  font-size: 0.95rem; /* Slightly smaller font */
  margin-left: 0.5rem; /* Space after label text */
  
  /* Appearance */
  border-radius: var(--radius-sm); 
  border: 1px solid var(--border); 
  background: var(--bg); 
  color: var(--text); 
  box-shadow: none; 
  -webkit-appearance: none; 
   appearance: none;
   transition: border-color 0.2s, box-shadow 0.2s; 

   /* Override DataTables inline styles if necessary */
   display: inline-block !important; 
}

/* Add dropdown arrow for the select */
.admin-container .dataTables_length select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23${'var(--text)'.slice(4,-1).replace('#', '')}'%3E%3Cpath fill-rule='evenodd' d='M8 11.5a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 0 1 .708-.708L8 10.293l3.646-3.647a.5.5 0 0 1 .708.708l-4 4A.5.5 0 0 1 8 11.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1em 1em;
  padding-right: 2rem; /* Make space for arrow */
}

/* Adjust search input width */
.admin-container .dataTables_filter input[type="search"] {
   min-width: 180px; /* Give search more space */
   margin-left: 0.5rem; /* Space after "Search:" label */
}


/* Focus styles */
.admin-container .dataTables_length select:focus,
.admin-container .dataTables_filter input[type="search"]:focus {
 outline: none;
 border-color: var(--primary);
 box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.25);
}

/* --- B. Mobile Adjustments --- */
@media screen and (max-width: 768px) {
  /* Stack controls vertically on mobile */
  .admin-container .dataTables_length,
  .admin-container .dataTables_filter {
      float: none; /* Remove floats */
      width: 100%; /* Take full width */
      text-align: left; /* Align left */
      margin-bottom: 1.5rem; /* Ensure space below */
  }

  .admin-container .dataTables_length label,
  .admin-container .dataTables_filter label {
      flex-direction: column; /* Stack label text above input/select */
      align-items: flex-start; /* Align label text left */
      gap: 0.5rem;
  }

  .admin-container .dataTables_length select,
  .admin-container .dataTables_filter input[type="search"] {
      width: 100%; /* Input/select takes full width */
      max-width: none; /* Remove desktop width limit */
      margin-left: 0; /* No margin needed when stacked */
      padding: 12px; /* Use standard input padding */
      font-size: 1rem; /* Use standard input font size */
  }
  
   /* Ensure pagination/info are centered */
   .admin-container .dataTables_info, 
   .admin-container .dataTables_paginate {
       float: none;
       width: 100%;
       text-align: center;
   }
   .dataTables_paginate {
       padding-top: 0.5rem; /* Add space above pagination */
   }
}