@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-body: #f5f6fa;
  --bg-card: #ffffff;
  --bg-card-hover: #fafbfc;
  --primary: #9B1B7D;
  --primary-light: #C74BAA;
  --primary-bg: rgba(155, 27, 125, 0.08);
  --secondary: #2d3436;
  --text-primary: #1a1a2e;
  --text-secondary: #636e72;
  --text-muted: #b2bec3;
  --border: #e9ecef;
  --border-hover: #dee2e6;
  --success: #00b894;
  --success-bg: rgba(0, 184, 148, 0.1);
  --warning: #fdcb6e;
  --warning-bg: rgba(253, 203, 110, 0.1);
  --error: #d63031;
  --error-bg: rgba(214, 48, 49, 0.1);
  --phone-color: #4834d4;
  --phone-bg: rgba(72, 52, 212, 0.08);
  --door-color: #00a8a8;
  --door-bg: rgba(0, 168, 168, 0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-body);
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header */
.header-bar {
  position: sticky;
  top: 0;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  z-index: 100;
}

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

.site-logo {
  height: 36px;
  object-fit: contain;
}

.header-left h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.welcome-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Main Content */
.main-content {
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

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

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.stat-card:nth-child(1) .stat-icon { background-color: var(--primary); }
.stat-card:nth-child(2) .stat-icon { background-color: var(--phone-color); }
.stat-card:nth-child(3) .stat-icon { background-color: var(--door-color); }
.stat-card:nth-child(4) .stat-icon { background-color: var(--success); }

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: transform 0.2s;
}

/* Queue Section */
.queue-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Queue Cards */
.queue-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.queue-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.queue-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
}

.badge-active.phone-badge {
  background-color: var(--phone-bg);
  color: var(--phone-color);
}

.badge-active.door-badge {
  background-color: var(--door-bg);
  color: var(--door-color);
}

.queue-body {
  padding: 0;
}

.queue-list {
  list-style: none;
}

.queue-item {
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  font-size: 0.925rem;
  cursor: grab;
}
.queue-item:active {
  cursor: grabbing;
}
.sortable-ghost {
  opacity: 0.4;
  background-color: var(--border) !important;
  border: 1px dashed var(--primary);
}

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

.queue-item.active {
  background-color: var(--primary-bg);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.queue-item.active::before {
  content: none;
}

.queue-order {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 28px;
}

.queue-name {
  flex: 1;
  color: var(--text-primary);
}

.queue-arrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary);
  background-color: var(--primary-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-light);
}

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

.btn-danger {
  background-color: var(--error);
  color: white;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-warning {
  background-color: #e17055;
  color: white;
}
.btn-warning:hover {
  opacity: 0.9;
}

.btn-success {
  background-color: var(--success);
  color: white;
}
.btn-success:hover {
  opacity: 0.9;
}

.btn-phone {
  background-color: var(--phone-color);
  color: white;
}
.btn-phone:hover {
  opacity: 0.9;
}

.btn-door {
  background-color: var(--door-color);
  color: white;
}
.btn-door:hover {
  opacity: 0.9;
}

.btn-take {
  font-size: 0.95rem;
  padding: 0.85rem;
  margin: 1rem 1.5rem;
  width: calc(100% - 3rem);
  border-radius: var(--radius-md);
}

.btn-take.my-turn {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(155, 27, 125, 0.3);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.2s ease-out;
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form elements */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-body);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-bg);
}

textarea.form-control {
  resize: vertical;
  min-height: 72px;
}

/* Records Section */
.records-section {
  margin-bottom: 1.5rem;
}

.records-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.records-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.records-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.table-responsive {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background-color: var(--bg-body);
}

.data-table th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-primary);
}

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

.data-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-phone {
  background-color: var(--phone-bg);
  color: var(--phone-color);
}

.badge-door {
  background-color: var(--door-bg);
  color: var(--door-color);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: #e17055;
}

.badge-error {
  background-color: var(--error-bg);
  color: var(--error);
}

/* Toast Container */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 260px;
  animation: toastSlideIn 0.2s ease-out;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: opacity 0.3s, transform 0.3s;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--error);
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card, .glassmorphism {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

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

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 0.5rem;
}

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

.login-form .form-group input {
  width: 100%;
  background-color: var(--bg-body);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

.login-form .form-group input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.login-form .btn-primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.error-msg {
  background-color: var(--error-bg);
  color: var(--error);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(214, 48, 49, 0.2);
}

.login-footer {
  text-align: center;
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Utility Classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Animations */
@keyframes modalSlideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

/* Custom Alert Modal */
#custom-alert-modal .modal-content {
  max-width: 400px;
  text-align: center;
  padding-bottom: 0.5rem;
}
#custom-alert-modal .modal-header {
  border-bottom: none;
  padding-bottom: 0;
  justify-content: center;
}
#custom-alert-modal .modal-body {
  padding: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
}
#custom-alert-modal .modal-footer {
  border-top: none;
  justify-content: center;
  padding-top: 0;
}
#custom-alert-modal .btn-primary {
  width: 100px;
}

/* Responsive */
@media (max-width: 768px) {
  .queue-section { grid-template-columns: 1fr; }
  .stats-section { grid-template-columns: 1fr 1fr; }
  .header-bar { flex-direction: column; gap: 0.75rem; padding: 0.75rem 1rem; }
  .header-right { justify-content: center; }
  .main-content { padding: 1rem; }
  .records-filters { width: 100%; }
  .records-filters .form-control { flex: 1; min-width: 0; }
}

@media (max-width: 480px) {
  .stats-section { grid-template-columns: 1fr; }
  .queue-section { grid-template-columns: 1fr; }
  .header-left h1 { font-size: 0.95rem; }
}

/* Online Users Section */
.online-users-section {
  margin-bottom: 1.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.online-users-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.online-users-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.online-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  background-color: var(--bg-body);
  border-radius: 20px;
  border: 1px solid var(--border);
}
.online-user .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}
.online-user.status-online .status-dot {
  background-color: var(--success);
}
.online-user.status-break .status-dot {
  background-color: var(--warning);
}

/* Queue Actions */
.queue-action-container {
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.queue-action-container .btn-take {
  margin: 0;
  width: 100%;
}
.proxy-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: var(--bg-body);
  border: 1px dashed var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
}
.proxy-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.btn-proxy {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Chat Widget */
/* iOS / Messenger Style Chat Widget */
.chat-widget {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 360px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.2);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
}

.chat-widget.minimized {
  height: 64px;
  width: 64px;
  border-radius: 32px;
  background: #0084ff;
  box-shadow: 0 4px 12px rgba(0, 132, 255, 0.4);
  cursor: pointer;
  border: none;
}

.chat-widget.minimized:hover {
  transform: scale(1.05);
}

.chat-widget:not(.minimized) {
  height: 520px;
}

.chat-header {
  padding: 0.8rem 1rem;
  background: #0084ff;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  height: auto;
}

.chat-header-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
}

.chat-widget.minimized .chat-header {
  background: transparent;
  color: #ffffff;
  justify-content: center;
  height: 100%;
  border: none;
  padding: 0;
  width: 100%;
}

.chat-widget.minimized .chat-back-icon,
.chat-widget.minimized .chat-menu-icon {
  display: none;
}
.chat-widget.minimized .chat-header-profile {
  border: none;
  transform: scale(1.2);
}

.chat-widget.minimized .chat-body,
.chat-widget.minimized .chat-footer {
  display: none;
}

/* Scrollbar */
.chat-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: #ffffff;
}
.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background-color: #ccd0d5; border-radius: 10px; }

.chat-message-container {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.chat-message {
  max-width: 75%;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  line-height: 1.35;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  word-wrap: break-word;
}

.chat-message .chat-text {
  margin-bottom: 0.2rem;
}

.chat-message .chat-meta {
  font-size: 0.6rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
}

/* User Message */
.chat-message.me {
  align-self: flex-end;
  background: #0084ff;
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
}

.chat-message.me .chat-meta {
  color: rgba(255, 255, 255, 0.65);
}

/* Other User Message */
.chat-message.others {
  align-self: flex-start;
  background-color: #e9ecef;
  color: #1a1a1a;
  border-radius: 18px 18px 18px 4px;
}

.chat-message.others .chat-meta {
  color: #8a8d91;
}

.chat-footer {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid #e4e6eb;
  background: #ffffff;
  border-radius: 0 0 12px 12px;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#chat-input {
  flex: 1;
  padding: 0.55rem 0.85rem;
  background-color: #f0f2f5;
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 0.88rem;
  outline: none;
  color: #050505;
}

#chat-input:focus {
  border-color: #0084ff;
  background-color: #e8e9ed;
}

#chat-input::placeholder {
  color: #8a8d91;
}

.btn-chat-send {
  background: none;
  border: none;
  padding: 0.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  transition: background 0.15s;
}
.btn-chat-send:hover {
  background: rgba(0, 132, 255, 0.1);
}

.chat-message-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.2rem;
  padding: 0 0.3rem;
  font-size: 0.7rem;
}
.chat-message-actions span {
  cursor: pointer;
  font-weight: 500;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.chat-message-actions span:hover {
  opacity: 1;
  text-decoration: underline;
}

