@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Khmer:wght@100..900&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Noto Sans Khmer", "Khmer OS", "Segoe UI", system-ui, sans-serif;
  background: #f5f7fb;
  min-height: 100vh;
  transition:
    background 0.3s,
    color 0.3s;
}

/* Dark Mode */
body.dark-mode {
  background: #1a1a2e;
  color: #e0e0e0;
}

body.dark-mode .login-card,
body.dark-mode .card,
body.dark-mode .stat-box,
body.dark-mode .header,
body.dark-mode .person-item,
body.dark-mode .modal-content,
body.dark-mode .toast {
  background: #16213e;
  border-color: #0f3460;
  color: #e0e0e0;
}

body.dark-mode .card-title,
body.dark-mode .modal-header {
  background: #0f3460;
  border-color: #1a4a6f;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #0f3460;
  border-color: #1e3a6b;
  color: #e0e0e0;
}

body.dark-mode .btn-secondary {
  background: #0f3460;
  color: #e0e0e0;
}

body.dark-mode .filter-tab {
  background: #0f3460;
  color: #e0e0e0;
}

body.dark-mode .filter-tab.active {
  background: #1e3c72;
  color: white;
}

body.dark-mode .stat-icon {
  background: #0f3460;
}

body.dark-mode .permission-message {
  background: #2c3e50;
  border-color: #1a4a6f;
  color: #f39c12;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-btn,
.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0f2f5;
  color: #666;
}

.lang-btn:hover,
.theme-btn:hover {
  background: #e4e6e9;
}

body.dark-mode .lang-btn,
body.dark-mode .theme-btn {
  background: #0f3460;
  color: #e0e0e0;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  padding: 20px;
}

body.dark-mode .login-page {
  background: linear-gradient(135deg, #0a0f2a, #1a1a2e);
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo i {
  font-size: 3rem;
  color: #1e3c72;
}

.login-logo h2 {
  font-size: 1.1rem;
  margin-top: 10px;
  color: #333;
}

.login-input {
  margin-bottom: 18px;
}

.login-input label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
}

.login-input input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 0.9rem;
}

.login-input input:focus {
  outline: none;
  border-color: #1e3c72;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: #1e3c72;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.login-btn:hover {
  background: #2a5298;
}

.login-error {
  background: #fee;
  color: #c00;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
  text-align: center;
  font-size: 0.85rem;
  display: none;
}

/* Main App */
.main-app {
  display: none;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo i {
  font-size: 1.5rem;
  color: #1e3c72;
}

.logo h1 {
  font-size: 1rem;
  color: #333;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.user-name {
  font-size: 0.85rem;
  color: #666;
}

.role-badge {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
}

.role-badge.admin {
  background: #e3f2fd;
  color: #1976d2;
}

.logout-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
}

.logout-btn:hover {
  background: #f0f2f5;
  color: #333;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #2e7d32;
  background: #e8f5e9;
  padding: 4px 10px;
  border-radius: 20px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4caf50;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: white;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid #e5e7eb;
}

.stat-info h3 {
  font-size: 0.7rem;
  color: #888;
  margin-bottom: 6px;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: bold;
  color: #1e3c72;
}

.stat-icon {
  width: 40px;
  height: 40px;
  background: #f0f2f5;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e3c72;
}

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

/* Card */
.card {
  background: white;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.card-title {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 1rem;
  background: #fafbfc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.card-body {
  padding: 20px;
}

/* Form */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 0;
}

.form-group.full {
  grid-column: span 2;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #666;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fafbfc;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #1e3c72;
  background: white;
}

/* Photo Upload */
.photo-upload {
  border: 2px dashed #ddd;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
}

.photo-upload:hover {
  border-color: #1e3c72;
  background: #f8f9ff;
}

.photo-preview {
  max-width: 120px;
  max-height: 120px;
  margin: 10px auto;
  border-radius: 50%;
  object-fit: cover;
  display: none;
}

.photo-preview.show {
  display: block;
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary {
  background: #1e3c72;
  color: white;
  flex: 1;
}

.btn-primary:hover:not(:disabled) {
  background: #2a5298;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f0f2f5;
  color: #666;
}

.btn-secondary:hover {
  background: #e4e6e9;
}

.btn-print {
  background: #2e7d32;
  color: white;
  padding: 8px 16px;
  font-size: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-print:hover {
  background: #1b5e20;
}

.btn-excel {
  background: #1e7e34;
  color: white;
}

/* Search & Filter */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.search-box input {
  padding-left: 35px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-tab {
  padding: 5px 14px;
  border-radius: 20px;
  background: #f0f2f5;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
}

.filter-tab.active {
  background: #1e3c72;
  color: white;
}

/* Person List */
.person-list {
  max-height: 500px;
  overflow-y: auto;
}

.person-item {
  background: #fafbfc;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
}

.person-item:hover {
  background: white;
  border-color: #1e3c72;
}

.person-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
}

.person-info {
  flex: 1;
}

.person-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.person-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e3c72;
}

.person-id {
  font-size: 0.7rem;
  color: #888;
  margin-top: 2px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 500;
}

.badge-cpp {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-opposition {
  background: #fff3e0;
  color: #f57c00;
}

.badge-none {
  background: #ffebee;
  color: #c62828;
}

.person-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.detail-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: #666;
}

.detail-chip i {
  width: 16px;
  color: #888;
}

.action-btns {
  display: flex;
  gap: 5px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #888;
}

.icon-btn.edit:hover {
  background: #e3f2fd;
  color: #1e3c72;
}

.icon-btn.delete:hover {
  background: #ffebee;
  color: #f44336;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  border-radius: 20px;
  max-width: 550px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #888;
}

.modal-body {
  padding: 20px;
}

.info-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f2f5;
}

.info-label {
  font-weight: 500;
  color: #666;
  font-size: 0.8rem;
}

.info-value {
  color: #333;
  font-size: 0.85rem;
}

.modal-photo {
  text-align: center;
  margin-bottom: 15px;
}

.modal-photo img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e5e7eb;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* Confirm Modal */
.confirm-modal {
  max-width: 360px;
}

.confirm-icon {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 15px;
}

.confirm-title {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.confirm-message {
  text-align: center;
  color: #666;
  margin-bottom: 20px;
  font-size: 0.85rem;
}

.confirm-buttons {
  display: flex;
  gap: 12px;
}

.btn-danger {
  background: #f44336;
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: white;
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1100;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  min-width: 260px;
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.toast-icon.error {
  background: #ffebee;
  color: #c62828;
}

.toast-icon.warning {
  background: #fff3e0;
  color: #f57c00;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.toast-message {
  font-size: 0.7rem;
  color: #666;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
}

/* Permission Message */
.permission-message {
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  color: #f57c00;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  .print-area,
  .print-area * {
    visibility: visible;
  }
  .print-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: white;
  }
}

/* Responsive */
@media (max-width: 800px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-group.full {
    grid-column: span 1;
  }
}
