/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

 /* app/assets/stylesheets/application.css */
body {
  font-family: Arial, Helvetica, sans-serif;
  padding: 1rem;
}

nav {
  justify-content: flex-end;
  display: flex;
  font-size: 0.875em;
  gap: 0.5rem;
  max-width: 1024px;
  margin: 0 auto;
  padding: 1rem;
}

nav a {
  display: inline-block;
}

main {
  max-width: 1024px;
  margin: 0 auto;
}

.alert,
.error {
  color: red;
}

.notice {
  color: green;
}

section.school {
  display: flex;
  gap: 1rem;
  flex-direction: row;
}

section.school img {
  border-radius: 8px;
  flex-basis: 50%;
  max-width: 50%;
}

.students-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.students-section h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: #333;
  font-size: 1.5rem;
}

.student-search-container {
  position: relative;
  margin-bottom: 2rem;
}

.student-search-container label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #555;
}

#student-search {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

#student-search:focus {
  outline: none;
  border-color: #4a90e2;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
}

.search-result-item {
  padding: 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.search-result-item label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  margin: 0;
  font-weight: normal;
}

.search-result-item label strong {
  color: #333;
  font-size: 1rem;
}

.student-email {
  color: #666;
  font-size: 0.875rem;
}

.no-results,
.search-error {
  padding: 1rem;
  text-align: center;
  color: #666;
}

.search-error {
  color: #d32f2f;
}

.selected-students-container {
  margin-top: 2rem;
}

.selected-students-container h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #333;
  font-size: 1.25rem;
}

.selected-students-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.selected-students-list .no-selection {
  padding: 1rem;
  text-align: center;
  color: #999;
  font-style: italic;
}

.selected-student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.selected-student-item .student-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.selected-student-item strong {
  color: #333;
  font-size: 1rem;
}

.remove-student {
  background: #f44336;
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.remove-student:hover {
  background: #d32f2f;
}

.reason-selection-container {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e0e0;
}

.reason-selection-container label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #555;
  font-size: 1rem;
}

#detention-reason {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#detention-reason:focus {
  outline: none;
  border-color: #4a90e2;
}

#detention-reason:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
  color: #999;
}

.comments-container {
  margin-top: 1.5rem;
}

.comments-container label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #555;
  font-size: 1rem;
}

#detention-comments {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-family: Arial, Helvetica, sans-serif;
  resize: vertical;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#detention-comments:focus {
  outline: none;
  border-color: #4a90e2;
}

#detention-comments::placeholder {
  color: #999;
}

.details-container {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e0e0;
}

.details-container h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #333;
  font-size: 1.25rem;
}

.details-row {
  display: flex;
  gap: 1rem;
}

.details-field {
  flex: 1;
}

.details-container label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #555;
  font-size: 1rem;
}

#detention-type,
#cover-teacher,
#room,
#detention-time,
#detention-duration {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#detention-type:focus,
#cover-teacher:focus,
#room:focus,
#detention-time:focus,
#detention-duration:focus {
  outline: none;
  border-color: #4a90e2;
}

#detention-type:disabled,
#cover-teacher:disabled,
#room:disabled,
#detention-time:disabled,
#detention-duration:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
  color: #999;
}

.save-button-container {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
}

.btn-save {
  background-color: #4caf50;
  color: white;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-save:hover {
  background-color: #45a049;
}

.btn-save:active {
  background-color: #3d8b40;
}

.btn-save:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

.detentions-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.detentions-container h1 {
  margin-bottom: 1.5rem;
  color: #333;
}

.detentions-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.detentions-table thead {
  background-color: #4a90e2;
  color: white;
}

.detentions-table th {
  padding: 1rem;
  text-align: left;
  font-weight: bold;
  font-size: 0.95rem;
}

.detentions-table td {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: top;
}

.detentions-table tbody tr:hover {
  background-color: #f9f9f9;
}

.detentions-table tbody tr:last-child td {
  border-bottom: none;
}

.no-comments {
  color: #999;
  font-style: italic;
}

.no-detentions {
  text-align: center;
  padding: 3rem;
  background: #f9f9f9;
  border-radius: 8px;
  border: 2px dashed #ddd;
}

.no-detentions p {
  margin: 1rem 0;
  color: #666;
  font-size: 1.1rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #f0f0f0;
  color: #333;
  text-decoration: none;
  border-radius: 4px;
  border: 1px solid #ddd;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: #e0e0e0;
}

.btn-primary {
  background-color: #4a90e2;
  color: white;
  border-color: #4a90e2;
}

.btn-primary:hover {
  background-color: #357abd;
}

.detention-form-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.detention-form-container h1 {
  margin-bottom: 1.5rem;
  color: #333;
}

.detention-form-container .students-section {
  margin-top: 0;
}

.actions-cell {
  white-space: nowrap;
}

.btn-action {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: 4px;
  border: 1px solid;
  transition: all 0.2s;
  margin-right: 0.5rem;
}

.btn-edit {
  background-color: #4a90e2;
  color: white;
  border-color: #4a90e2;
}

.btn-edit:hover {
  background-color: #357abd;
}

.btn-delete {
  background-color: #f44336;
  color: white;
  border-color: #f44336;
}

.btn-delete:hover {
  background-color: #d32f2f;
}

.edit-detention-form {
  background: #f9f9f9;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  max-width: 800px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #555;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
  transition: border-color 0.2s;
  font-family: Arial, Helvetica, sans-serif;
}

.form-control:focus {
  outline: none;
  border-color: #4a90e2;
}

textarea.form-control {
  resize: vertical;
}

.student-info-display {
  padding: 0.75rem;
  background: white;
  border: 2px solid #ddd;
  border-radius: 4px;
}

.student-info-display strong {
  color: #333;
  font-size: 1rem;
}

.form-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e0e0;
  display: flex;
  gap: 1rem;
}

.audit-logs-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.audit-logs-container h1 {
  margin-bottom: 1.5rem;
  color: #333;
}

.audit-logs-info {
  background: #e3f2fd;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  border-left: 4px solid #2196f3;
}

.audit-logs-info p {
  margin: 0;
  color: #1565c0;
}

.audit-logs-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.audit-logs-table thead {
  background-color: #424242;
  color: white;
}

.audit-logs-table th {
  padding: 1rem;
  text-align: left;
  font-weight: bold;
  font-size: 0.95rem;
}

.audit-logs-table td {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: top;
}

.audit-logs-table tbody tr:hover {
  background-color: #f9f9f9;
}

.audit-logs-table tbody tr:last-child td {
  border-bottom: none;
}

.audit-logs-table .timestamp {
  white-space: nowrap;
  color: #666;
  font-size: 0.9rem;
}

.action-cell {
  white-space: nowrap;
}

.action-badge {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: bold;
  text-transform: capitalize;
}

.action-badge.detention_created {
  background-color: #4caf50;
  color: white;
}

.action-badge.detention_updated {
  background-color: #ff9800;
  color: white;
}

.action-badge.detention_deleted {
  background-color: #f44336;
  color: white;
}

.user-email {
  color: #666;
  font-size: 0.875rem;
}

.comments-cell {
  max-width: 300px;
}

.no-data {
  color: #999;
  font-style: italic;
}

.no-audit-logs {
  text-align: center;
  padding: 3rem;
  background: #f9f9f9;
  border-radius: 8px;
  border: 2px dashed #ddd;
}

.no-audit-logs p {
  margin: 1rem 0;
  color: #666;
  font-size: 1.1rem;
}

.view-navigation {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.view-navigation .btn {
  font-weight: 500;
  transition: all 0.2s;
}

.view-navigation .btn-active {
  background-color: #4a90e2;
  color: white;
  border-color: #4a90e2;
  font-weight: bold;
}

.view-navigation .btn-active:hover {
  background-color: #357abd;
}

.filter-options {
  margin-bottom: 1.5rem;
}

.filter-options form {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-options label {
  font-weight: bold;
  color: #555;
  margin: 0;
}

.filter-options .form-select {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  background-color: white;
  cursor: pointer;
  min-width: 200px;
}

.filter-options .form-select:focus {
  outline: none;
  border-color: #4a90e2;
}

.student-vtg {
  font-size: 0.9em;
  color: #666;
}

.toggle-container {
  margin-bottom: 1.5rem;
}

.toggle-buttons {
  display: inline-flex;
  gap: 0;
  border: 2px solid #4a90e2;
  border-radius: 4px;
  overflow: hidden;
}

.toggle-btn {
  padding: 0.5rem 1.5rem;
  text-decoration: none;
  border: none;
  transition: all 0.2s;
  background-color: white;
  color: #4a90e2;
  font-weight: 500;
}

.toggle-btn:hover {
  background-color: #f0f7ff;
}

.toggle-btn.toggle-active {
  background-color: #4a90e2;
  color: white;
  font-weight: bold;
}

.toggle-btn.toggle-active:hover {
  background-color: #357abd;
}

.toggle-btn:not(:first-child) {
  border-left: 1px solid #4a90e2;
}

.charts-section {
  margin-bottom: 3rem;
}

.charts-section h2 {
  margin-bottom: 1.5rem;
  color: #333;
  font-size: 1.5rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.chart-container {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-container h3 {
  margin-bottom: 1rem;
  color: #555;
  font-size: 1.1rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    padding: 1rem;
  }
}

/* Login Page Styles */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1e3a8a 0%, #0f172a 100%);
  padding: 1rem;
}

.login-page ~ nav,
body:has(.login-page) nav {
  display: none;
}

.login-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 3rem;
  width: 100%;
  max-width: 450px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 100%;
  max-width: 250px;
  height: auto;
  margin: 0 auto 1.5rem;
  display: block;
}

.login-header h1 {
  margin: 0 0 0.5rem 0;
  color: #333;
  font-size: 1.75rem;
  font-weight: bold;
}

.login-header p {
  margin: 0;
  color: #666;
  font-size: 1rem;
}

.alert-message {
  background-color: #fee;
  border: 1px solid #fcc;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  color: #c33;
  font-size: 0.95rem;
}

.notice-message {
  background-color: #efe;
  border: 1px solid #cfc;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  color: #3c3;
  font-size: 0.95rem;
}

.login-form {
  margin-bottom: 1.5rem;
}

.form-field {
  margin-bottom: 1.5rem;
}

.form-field label {
  display: block;
  margin-bottom: 0.5rem;
  color: #333;
  font-weight: 600;
  font-size: 0.95rem;
}

.login-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-sizing: border-box;
  transition: all 0.3s ease;
  font-family: Arial, Helvetica, sans-serif;
}

.login-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-input::placeholder {
  color: #999;
}

.login-button {
  width: 100%;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: bold;
  color: white;
  background: linear-gradient(180deg, #1e3a8a 0%, #0f172a 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.35);
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.45);
}

.login-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.3);
}

.login-footer {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
}

.forgot-password-link {
  color: #667eea;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.forgot-password-link:hover {
  color: #764ba2;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .login-container {
    padding: 2rem 1.5rem;
  }
  
  .login-logo {
    max-width: 200px;
  }
  
  .login-header h1 {
    font-size: 1.5rem;
  }
}

/* Header Banner Styles */
#wrapperHeader {
  width: 100%;
  background-color: #003366;
  margin-bottom: 1rem;
}

#wrapperHeader table.main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

#wrapperHeader .header {
  padding: 0;
}

#wrapperHeader #logo {
  padding: 1rem;
  text-align: center;
}

#wrapperHeader #logo a {
  display: inline-block;
}

#wrapperHeader #logo img {
  max-width: 100%;
  height: auto;
  display: block;
}

#wrapperHeader #nav {
  background-color: #002244;
  padding: 0;
}

#wrapperHeader #nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

#wrapperHeader #nav li {
  margin: 0;
  padding: 0;
}

#wrapperHeader #nav h2 {
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
}

#wrapperHeader #nav a,
#wrapperHeader #nav button {
  display: block;
  padding: 0.5rem 1rem;
  color: white;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.75rem;
  transition: background-color 0.2s;
}

#wrapperHeader #nav a:hover {
  background-color: #003366;
}

/* Top-bar dropdowns: hover (desktop) + focus-within (keyboard) reveal the submenu. */
/* Sortable.js drag preview row */
.sortable-ghost {
  opacity: 0.4;
  background: #e0e7ff !important;
}

#wrapperHeader #nav .nav-dropdown {
  position: relative;
}

#wrapperHeader #nav .nav-dropdown-toggle {
  cursor: pointer;
}

#wrapperHeader #nav .nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background-color: #002244;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  z-index: 1000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  border-top: 1px solid #003366;
}

#wrapperHeader #nav .nav-dropdown:hover > .nav-dropdown-menu,
#wrapperHeader #nav .nav-dropdown:focus-within > .nav-dropdown-menu {
  display: block;
}

#wrapperHeader #nav .nav-dropdown-menu li {
  width: 100%;
}

#wrapperHeader #nav .nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  font-weight: normal;
  font-size: 0.78rem;
  white-space: nowrap;
}

#wrapperHeader #nav .nav-dropdown-menu .nav-dropdown-subitem a {
  padding-left: 1.75rem;
  color: #b8c5d6;
}

@media (max-width: 768px) {
  #wrapperHeader #nav ul {
    flex-direction: column;
    align-items: stretch;
  }
  
  #wrapperHeader #nav li {
    width: 100%;
  }
  
  #wrapperHeader #nav li[style*="margin-left:auto"] {
    margin-left: 0 !important;
  }

  /* On narrow screens, drop the absolute-positioned submenus inline. */
  #wrapperHeader #nav .nav-dropdown-menu {
    position: static;
    display: block;
    box-shadow: none;
    border-top: none;
    background-color: #001a36;
    padding-left: 0.5rem;
  }
}

/* User menu with logout */
#wrapperHeader .user-menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.5rem 1rem;
}

#wrapperHeader .user-name-display {
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
  padding-top: 0.5rem;
  padding-right: 0.5rem;
}

#wrapperHeader .logout-link {
  background: none;
  border: none;
  color: white;
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin: 0;
  font-weight: normal;
}

#wrapperHeader .logout-link:hover {
  opacity: 0.8;
}
