/* ===== MOI TRACKING SYSTEM - COMPLETE CSS ===== */
/* Matching React Frontend Design Exactly */

/* === ROOT VARIABLES === */
:root {
  /* Colors */
  --primary: #3498db;
  --primary-dark: #2980b9;
  --secondary: #95a5a6;
  --secondary-dark: #7f8c8d;
  --success: #27ae60;
  --success-dark: #229954;
  --warning: #f39c12;
  --warning-dark: #e67e22;
  --danger: #e74c3c;
  --danger-dark: #c0392b;
  --header-bg: #2c3e50;
  --header-hover: #34495e;
  --text-dark: #333;
  --text-muted: #666;
  --border-color: #ddd;
  --border-light: #f0f0f0;
  --background: #f8f9fa;
  --white: #fff;

  /* Z-Index Layers (Standard stacking order) */
  --z-header: 100;
  --z-dropdown: 200;
  --z-modal-overlay: 300;
  --z-modal: 400;
  --z-mobile-menu-overlay: 500;
  --z-mobile-menu: 600;
  --z-mobile-menu-toggle: 700;
}

/* === RESET & BASE === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    'Noto Sans Tamil', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dark);
  background-color: var(--background);
  overflow-x: hidden;
  width: 100%;
  position: relative;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dark);
}

/* === LAYOUT === */
.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.main-content {
  padding: 2rem 0;
  min-height: calc(100vh - 150px);
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* === HEADER === */
.header {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  width: 100%;
  box-sizing: border-box;
  /* Note: Mobile menu breaks out of this stacking context on mobile */
}

/* Header Top Row: Logo + Navigation */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  overflow: hidden;
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  margin: 0;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.logo:hover {
  color: var(--white);
  opacity: 0.9;
}

/* Hamburger Menu Button */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: var(--z-mobile-menu-toggle);
  position: relative;
}

.hamburger span {
  width: 30px;
  height: 3px;
  background-color: var(--white);
  border-radius: 3px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-20px);
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* === NAVIGATION === */
.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav-link {
  color: rgba(255, 255, 255, 0.85);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 0.875rem;
  position: relative;
  cursor: pointer;
  display: block;
  border: 1px solid transparent;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.2);
}

.nav-link.active {
  background-color: rgba(255, 255, 255, 0.95);
  color: #2c3e50;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Header Search Compact (between logo and navigation) */
.header-search-compact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 1rem;
  margin-left: auto;
}

.header-left .search-toggle {
  display: none; /* Hidden on desktop, shown on mobile */
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-left .search-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.header-left .search-toggle svg {
  color: var(--white);
}

/* === GLOBAL SEARCH === */
.search-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 50px;
  padding: 0.35rem 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-container:focus-within {
  border-color: var(--primary);
  background-color: var(--white);
  box-shadow: 0 4px 16px rgba(52, 152, 219, 0.2);
  transform: translateY(-1px);
}

.search-container .search-icon {
  color: #999;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  min-width: 150px;
  padding: 0.4rem 0.5rem !important;
  border: none !important;
  border-radius: 0;
  font-size: 0.9rem !important;
  background-color: transparent !important;
  transition: none;
  box-shadow: none !important;
}

.search-input:focus {
  outline: none;
}

.search-container:focus-within .search-icon {
  color: var(--primary);
}

.search-input::placeholder {
  color: #999;
  font-size: 0.95rem;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-height: 400px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  width: 100%;
}

/* Position search results relative to header-search-compact */
.header-search-compact {
  position: relative;
}

.search-result-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background-color 0.2s;
}

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

.search-result-item:hover {
  background-color: var(--background);
}

.search-result-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-dark);
}

.search-result-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* === MESSAGES === */
.message-box {
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  position: relative;
  animation: slideDown 0.3s ease-out;
  font-size: 0.875rem;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success {
  background: #efe;
  color: #38a169;
  border-left: 4px solid var(--success);
}

.error {
  background: #fee;
  color: #c53030;
  border-left: 4px solid var(--danger);
}

.close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.2s;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
}

.close-btn:hover {
  opacity: 1;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  gap: 0.5rem;
  line-height: 1.5;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1a5276 100%);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
  color: var(--white);
}

.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--success-dark) 0%, #1e8449 100%);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, var(--warning-dark) 100%);
  color: var(--white);
}

.btn-warning:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--warning-dark) 0%, #d35400 100%);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--danger-dark) 0%, #a93226 100%);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-secondary {
  background: linear-gradient(135deg, #ecf0f1 0%, #bdc3c7 100%);
  color: var(--text-dark);
}

.btn-secondary:hover:not(:disabled) {
  background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
  color: var(--text-dark);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline::before {
  display: none;
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-outline-danger {
  background: transparent;
  border: 2px solid var(--danger);
  color: var(--danger);
}

.btn-outline-danger::before {
  display: none;
}

.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-outline-success {
  background: transparent;
  border: 2px solid var(--success);
  color: var(--success);
}

.btn-outline-success::before {
  display: none;
}

.btn-outline-success:hover:not(:disabled) {
  background: var(--success);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
}

.btn-ghost::before {
  display: none;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--background);
  color: var(--text-dark);
  box-shadow: none;
  transform: none;
}

.btn-sm {
  padding: 0.4rem 0.875rem;
  font-size: 0.813rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: 12px;
}

.btn-icon {
  padding: 0.625rem;
  border-radius: 10px;
}

.btn-icon.btn-sm {
  padding: 0.4rem;
  border-radius: 8px;
}

.btn-icon.btn-lg {
  padding: 0.875rem;
  border-radius: 12px;
}

/* === CARDS === */
/*
 * ISSUE FIX: Custom dropdown z-index problem
 * -----------------------------------------
 * Problem: Custom select dropdowns were appearing behind other elements (tables, cards)
 *          even with high z-index values (99999).
 *
 * Root Cause: The .card had "overflow: hidden" which clips any child content
 *             that extends beyond the card boundaries, including dropdowns.
 *             CSS z-index doesn't help when parent has overflow:hidden.
 *
 * Solution: Changed "overflow: hidden" to "overflow: visible" to allow
 *           dropdown menus to extend beyond the card container.
 *
 * Date: 2025-11-27
 */
.card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  margin-bottom: 1.5rem;
  overflow: visible; /* Changed from 'hidden' - allows dropdowns to extend outside card */
  max-width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.card-header {
  padding: 1.25rem 1.5rem 0;
  border-bottom: none;
}

.card-body {
  padding: 1.25rem 1.5rem;
  overflow: visible; /* Required for dropdowns to show outside card-body */
}

.card-footer {
  padding: 1rem 1.5rem;
  background: var(--background);
  border-top: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-dark);
  letter-spacing: -0.02em;
}

.form-container {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  margin-bottom: 2rem;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

/* === TABLES === */
.table-container {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  background: linear-gradient(180deg, #f8f9fa 0%, #f1f3f4 100%);
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.813rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table tbody tr {
  transition: background-color 0.15s ease;
}

.table tbody tr:hover {
  background-color: rgba(52, 152, 219, 0.04);
}

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

.table .amount {
  font-weight: 700;
  color: var(--success);
}

.table .pending {
  color: var(--warning);
  font-weight: 600;
}

.table .returned {
  color: var(--secondary);
  text-decoration: line-through;
}

/* Table row actions */
.table .actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* === FORMS === */
.form-group {
  margin-bottom: 1.5rem;
}

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

.form-row .form-group {
  flex: 1;
  min-width: min(250px, 100%);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.required {
  color: var(--danger);
  margin-left: 2px;
}

/* === MODERN INPUT STYLES === */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.875rem;
  font-family: inherit;
  background-color: var(--white);
  color: var(--text-dark);
  transition: all 0.2s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  height: 42px;
  box-sizing: border-box;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: #bbb;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
  background-color: var(--white);
}

input::placeholder,
textarea::placeholder {
  color: #aaa;
  font-weight: 400;
}

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
  height: auto;
}

/* Custom Select Dropdown */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 44px;
  cursor: pointer;
}

select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%233498db' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

select option {
  padding: 12px;
  font-size: 0.875rem;
}

/* === CUSTOM SELECT DROPDOWN === */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select {
  position: relative;
  width: 100%;
  z-index: 1;
}

.custom-select.is-open {
  z-index: 9999;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.875rem;
  background: var(--white);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  color: var(--text-dark);
  height: 42px;
  box-sizing: border-box;
  user-select: none;
}

.custom-select-trigger:hover {
  border-color: #bbb;
}

.custom-select.is-open .custom-select-trigger,
.custom-select-trigger:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
  outline: none;
}

.custom-select.is-open .custom-select-trigger {
  border-radius: 10px 10px 0 0;
  border-bottom-color: transparent;
}

.custom-select-trigger span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-trigger span.placeholder {
  color: #aaa;
}

.custom-select-arrow {
  width: 20px;
  height: 20px;
  margin-left: 8px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.custom-select-arrow svg {
  width: 100%;
  height: 100%;
  stroke: #666;
  transition: stroke 0.2s ease;
}

.custom-select.is-open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select.is-open .custom-select-arrow svg {
  stroke: var(--primary);
}

.custom-select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 2px solid var(--primary);
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 99999;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.custom-select.is-open .custom-select-options {
  display: block;
  animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-select-option {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-light);
}

.custom-select-option:last-child {
  border-bottom: none;
  border-radius: 0 0 8px 8px;
}

.custom-select-option:hover {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.08) 0%, rgba(52, 152, 219, 0.04) 100%);
  color: var(--primary);
}

.custom-select-option.is-selected {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  font-weight: 500;
}

.custom-select-option.is-selected:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1a5276 100%);
  color: var(--white);
}

/* Scrollbar styling for dropdown */
.custom-select-options::-webkit-scrollbar {
  width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
  background: var(--background);
  border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

/* Hide original select when custom is active */
.custom-select select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* Input with icon */
.input-icon-wrapper {
  position: relative;
}

.input-icon-wrapper input {
  padding-left: 44px;
}

.input-icon-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  pointer-events: none;
  transition: color 0.2s;
}

.input-icon-wrapper input:focus + .input-icon,
.input-icon-wrapper input:focus ~ .input-icon {
  color: var(--primary);
}

/* Input Groups */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group input {
  border-radius: 10px 0 0 10px;
  border-right: none;
}

.input-group-append {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  background: var(--background);
  border: 2px solid var(--border-color);
  border-left: none;
  border-radius: 0 10px 10px 0;
  color: var(--text-muted);
  font-weight: 500;
}

/* Number Input */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Search Input */
input[type="search"] {
  padding-left: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

input[type="search"]:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%233498db' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

/* Checkbox & Radio Buttons */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  cursor: pointer;
  accent-color: var(--primary);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  transition: all 0.2s;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-checkbox .checkmark {
  height: 22px;
  width: 22px;
  background-color: var(--white);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.custom-checkbox:hover .checkmark {
  border-color: var(--primary);
}

.custom-checkbox input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

.custom-checkbox .checkmark::after {
  content: '';
  display: none;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.custom-checkbox input:checked ~ .checkmark::after {
  display: block;
}

/* Input States */
input.is-valid,
select.is-valid,
textarea.is-valid {
  border-color: var(--success);
}

input.is-valid:focus,
select.is-valid:focus,
textarea.is-valid:focus {
  box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.15);
}

input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--danger);
}

input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.15);
}

/* Disabled State */
input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--background);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Read-only State */
input:read-only:not([type="checkbox"]):not([type="radio"]) {
  background-color: var(--background);
  cursor: default;
}

/* Form Help Text */
.form-help {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.813rem;
  color: var(--text-muted);
}

.form-error {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.813rem;
  color: var(--danger);
}

/* Input Sizes */
input.input-sm,
select.input-sm,
textarea.input-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.813rem;
  border-radius: 8px;
}

input.input-lg,
select.input-lg,
textarea.input-lg {
  padding: 1rem 1.25rem;
  font-size: 1.063rem;
  border-radius: 12px;
}

/* File Input */
input[type="file"] {
  padding: 0.5rem;
  border-style: dashed;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: var(--primary);
  background-color: rgba(52, 152, 219, 0.02);
}

input[type="file"]::file-selector-button {
  padding: 0.5rem 1rem;
  margin-right: 1rem;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--primary-dark);
}

/* === CUSTOM DATE PICKER (Flatpickr) === */
.flatpickr-calendar {
  background: var(--white);
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  font-family: inherit;
  width: 320px;
  padding: 0;
  overflow: hidden;
}

.flatpickr-calendar.animate.open {
  animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flatpickr-months {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 12px 8px;
  border-radius: 12px 12px 0 0;
}

.flatpickr-months .flatpickr-month {
  height: 36px;
}

.flatpickr-current-month {
  padding: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: transparent;
  border: none;
  color: var(--white);
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0 4px;
  appearance: none;
  cursor: pointer;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.flatpickr-current-month input.cur-year {
  color: var(--white);
  font-weight: 600;
  font-size: 1.1rem;
  background: transparent;
  padding: 0 4px;
}

.flatpickr-current-month input.cur-year:focus {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  padding: 8px 12px;
  fill: var(--white);
  color: var(--white);
  transition: all 0.2s;
  border-radius: 8px;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  background: rgba(255, 255, 255, 0.15);
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
  width: 12px;
  height: 12px;
}

.flatpickr-innerContainer {
  padding: 12px;
}

.flatpickr-weekdays {
  background: transparent;
  padding: 0 0 8px 0;
}

.flatpickr-weekday {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.flatpickr-days {
  width: 100%;
}

.dayContainer {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
}

.flatpickr-day {
  height: 38px;
  line-height: 38px;
  font-size: 0.9rem;
  color: var(--text-dark);
  border-radius: 8px;
  margin: 2px;
  max-width: calc(14.285% - 4px);
  transition: all 0.15s ease;
  border: none;
}

.flatpickr-day:hover {
  background: var(--background);
  border: none;
}

.flatpickr-day.today {
  background: rgba(52, 152, 219, 0.1);
  color: var(--primary);
  font-weight: 600;
  border: none;
}

.flatpickr-day.today:hover {
  background: rgba(52, 152, 219, 0.2);
  color: var(--primary);
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  font-weight: 600;
  border: none;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4);
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: #ccc;
}

.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
  background: var(--background);
  color: var(--text-muted);
}

.flatpickr-day.disabled,
.flatpickr-day.disabled:hover {
  color: #ddd;
  background: transparent;
  cursor: not-allowed;
}

/* Date input wrapper */
.date-input-wrapper {
  position: relative;
}

.date-input-wrapper input {
  padding-right: 40px;
  cursor: pointer;
  height: 42px;
}

.date-input-wrapper input.flatpickr-input {
  height: 42px;
}

.date-input-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23666'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'%3E%3C/path%3E%3C/svg%3E");
  background-size: contain;
  pointer-events: none;
}

/* Flatpickr alt input styling */
.flatpickr-input[readonly] {
  background-color: var(--white);
  cursor: pointer;
}

/* Time picker styling */
.flatpickr-time {
  border-top: 1px solid var(--border-light);
  padding: 12px;
  margin-top: 8px;
}

.flatpickr-time input {
  font-size: 1rem;
  font-weight: 500;
}

.flatpickr-time .flatpickr-am-pm {
  font-weight: 500;
}

/* === STATISTICS GRID === */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.stat-card {
  background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
  padding: 0.3rem 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(44, 62, 80, 0.1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  border-color: var(--primary);
}

.stat-number {
  font-size: 0.938rem;
  font-weight: 700;
  color: var(--header-bg);
  margin: 0;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
  line-height: 1.2;
}

/* Stat card color variations */
.stat-card:nth-child(1) {
  border-color: #3498db;
  background: linear-gradient(135deg, #ebf5fb 0%, #ffffff 100%);
}

.stat-card:nth-child(1) .stat-number {
  color: #2980b9;
}

.stat-card:nth-child(2) {
  border-color: #9b59b6;
  background: linear-gradient(135deg, #f4ecf7 0%, #ffffff 100%);
}

.stat-card:nth-child(2) .stat-number {
  color: #8e44ad;
}

.stat-card:nth-child(3) {
  border-color: #27ae60;
  background: linear-gradient(135deg, #e8f8f5 0%, #ffffff 100%);
}

.stat-card:nth-child(3) .stat-number {
  color: #229954;
}

.stat-card:nth-child(4) {
  border-color: #16a085;
  background: linear-gradient(135deg, #e8f6f3 0%, #ffffff 100%);
}

.stat-card:nth-child(4) .stat-number {
  color: #138d75;
}

.stat-card:nth-child(5) {
  border-color: #f39c12;
  background: linear-gradient(135deg, #fef5e7 0%, #ffffff 100%);
}

.stat-card:nth-child(5) .stat-number {
  color: #d68910;
}

.stat-card:nth-child(6) {
  border-color: #e74c3c;
  background: linear-gradient(135deg, #fadbd8 0%, #ffffff 100%);
}

.stat-card:nth-child(6) .stat-number {
  color: #cb4335;
}

.stat-card:nth-child(7) {
  border-color: #e67e22;
  background: linear-gradient(135deg, #fdebd0 0%, #ffffff 100%);
}

.stat-card:nth-child(7) .stat-number {
  color: #ca6f1e;
}

/* === UTILITY CLASSES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* === PAGE HEADER === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 100%;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--header-bg);
  margin: 0;
  word-break: break-word;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 100%;
}

/* === TABS === */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: all 0.2s;
  margin-bottom: -2px;
  text-decoration: none;
}

.tab:hover {
  color: var(--primary);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* === AUTOCOMPLETE/DROPDOWN === */
.autocomplete-container {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-item {
  padding: 0.6rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.2s;
}

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

.autocomplete-item:hover {
  background-color: var(--background);
}

.autocomplete-title {
  font-weight: 600;
  font-size: 0.813rem;
  color: var(--text-dark);
}

.autocomplete-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* === BADGE === */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background-color: #d4edda;
  color: #155724;
}

.badge-warning {
  background-color: #fff3cd;
  color: #856404;
}

.badge-danger {
  background-color: #f8d7da;
  color: #721c24;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

/* === PAGINATION === */
.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
}

.pagination a,
.pagination span {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-dark);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.813rem;
}

.pagination a:hover {
  background-color: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.pagination .active {
  background-color: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* === RESPONSIVE === */
/* Tablet */
@media (max-width: 1024px) {
  .logo h1 {
    font-size: 1.5rem;
  }

  .nav {
    gap: 0.35rem;
  }

  .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .search-container {
    max-width: 500px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
    width: 100%;
  }

  .header-top {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.6rem 0;
  }

  .header-left {
    flex: 1;
    justify-content: space-between;
    min-width: 0;
  }

  .logo {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .logo h1 {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Show hamburger button on mobile */
  .hamburger {
    display: flex;
  }

  /* Hide navigation by default on mobile */
  .nav {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    flex-direction: column;
    padding: 5rem 0 2rem 0;
    gap: 0;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    z-index: var(--z-mobile-menu);
    overflow-y: auto;
    isolation: isolate;
  }

  /* Show navigation when menu is open */
  .nav.active {
    left: 0;
  }

  .nav-link {
    width: 100%;
    text-align: left;
    padding: 1rem 1.5rem;
    border-radius: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid transparent;
    font-size: 1rem;
    display: block;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    position: relative;
    z-index: 1;
  }

  .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left-color: rgba(255, 255, 255, 0.3);
  }

  .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-left-color: var(--white);
    color: var(--white);
    font-weight: 600;
  }

  /* Overlay for mobile menu */
  .nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-mobile-menu-overlay);
    cursor: pointer;
    pointer-events: auto;
  }

  .nav-overlay.active {
    display: block;
    /* Don't block clicks on the menu area */
    left: 280px;
    width: calc(100% - 280px);
  }

  /* Mobile Search Styles */
  .header-left .search-toggle {
    display: flex;
    width: 34px;
    height: 34px;
  }

  .header-left .search-toggle svg {
    width: 18px;
    height: 18px;
  }

  .search-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: none;
    background: var(--header-bg);
    padding: 0.85rem 1rem;
    z-index: var(--z-modal);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }

  .search-container.active {
    transform: translateY(0);
  }

  .search-container .search-icon {
    left: 1.25rem;
    width: 16px;
    height: 16px;
  }

  .search-input {
    padding: 0.7rem 1rem 0.7rem 3.1rem !important;
    font-size: 0.95rem !important;
  }

  .btn {
    max-width: 100%;
    box-sizing: border-box;
  }

  .card {
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row .form-group {
    min-width: 0;
    width: 100%;
  }

  input, select, textarea {
    max-width: 100%;
    box-sizing: border-box;
  }

  .table {
    font-size: 0.875rem;
  }

  .table th,
  .table td {
    padding: 0.5rem;
  }

  .stats-grid {
    gap: 0.6rem;
  }

  .stat-card {
    padding: 0.45rem 0.85rem;
    border-radius: 16px;
  }

  .stat-number {
    font-size: 0.875rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .page-actions {
    flex-direction: column;
  }

  .page-actions .btn {
    width: 100%;
  }

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

/* Small Mobile Devices (iPhone, smaller screens) */
@media (max-width: 430px) {
  .container {
    padding: 0 0.75rem;
  }

  .header-top {
    padding: 0.5rem 0;
  }

  .logo h1 {
    font-size: 1rem;
  }

  .header-left .search-toggle {
    width: 32px;
    height: 32px;
  }

  .header-left .search-toggle svg {
    width: 16px;
    height: 16px;
  }

  .search-container {
    padding: 0.75rem 0.85rem;
  }

  .search-container .search-icon {
    left: 1rem;
    width: 15px;
    height: 15px;
  }

  .search-input {
    font-size: 0.9rem !important;
    padding: 0.65rem 0.85rem 0.65rem 2.85rem !important;
  }
}

/* === PRINT STYLES === */
@media print {
  .header,
  .page-actions,
  .btn,
  button {
    display: none;
  }

  .main-content {
    padding: 0;
  }

  .card,
  .table {
    box-shadow: none;
    page-break-inside: avoid;
  }
}

/* === FUNCTIONS PAGE STYLES === */
/* Reduce page header size */
body:has([data-page="functions"]) .page-header {
  margin-bottom: 1rem;
}

body:has([data-page="functions"]) .page-title {
  font-size: 1.5rem;
}

body:has([data-page="functions"]) .page-actions .btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.813rem;
}

/* Compact card */
body:has([data-page="functions"]) .card {
  margin-bottom: 1rem;
}

body:has([data-page="functions"]) .card-body {
  padding: 0.75rem;
}

/* Compact filter form */
.functions-filter-form {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.functions-filter-form .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 120px;
}

.functions-filter-form input,
.functions-filter-form select {
  padding: 0.35rem 0.6rem;
  font-size: 0.813rem;
  height: 32px;
  border-radius: 4px;
}

.functions-filter-form input::placeholder {
  font-size: 0.813rem;
}

.functions-filter-form .btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.813rem;
  height: 32px;
  flex: 0 0 auto;
  white-space: nowrap;
  border-radius: 4px;
}

/* Table styles */
body:has([data-page="functions"]) .table {
  font-size: 0.875rem;
}

body:has([data-page="functions"]) .table th,
body:has([data-page="functions"]) .table td {
  padding: 0.6rem 0.75rem;
}

body:has([data-page="functions"]) .table th {
  font-size: 0.813rem;
  font-weight: 600;
}

body:has([data-page="functions"]) .table .btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
}

/* "No results found" text */
body:has([data-page="functions"]) .text-muted {
  font-size: 0.875rem;
  padding: 1rem;
}

/* Responsive for Functions page */
@media (max-width: 1200px) {
  .functions-filter-form .form-group {
    min-width: 110px;
  }

  .functions-filter-form input,
  .functions-filter-form select {
    font-size: 0.75rem;
  }

  .functions-filter-form .btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.7rem;
  }
}

@media (max-width: 1024px) {
  .functions-filter-form {
    flex-wrap: wrap;
  }

  .functions-filter-form .form-group {
    min-width: 140px;
  }
}

@media (max-width: 768px) {
  body:has([data-page="functions"]) .page-title {
    font-size: 1.25rem;
  }

  .functions-filter-form {
    flex-direction: column;
    gap: 0.5rem;
  }

  .functions-filter-form .form-group {
    width: 100%;
    min-width: 0;
  }

  .functions-filter-form input,
  .functions-filter-form select,
  .functions-filter-form .btn {
    width: 100%;
    font-size: 0.875rem;
    height: 36px;
  }
}

/* === PEOPLE PAGE STYLES === */
/* Compact filter form for People page */
.people-filter-form {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.people-filter-form .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 140px;
}

.people-filter-form input,
.people-filter-form select {
  padding: 0.35rem 0.6rem;
  font-size: 0.813rem;
  height: 32px;
  border-radius: 4px;
}

.people-filter-form input::placeholder {
  font-size: 0.813rem;
}

.people-filter-form .btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.813rem;
  height: 32px;
  flex: 0 0 auto;
  white-space: nowrap;
  border-radius: 4px;
}

/* Responsive for People page */
@media (max-width: 1024px) {
  .people-filter-form {
    flex-wrap: wrap;
  }

  .people-filter-form .form-group {
    min-width: 160px;
  }
}

@media (max-width: 768px) {
  .people-filter-form {
    flex-direction: column;
    gap: 0.5rem;
  }

  .people-filter-form .form-group {
    width: 100%;
    min-width: 0;
  }

  .people-filter-form input,
  .people-filter-form select,
  .people-filter-form .btn {
    width: 100%;
    font-size: 0.875rem;
    height: 36px;
  }
}

/* === MOI CONTRIBUTIONS PAGE STYLES === */
/* Compact filter form for Moi Contributions page */
.moi-filter-form {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.moi-filter-form .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 140px;
}

.moi-filter-form select {
  padding: 0.35rem 0.6rem;
  font-size: 0.813rem;
  height: 32px;
  border-radius: 4px;
}

.moi-filter-form .btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.813rem;
  height: 32px;
  flex: 0 0 auto;
  white-space: nowrap;
  border-radius: 4px;
}

/* Responsive for Moi Contributions page */
@media (max-width: 1200px) {
  .moi-filter-form {
    flex-wrap: wrap;
  }

  .moi-filter-form .form-group {
    min-width: 160px;
  }
}

@media (max-width: 768px) {
  .moi-filter-form {
    flex-direction: column;
    gap: 0.5rem;
  }

  .moi-filter-form .form-group {
    width: 100%;
    min-width: 0;
  }

  .moi-filter-form select,
  .moi-filter-form .btn {
    width: 100%;
    font-size: 0.875rem;
    height: 36px;
  }
}

/* === FUNCTION CARDS GRID === */
.function-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.function-card {
  background: var(--white);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text-dark);
  transition: all 0.3s ease;
  cursor: pointer;
  display: block;
}

.function-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
  transform: translateY(-2px);
}

.function-card.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.05) 0%, rgba(52, 152, 219, 0.1) 100%);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.function-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.function-card-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--primary);
}

.function-date {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.function-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.function-family {
  font-size: 0.95rem;
  color: var(--text-dark);
  margin: 0;
  font-weight: 500;
}

.function-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.function-card-stats .stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.function-card-stats .stat-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
}

/* Responsive function cards */
@media (max-width: 768px) {
  .function-cards-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .function-card {
    padding: 1.25rem;
  }

  .function-card-header h3 {
    font-size: 1.125rem;
  }
}

/* === AUTOCOMPLETE STYLES === */
.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  margin-top: -1px;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.2s;
}

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

.autocomplete-item:hover {
  background-color: var(--background);
}

.autocomplete-item strong {
  color: var(--text-dark);
  font-weight: 600;
}

.autocomplete-item small {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.autocomplete-create-new {
  background-color: #f8f9fa;
  border-top: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--success);
}

.autocomplete-create-new:hover {
  background-color: rgba(39, 174, 96, 0.1);
}

/* Form group positioning for autocomplete */
.form-group {
  position: relative;
}

#person_search {
  position: relative;
  z-index: 1;
}

/* Quick create person form */
#quick-create-person {
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  margin-top: 0.5rem;
}

#quick-create-person h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

#quick-create-person .form-group {
  margin-bottom: 0.75rem;
}

#quick-create-person .form-group:last-of-type {
  margin-bottom: 1rem;
}

#quick-create-person label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
  display: block;
}

#quick-create-person input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
}

#quick-create-person input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
  border-radius: 4px;
}

/* Responsive autocomplete */
@media (max-width: 768px) {
  .autocomplete-results {
    max-height: 250px;
  }

  .autocomplete-item {
    padding: 0.65rem 0.875rem;
  }

  #quick-create-person {
    padding: 0.875rem;
  }
}

/* === STATS GRID FOR DASHBOARD === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  /* gap: 1.5rem; */
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  /* padding: 1.5rem; */
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

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

  .stat-value {
    font-size: 1.5rem;
  }
}

/* === MODAL STYLES === */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.modal-content {
  position: relative;
  z-index: 2;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.modal-close:hover {
  background-color: var(--background);
  color: var(--text-dark);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Modal animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Autocomplete in modal */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  margin-top: -1px;
}

.autocomplete-dropdown .autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.2s;
}

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

.autocomplete-dropdown .autocomplete-item:hover {
  background-color: var(--background);
}

/* Success toast notification */
.success-toast {
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .modal-header,
  .modal-body {
    padding: 1.25rem;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

/* ===== VOICE SEARCH STYLES ===== */

/* Voice button base styles */
.voice-mic-btn,
.voice-speaker-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--text-dark);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.voice-mic-btn svg,
.voice-speaker-btn svg {
  width: 16px;
  height: 16px;
}

.voice-mic-btn:hover,
.voice-speaker-btn:hover {
  background: rgba(52, 152, 219, 0.2);
  color: var(--primary);
}

/* Microphone listening state */
.voice-mic-btn.listening {
  color: var(--danger);
  animation: pulse 1.5s infinite;
}

.voice-mic-btn.processing {
  color: var(--warning);
}

.voice-mic-btn.error {
  color: var(--danger);
}

/* Speaker speaking state */
.voice-speaker-btn.speaking {
  color: var(--success);
  animation: pulse 1.5s infinite;
}

.voice-speaker-btn.error {
  color: var(--danger);
}

/* Pulse animation for active states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

/* Language selector - uses theme's custom select */
.voice-lang-select {
  flex-shrink: 0;
  min-width: 80px;
  font-size: 0.875rem;
}

/* Custom select wrapper for voice language */
.search-container .custom-select {
  position: relative;
  z-index: var(--z-dropdown);
}

/* Custom select options positioning */
.search-container .custom-select-options {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  z-index: calc(var(--z-dropdown) + 1);
  max-height: 200px;
  overflow-y: auto;
}

/* Voice search wrapper */
.voice-search-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

/* Header search container with voice buttons */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Adjust search input to accommodate voice buttons */
.search-container .search-input {
  flex: 1;
}

/* Add space between input and voice buttons */
.search-container .voice-mic-btn {
  margin-left: 0.25rem;
}

/* Voice toast messages */
.voice-toast {
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Slide in animation for toast */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .voice-mic-btn,
  .voice-speaker-btn {
    width: 28px;
    height: 28px;
  }

  .voice-mic-btn svg,
  .voice-speaker-btn svg {
    width: 14px;
    height: 14px;
  }

  .voice-lang-select {
    font-size: 0.75rem;
    min-width: 70px;
  }

  .voice-search-wrapper {
    flex-wrap: nowrap;
  }

  .search-container {
    max-width: 100%;
    gap: 0.3rem;
  }

  /* Ensure dropdown options don't overflow on mobile */
  .search-container .custom-select-options {
    max-height: 150px;
  }
}

/* Accessibility - focus states */
.voice-mic-btn:focus,
.voice-speaker-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Disabled state */
.voice-mic-btn:disabled,
.voice-speaker-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.voice-mic-btn:disabled:hover,
.voice-speaker-btn:disabled:hover {
  color: #666;
  background: none;
}

/* ===== SIMPLE LISTENING INDICATOR ===== */
.voice-listening-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.95), rgba(46, 204, 113, 0.95));
  border-radius: 20px;
  padding: 2rem 3rem;
  z-index: 10000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-width: 320px;
  backdrop-filter: blur(10px);
  animation: fadeInScale 0.3s ease;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.listening-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  animation: pulseExpand 1.5s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pulseExpand {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.listening-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.listening-icon {
  font-size: 2rem;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.listening-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  text-align: center;
  font-weight: 400;
}

/* ===== AUDIO VISUALIZER (DEPRECATED) ===== */
.voice-visualizer {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  border-radius: 16px;
  padding: 2rem;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  min-width: 300px;
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.voice-visualizer-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  height: 80px;
  width: 100%;
}

.voice-bar {
  width: 12px;
  min-height: 4px;
  background: linear-gradient(to top, #3498db, #2ecc71);
  border-radius: 6px;
  transition: height 0.1s ease;
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.voice-bar:nth-child(1) {
  background: linear-gradient(to top, #e74c3c, #f39c12);
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.voice-bar:nth-child(2) {
  background: linear-gradient(to top, #f39c12, #f1c40f);
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

.voice-bar:nth-child(3) {
  background: linear-gradient(to top, #2ecc71, #27ae60);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.voice-bar:nth-child(4) {
  background: linear-gradient(to top, #3498db, #2980b9);
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.voice-bar:nth-child(5) {
  background: linear-gradient(to top, #9b59b6, #8e44ad);
  box-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
}

.voice-visualizer-text {
  color: white;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.5px;
}

.voice-test-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.voice-test-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.voice-test-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.voice-test-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pulsing animation for the mic icon */
@keyframes pulseGlow {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Mobile responsive for listening indicator */
@media (max-width: 768px) {
  .voice-listening-indicator {
    min-width: 280px;
    padding: 1.5rem 2rem;
  }

  .listening-pulse {
    width: 60px;
    height: 60px;
  }

  .listening-text {
    font-size: 1.2rem;
  }

  .listening-icon {
    font-size: 1.5rem;
  }

  .listening-subtitle {
    font-size: 0.85rem;
  }

  /* Visualizer (deprecated) */
  .voice-visualizer {
    min-width: 260px;
    padding: 1.5rem;
  }

  .voice-visualizer-bars {
    height: 60px;
    gap: 6px;
  }

  .voice-bar {
    width: 10px;
  }

  .voice-visualizer-text {
    font-size: 1rem;
  }
}
