/* admin_panel/admin.css */
:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1f293d;
  --bg-input: #1a2234;
  --border: #243049;
  --border-focus: #0ea5e9;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --accent-mint: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --sidebar-w: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  background: rgba(14, 165, 233, 0.15);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 6px;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: #fff;
}

.nav-item.active {
  background: rgba(14, 165, 233, 0.18);
  color: var(--primary);
  font-weight: 600;
}

.nav-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.admin-name {
  font-size: 13px;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: 0.2s;
}

.btn-logout:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

/* Main Content Area */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  height: 70px;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-container {
  padding: 32px;
  flex: 1;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.blue { background: rgba(14, 165, 233, 0.15); color: var(--primary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-mint); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.stat-info .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

.stat-info .stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* Action Bars & Filters */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.filters-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: 0.2s;
}

.search-input:focus {
  border-color: var(--border-focus);
}

/* Custom dark styling for all selects */
select, .select-filter, .filter-select, select.form-control {
  background-color: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: #fff !important;
  padding: 9px 34px 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2.5' 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: 14px 14px;
  transition: 0.2s;
}

select:focus, .select-filter:focus, .filter-select:focus, select.form-control:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

select option, .select-filter option, .filter-select option {
  background-color: var(--bg-card);
  color: #fff;
  padding: 10px;
}

/* Remove ugly native number spinners (grey arrows on white square) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

input[type="number"] {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: var(--accent-rose);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Tables */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

th {
  background: #162032;
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: #e2e8f0;
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-in_progress { background: rgba(14, 165, 233, 0.15); color: var(--primary); border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-sent_to_crm { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-completed, .badge-done, .badge-active { background: rgba(16, 185, 129, 0.15); color: var(--accent-mint); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-cancelled, .badge-inactive { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); border: 1px solid rgba(244, 63, 94, 0.3); }

/* Doctors Grid */
.doctors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.doctor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
  position: relative;
  transition: 0.2s;
}

.doctor-card:hover {
  border-color: rgba(14, 165, 233, 0.4);
  transform: translateY(-2px);
}

.doctor-header {
  display: flex;
  gap: 16px;
  align-items: center;
}

.doctor-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.doctor-name {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.doctor-role {
  font-size: 13px;
  color: var(--text-muted);
}

.doctor-clinics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.clinic-pill {
  font-size: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--primary);
}

.price-mini-table {
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
}

.price-item span {
  display: block;
  color: var(--text-muted);
}
.price-item strong {
  color: #fff;
  font-size: 13px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 28px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.close-btn:hover {
  color: #fff;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row .form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.form-row .form-label {
  margin-bottom: 6px;
}

.input-with-eye {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-eye .form-control {
  padding-right: 42px;
}

.btn-toggle-eye {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
  color: var(--text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  user-select: none;
}

.btn-toggle-eye:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}


.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--bg-input);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #e2e8f0;
  cursor: pointer;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--accent-mint); }
.toast.error { border-left: 4px solid var(--accent-rose); }

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

/* Period Button Group */
.period-btn-group {
  display: inline-flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 3px;
}
.period-btn-group .btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px 14px;
  font-weight: 600;
  transition: 0.2s;
}
.period-btn-group .btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.period-btn-group .btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent-mint));
  transition: width 0.4s ease;
}

/* Review Cards */
.review-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.review-stars {
  color: #f59e0b;
  font-size: 14px;
}
.review-date {
  font-size: 11px;
  color: var(--text-muted);
}
.review-comment {
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.4;
}

/* ====================================================
   LIVE CHAT THREAD (ДВУСТОРОННИЙ ДИАЛОГ С ПАЦИЕНТОМ)
==================================================== */
.chat-container {
  margin-top: 18px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.chat-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-pulse {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  animation: pulseGreen 2s infinite;
}
@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.chat-thread {
  max-height: 260px;
  min-height: 100px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
}

.chat-msg {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.chat-msg.patient {
  align-items: flex-start;
}
.chat-msg.admin {
  align-items: flex-end;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  animation: msgFadeIn 0.25s ease-out;
}
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.patient .chat-bubble {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: 2px;
  color: #f1f5f9;
}
.chat-msg.admin .chat-bubble {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(2, 132, 199, 0.35));
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-bottom-right-radius: 2px;
  color: #fff;
}

.chat-sender {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: 0.3px;
}
.chat-msg.patient .chat-sender {
  color: #a78bfa;
}
.chat-msg.admin .chat-sender {
  color: var(--accent-mint);
}

.chat-time {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.chat-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ====================================================
   TOAST NOTIFICATIONS (REAL-TIME ОПОВЕЩЕНИЯ)
==================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 420px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s, transform 0.3s;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.toast-lead {
  border-left: 4px solid var(--accent-mint);
}
.toast.toast-reply {
  border-left: 4px solid #a855f7;
}

.toast-icon {
  font-size: 20px;
  line-height: 1;
}
.toast-body {
  flex: 1;
}
.toast-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}
.toast-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

@keyframes rowPulseHighlight {
  0% { background: rgba(56, 189, 248, 0.3); }
  100% { background: transparent; }
}
.row-new-highlight {
  animation: rowPulseHighlight 3s ease-out;
}


