/* app/assets/stylesheets/admin.css */
/*
  Admin-only styles for the super-admin (public schema) UI.
  Intentionally does NOT import Bootstrap (admin layout loads Bootstrap via CDN).
*/

@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css");
@import url("https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css");
@import url("https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css");

/* Base */
body {
  font-family: 'Lato', 'Inter', sans-serif;
  color: #1f1f1f;
  background-color: #ffffff;
}

/* ---- Admin typography ---- */
body {
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:where(h1, h2, h3, h4, h5, h6) {
  color: var(--app-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.6rem, 1.1rem + 1.2vw, 2.2rem);
  font-weight: 800;
}

.app-topbar h1 {
  margin-bottom: 0;
}

.app-topbar h1 a {
  color: var(--app-link);
  text-decoration: none !important;
}

h2 {
  font-size: clamp(1.35rem, 1.05rem + 0.8vw, 1.75rem);
  font-weight: 750;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

h4 {
  font-size: 1.1rem;
  font-weight: 700;
}

h5 {
  font-size: 1rem;
  font-weight: 700;
}

h6 {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

:where(p, li, dt, dd) {
  color: var(--app-text);
  line-height: 1.6;
}

p {
  margin: 0 0 0.9rem;
}

:where(ul, ol) {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

:where(a) {
  color: var(--app-link);
  text-decoration: none !important;
}

:where(a:hover) {
  color: var(--app-link-hover) !important;
  text-decoration: none !important;
}

:where(small, .small, .text-muted) {
  color: var(--app-muted) !important;
}

:where(hr) {
  border: 0;
  border-top: 1px solid var(--app-border);
  opacity: 1;
  margin: 1.25rem 0;
}

:where(code, kbd, samp) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
}

:where(code) {
  background: color-mix(in srgb, var(--app-surface-2) 85%, transparent);
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 0.15rem 0.35rem;
}

:where(pre) {
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  overflow: auto;
  line-height: 1.5;
}

:where(pre code) {
  background: transparent;
  border: 0;
  padding: 0;
}

/* Navbar Logo */
.navbar-logo {
  height: 40px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
}

/* Brand navbar override (admin nav uses .navbar-dark.bg-dark) */
.navbar-dark.bg-dark {
  background-color: #A7D7A0 !important;
}

.navbar-dark .navbar-brand,
.navbar-dark .navbar-nav .nav-link {
  color: #1f1f1f !important;
}

.navbar-dark .navbar-brand:hover,
.navbar-dark .navbar-nav .nav-link:hover {
  color: #1f1f1f !important;
  opacity: 0.8;
}

/* ---- Sidebar layout styles (copied from application.css so admin can diverge) ---- */

/* Wrapper */
.wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow: visible;
}

/* App Layout Variables */
:root {
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 80px;
  --app-topbar-height: 70px;

  /* Theme (light defaults) */
  --app-bg: #ffffff;
  --app-surface: #f8f9fa;
  --app-surface-2: #fafafa;
  --app-text: #111827;
  --app-muted: #6b7280;
  --app-border: #e5e7eb;
  --app-table-border: #e2e8f0;
  --app-sidebar-bg: #a7ddc4;
  --app-sidebar-hover: #dcf0e7;
  --app-medical-card-bg: #edf3ec;
  --app-medical-card-bg-hover: #e0edde;
  --record-icon-bg: #d1f2eb;
  --record-icon-color: #0d6b47;
  --app-link: #225B73;
  --app-link-hover: #1a749b;

  --app-btn-bg: #f8f9fa;
  --app-btn-hover-bg: #e9ecef;

  --app-btn-primary-bg: #f8f9fa;
  --app-btn-primary-hover-bg: #1a749b;
  --app-btn-primary-text: #4a5568;
  --app-btn-primary-hover-text: #ffffff;

  --app-btn-cancel-bg: #f7fafc;
  --app-btn-cancel-hover-bg: #c5c7c7;
  --app-btn-cancel-text: #4a5568;

  --app-flash-success-bg: #A7D7A0;
  --app-flash-danger-bg: #f87171;
  --app-flash-info-bg: #60a5fa;
  --app-flash-warning-bg: #fbbf24;
  --app-flash-text: #1f1f1f;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --app-bg: #1f1f1f;
  --app-surface: #0f172a;
  --app-surface-2: #173d4f;
  --app-text: #f2f2f2;
  --app-muted: #bcbdbe;
  --app-border: #243042;
  --app-table-border: #f2f2f2;
  --app-sidebar-bg: #19744d;
  --app-sidebar-hover: #3fa679;
  --app-link: #7dd3fc;
  --app-btn-bg: #247d96;
  --app-medical-card-bg: #292b28;
  --app-medical-card-bg-hover: #0e4e6c;
  --record-icon-bg: #292b28;
  --record-icon-color: #0d6b47;
  --app-btn-primary-bg: #f8f9fa;
  --app-btn-primary-hover-bg: #324852;
  --app-btn-primary-text: #7888a4;
  --app-btn-primary-hover-text: #ffffff;
  --app-btn-cancel-bg: #696b6b;
  --app-btn-cancel-hover-bg: #464848;
  --app-btn-cancel-text: #f7fafc;
  --app-flash-success-bg: #275012;
  --app-flash-danger-bg: #562020;
  --app-flash-info-bg: #243549;
  --app-flash-warning-bg: #69541f;
  --app-flash-text: #f2f2f2;
}

/* Theme-aware base colors */
body {
  background: var(--app-bg);
  color: var(--app-text);
}

/* Fixed Topbar (sibling of .main-content, aligns to sidebar width) */
.app-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--app-topbar-height);

  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0 2rem;
  background: #ffffff;
  border-bottom: 1px solid var(--app-border);

  /* Above content, below sidebar + sidebar popout submenus */
  z-index: 900;
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-topbar .left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-topbar .right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-topbar .left h1 {
  color: var(--app-text);
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
}

.app-topbar .left p {
  color: var(--app-muted);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  padding-top: 0.25rem;
}

.app-topbar .left h1+p {
  position: relative;
  padding-left: 1.5rem;
}

.app-topbar .left h1+p::before {
  content: "\f111";
  font-family: "Font Awesome 6 Free";
  font-weight: 600;
  font-size: 0.6rem;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--app-muted);
  padding-top: 0.25rem;
}

.wrapper.sidebar-collapsed .app-topbar {
  left: var(--sidebar-collapsed-width);
}

.app-topbar {
  background: var(--app-bg);
  border-bottom-color: var(--app-border);
}

/* Theme toggle icon swapping */
.app-topbar .theme-icon {
  display: inline-flex;
  align-items: center;
}

.app-topbar .theme-icon-dark {
  display: none;
}

html[data-theme="dark"] .app-topbar .theme-icon-light {
  display: none;
}

html[data-theme="dark"] .app-topbar .theme-icon-dark {
  display: inline-flex;
}

/* Dashboard (tenant-style) */
.page-container {
  padding: 1rem 2rem;
  margin: 0 auto;
}

/* Index/search/table (tenant-style) */
.search-container {
  margin-bottom: 2rem;
}

.search-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.add-button-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Utility (used by Stimulus controllers like slug-lock) */
.hidden {
  display: none !important;
}

/* Slug lock (Pages edit form) */
.slug-lock-field {
  position: relative;
  width: 100%;
}

.slug-lock-input {
  padding-right: 2.25rem;
  /* room for lock button */
  width: 100%;
  display: block;
}

.slug-lock-button {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--app-muted);
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.slug-lock-button:hover {
  color: var(--app-text);
}

.slug-lock-input.is-locked {
  cursor: not-allowed;
  opacity: 0.95;
}

.disclaimer-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  margin-top: 1.5rem;
  border: 2px solid #f59e0b;
  border-radius: 0.5rem;
  background-color: #fffbeb;
  color: #92400e;
  font-size: 0.875rem;
  line-height: 1.5;
}

.disclaimer-warning i {
  color: #f59e0b;
  font-size: 1.125rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.search-bar {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #a0aec0;
  font-size: 0.9rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
  background: var(--app-bg);
  color: var(--app-text);
}

.search-input:focus {
  outline: none;
  border-color: var(--app-link);
  box-shadow: 0 0 0 3px rgba(34, 91, 115, 0.1);
}

.filter-bar {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.filter-group {
  flex: 1 1 180px;
}

.status-filter {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--app-text);
  background-color: var(--app-bg);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  appearance: none;
}

.status-filter:focus {
  outline: none;
  border-color: var(--app-link);
  box-shadow: 0 0 0 3px rgba(34, 91, 115, 0.1);
}

.search-results {
  margin-top: 0.25rem;
}

.search-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--app-muted);
  font-size: 0.9rem;
  margin: 0;
}

.clear-search-btn {
  color: var(--app-link);
  text-decoration: none;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.clear-search-btn:hover {
  background-color: color-mix(in srgb, var(--app-border) 35%, transparent);
}

.table-container {
  background: var(--app-bg);
  border-radius: 12px;
  border: 1px solid var(--app-table-border);
  overflow: hidden;
}

.patients-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--app-table-border);
}

.patients-table th {
  background-color: var(--app-bg);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--app-muted);
  border-bottom: 1px solid var(--app-table-border);
}

.patients-table td {
  padding: 1rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--app-table-border);
  color: var(--app-text);
  vertical-align: middle;
}

.patients-table tr:hover {
  background-color: var(--app-surface);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.active {
  background-color: var(--app-link);
  color: white;
}

.status-badge.inactive {
  background-color: color-mix(in srgb, var(--app-border) 70%, transparent);
  color: var(--app-text);
}

.table-actions {
  text-align: right;
  white-space: nowrap;
}

.actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  color: var(--app-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  background: transparent;
  border: 1px solid transparent;
  padding: 0;
}

button.action-btn {
  cursor: pointer;
  font: inherit;
}

.action-btn:hover {
  background-color: var(--app-sidebar-hover);
  color: var(--app-text);
  border-color: color-mix(in srgb, var(--app-border) 60%, transparent);
}

.delete-btn:hover {
  background-color: var(--app-sidebar-hover);
  color: darken(var(--app-text), 10%);
}

/* Pagination (matches tenant) */
.pagination-wrapper {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.pagination-wrapper .pagination-controls {
  margin: 0;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-link,
a.pagination-link,
span.pagination-link {
  color: #6c757d;
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  transition: all 0.15s ease-in-out;
  font-size: 0.875rem;
  display: inline-block;
}

.pagination-link:hover {
  color: #495057;
  background-color: #f8f9fa;
  border-color: #dee2e6;
}

.pagination-link.active,
.pagination-link.current,
span.pagination-link.active {
  background-color: #f8f9fa;
  border-color: #dee2e6;
  color: #495057;
  font-weight: 500;
}

.pagination-link.disabled {
  color: #adb5bd;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-numbers {
  display: flex;
  gap: 0.25rem;
}

.pagination-link i {
  margin: 0 0.25rem;
}

.pagination-link.prev-link i {
  margin-right: 0.25rem;
  margin-left: 0;
}

.pagination-link.next-link i {
  margin-left: 0.25rem;
  margin-right: 0;
}

/* User Show (copied from tenant so admin can diverge) */
.user-show-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem 0 1rem;
}

.user-header {
  margin-bottom: 2rem;
}

.user-header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.user-actions {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 6px;
}

.breadcrumb-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #6c757d;
  text-decoration: none;
}

.breadcrumb-link:hover {
  color: #495057;
}

.breadcrumb-link i {
  font-size: 0.875rem;
}

.user-info-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.right-column {
  display: flex;
  flex-direction: column;
}

.user-info-card {
  border-radius: 12px;
  border: 1px solid var(--app-border);
  padding: 1.5rem;
  background: var(--app-surface-2);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-text);
  margin: 0 0 1rem 0;
}

.user-photo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  background-color: #e5e7eb;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 600;
  object-fit: cover;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--app-border) 35%, transparent);
  margin-bottom: 0.25rem;
}

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

.info-item i {
  width: 1rem;
  color: var(--app-muted);
  flex-shrink: 0;
  text-align: center;
}

.info-item span {
  color: var(--app-text);
  font-size: 0.875rem;
  font-weight: 600;
}

.divider {
  height: 1px;
  background-color: var(--app-border);
  margin: 1rem 0;
}

.user-activity-section {
  border-radius: 12px;
  border: 1px solid var(--app-border);
  overflow: hidden;
  background: var(--app-surface-2);
}

.user-activity-header {
  padding: 1.5rem 1.5rem 0.5rem 1.5rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-text {
  flex-grow: 1;
}

.user-activity-subtitle {
  color: var(--app-muted);
  margin: 0;
  font-size: 0.875rem;
}

.user-activity-container {
  padding: 1.5rem;
}

.activity-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.activity-section {
  background: var(--app-bg);
  border-radius: 8px;
  padding: 1.25rem;
  border: 1px solid var(--app-border);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-text);
  margin: 0 0 1rem 0;
}

.activity-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.activity-item i {
  width: 1rem;
  color: var(--app-muted);
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.activity-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.activity-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.activity-value {
  font-size: 0.875rem;
  color: var(--app-text);
  font-weight: 600;
}

@media (max-width: 768px) {
  .user-info-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .user-header-content {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .user-actions {
    justify-content: flex-start;
  }
}

/* Page header (copied from tenant) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.page-header .header-text {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.page-header .header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Admin user edit form (copied/scoped from tenant) */
.form-card {
  background: var(--app-surface-2);
  border-radius: 8px;
  border: 1px solid var(--app-border);
  padding: 2rem;
  margin-top: 1rem;
}

.form-card .form-section {
  margin-bottom: 2rem;
}

.form-card .section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--app-text);
  margin: 0 0 0.5rem 0;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.form-row-full {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  align-items: start;
}

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

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--app-text);
  margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background-color: var(--app-bg);
  font-size: 1rem;
  color: var(--app-text);
  transition: border-color 0.2s ease;
  font-family: inherit;
  resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #225d72;
  box-shadow: 0 0 0 3px rgba(34, 91, 115, 0.1);
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  appearance: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
}

.btn-primary {
  background-color: var(--app-btn-primary-bg);
  color: var(--app-btn-primary-text);
  border: 1px solid var(--app-border);
}

.btn-primary:hover {
  background-color: var(--app-btn-primary-hover-bg);
  color: var(--app-btn-primary-hover-text);
  border: 1px solid var(--app-border);
}

.btn-secondary {
  background-color: var(--app-btn-secondary-bg);
  color: var(--app-btn-secondary-text);
}

.btn-secondary:hover {
  background-color: var(--app-btn-secondary-hover-bg);
  color: var(--app-btn-secondary-text);
}


.btn-cancel {
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background-color: var(--app-btn-cancel-bg);
  color: var(--app-btn-cancel-text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background-color: var(--app-btn-cancel-hover-bg);
  color: var(--app-btn-cancel-text);
  text-decoration: none;
}

.profile-picture-section {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.profile-picture-container {
  flex-shrink: 0;
}

.profile-picture {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
}

.profile-picture-info {
  flex-grow: 1;
}

.profile-picture-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--app-text);
  margin: 0;
}

.profile-upload-btn {
  display: none;
}

.profile-upload-label {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background-color: var(--app-btn-bg);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.15s ease-in-out;
}

.profile-upload-label:hover {
  background-color: var(--app-surface);
  border-color: var(--app-border);
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .search-filter-row {
    flex-wrap: wrap;
  }

  .search-bar {
    flex: 1 1 100%;
    max-width: none;
  }

  .filter-bar {
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .filter-group {
    flex: 1 1 100%;
  }
}

.dashboard-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.summary-card {
  background: var(--app-surface-2);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--app-border);
}

.summary-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.summary-card .card-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: flex-start;
}

.card-icon {
  color: var(--app-link);
  font-size: 1.2rem;
}

.card-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.card-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--app-text);
}

.card-change {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--app-muted);
  text-decoration: none;
}

.card-change.positive {
  color: #A7D7A0;
}

.card-change.negative {
  color: #ce7171;
}

.dashboard-charts-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.chart-card {
  background: var(--app-surface-2);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--app-border);
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--app-text);
  margin: 0 0 1.5rem 0;
}

.chart-container {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 1200px) {
  .dashboard-cards-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .page-container {
    padding: 1rem 1rem;
  }

  .dashboard-cards-row {
    grid-template-columns: 1fr;
  }

  .dashboard-charts-row {
    grid-template-columns: 1fr;
  }
}

/* Main Content */
.main-content {
  margin-left: 220px;
  flex-grow: 1;
  transition: margin-left 0.5s cubic-bezier(0.4, 0, 0.2, 1), width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 100vh;
  width: calc(100% - 220px);
  overflow: visible;
  padding-top: var(--app-topbar-height);
}

/* Sidebar theme overrides */
.sidebar {
  background: var(--app-sidebar-bg);
  border-right-color: var(--app-border);
}

.sidebar .nav-links>li>a {
  color: var(--app-text);
}

.sidebar .nav-links>li>a:hover,
.sidebar .nav-links>li>a.active,
.sidebar .nav-links>li.active>a {
  background: var(--app-sidebar-hover);
  color: var(--app-text);
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--app-sidebar-bg);
  position: fixed;
  height: 100vh;
  padding: 20px 10px;
  border-right: 1px solid #d1dce0;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  overflow-x: visible;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 80px;
  padding: 20px 10px;
}

/* Sidebar Header */
.sidebar .sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  min-height: 40px;
  position: relative;
}

/* Scrollable main area (nav) between header and footer */
.sidebar-main {
  flex: 1;
  overflow-y: auto;
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Ensure the logo link occupies full width so its child can center content */
.sidebar .sidebar-header>a {
  display: block;
  width: 100%;
}

.sidebar .logo-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  width: 100%;
  padding: 4px 0;
  overflow: hidden;
}

.sidebar .sidebar-toggle {
  position: fixed;
  left: calc(220px - 15px);
  top: 4px;
  transform: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #F8F9FA;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4001;
  transition: left 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
}

.sidebar .sidebar-toggle:hover {
  background: #f8f9fadf;
  transform: none;
}

/* Reposition toggle when sidebar is collapsed */
.wrapper.sidebar-collapsed .sidebar .sidebar-toggle {
  left: calc(80px - 15px);
  top: 4px;
}

.sidebar .sidebar-toggle i {
  font-size: 14px;
  color: #1f1f1f;
  transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle i {
  transform: none;
}

.sidebar .sidebar-logo {
  max-width: 100%;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  visibility: visible;
}

.sidebar.collapsed .sidebar-logo {
  opacity: 0;
  visibility: hidden;
  max-width: 0;
}

/* When collapsed, show logo as an icon-size image */
.sidebar.collapsed .logo-container .sidebar-logo {
  opacity: 1;
  visibility: visible;
  max-width: 40px;
  max-height: 40px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sidebar.collapsed .logo-container {
  justify-content: center;
}

/* Navigation Links */
.sidebar .nav-links {
  list-style: none;
  padding: 0;
}

.sidebar .nav-links>li {
  margin-bottom: 8px;
}

.sidebar .nav-links>li>a {
  text-decoration: none;
  color: var(--app-text);
  display: flex;
  align-items: center;
  font-size: 14px;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.3s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(0);
  overflow: hidden;
  min-width: 0;
}

.sidebar .nav-links>li>a:hover,
.sidebar .nav-links>li>a.active {
  background: var(--app-sidebar-hover);
}

/* Apply active styling when the li has the active class (Rails helper adds it to li) */
.sidebar .nav-links>li.active>a {
  background: var(--app-sidebar-hover);
  color: var(--app-text);
}

.sidebar .nav-links>li.active>a i {
  color: var(--app-text);
}

/* Enhanced hover effect for collapsed sidebar */
.sidebar.collapsed .nav-links>li>a:hover {
  background: #d9e4e8;
  transform: scale(1.05);
  transition: all 0.2s ease;
}

/* Center icons and link blocks when collapsed */
.sidebar.collapsed .nav-links>li {
  display: flex;
  /* justify-content removed - padding transitions on anchor handle centering smoothly */
}

.sidebar.collapsed .nav-links>li>a {
  justify-content: center;
  text-align: center;
}

/* Icon and Text for Links */
.sidebar .nav-links li>a i {
  font-size: 16px;
  min-width: 16px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed .nav-links li>a i {
  margin: 0;
}

.sidebar .nav-links li>a .link-text {
  margin-left: 10px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  visibility: visible;
  white-space: nowrap;
}

.sidebar.collapsed .nav-links li>a .link-text {
  opacity: 0;
  visibility: hidden;
  max-width: 0;
  width: 0;
  margin-left: 0;
  padding: 0;
  overflow: hidden;
  flex-shrink: 0;
}

/* Submenu positioning outside sidebar (controller expects container even if empty) */
.sidebar-submenus {
  position: fixed;
  top: 0;
  left: 220px;
  z-index: 1002;
  pointer-events: none;
  max-height: 100vh;
  overflow: visible;
}

.wrapper.sidebar-collapsed .sidebar-submenus {
  left: 80px;
}

/* Adjust Main Content when Sidebar is Collapsed */
.wrapper.sidebar-collapsed .main-content {
  margin-left: 80px !important;
  width: calc(100% - 80px) !important;
  transition: margin-left 0.5s cubic-bezier(0.4, 0, 0.2, 1), width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prevent “flash of expanded sidebar” on reload before Stimulus runs */
html.sidebar-precollapsed .sidebar {
  width: 80px;
}

html.sidebar-precollapsed .main-content {
  margin-left: 80px !important;
  width: calc(100% - 80px) !important;
}

html.sidebar-precollapsed .app-topbar {
  left: 80px;
}

html.sidebar-precollapsed .sidebar .link-text {
  opacity: 0;
  visibility: hidden;
  max-width: 0;
  margin-left: 0;
}

/* Sidebar logo - hide large, show small */
html.sidebar-precollapsed .sidebar .sidebar-logo {
  opacity: 0;
  visibility: hidden;
  max-width: 0;
}

html.sidebar-precollapsed .sidebar .logo-container .sidebar-logo {
  opacity: 1;
  visibility: visible;
  max-width: 40px;
  max-height: 40px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Nav links - hide link text and center icons */
html.sidebar-precollapsed .sidebar .nav-links li>a .link-text {
  opacity: 0;
  visibility: hidden;
  max-width: 0;
  margin-left: 0;
}

html.sidebar-precollapsed .sidebar .nav-links>li {
  display: flex;
  justify-content: center;
}

html.sidebar-precollapsed .sidebar .nav-links>li>a {
  justify-content: center;
  text-align: center;
  transform: translateX(0);
}

html.sidebar-precollapsed .sidebar .sidebar-toggle {
  left: calc(80px - 15px);
  top: 4px;
}

html.sidebar-precollapsed .sidebar-submenus {
  left: 80px;
}

/* Responsive sidebar behavior */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  .sidebar.collapsed {
    transform: translateX(0);
    width: 260px;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .wrapper.sidebar-collapsed .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* On mobile, sidebar overlays; topbar should be full width */
  .app-topbar {
    left: 0;
  }

  /* Backdrop for mobile sidebar */
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }
}

/* Tooltip styles for collapsed sidebar */
.sidebar.collapsed .tooltip {
  z-index: 1100;
}

.sidebar.collapsed .tooltip-inner {
  background-color: #333;
  color: white;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  max-width: 200px;
}

/* Ensure tooltips are visible when sidebar is collapsed */
.sidebar.collapsed [data-toggle="tooltip"] {
  position: relative;
}

/* Admin public page layout (used by admin_public_show) */
.public-page-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.public-page-navbar {
  background-color: #A7D7A0 !important;
  padding: 1rem 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.public-page-navbar .navbar-brand {
  padding: 0;
}

.public-page-navbar .navbar-nav {
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

.public-page-navbar .nav-link {
  color: #1f1f1f !important;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: opacity 0.15s ease-in-out;
}

.public-page-navbar .nav-link:hover {
  color: #1f1f1f !important;
  opacity: 0.8;
}

.public-page-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
}

.public-page-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e5e7eb;
  padding: 2rem 0;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-left {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.footer-logo-link {
  display: inline-block;
  text-decoration: none;
}

.footer-logo {
  height: 40px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
}

.footer-center {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1 1 auto;
}

.footer-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.footer-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.footer-link {
  color: #1f1f1f;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s ease-in-out;
}

.footer-link:hover {
  color: #225B73;
}

.footer-copyright {
  color: #6b7280;
  font-size: 0.875rem;
  margin: 0;
}

.footer-copyright p {
  margin: 0;
}

@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
  }

  .footer-left {
    justify-content: center;
    width: 100%;
  }

  .footer-center {
    width: 100%;
    order: 2;
  }

  .footer-right {
    align-items: center;
    width: 100%;
    order: 3;
  }

  .footer-links {
    flex-direction: column;
    gap: 1rem;
  }

  .public-page-footer {
    padding: 1.5rem 0;
  }
}