/* Afendor Group WhatsApp Management Dashboard Stylesheet */
:root {
  --bg-dark: #0b141a;
  --bg-sidebar: #111b21;
  --bg-header: #202c33;
  --bg-chat: #0b141a;
  --bg-message-out: #005c4b;
  --bg-message-in: #202c33;
  --bg-card: #182229;
  --bg-input: #2a3942;
  
  --accent-green: #00a884;
  --accent-green-hover: #06cf9c;
  --accent-blue: #53bdeb;

  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --border-color: #222d34;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body.dark-theme {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(134, 150, 160, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(134, 150, 160, 0.5);
}

/* ==================== AUTH OVERLAY ==================== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #0b141a 0%, #111b21 50%, #00221c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 168, 132, 0.1);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}
.brand-logo {
  font-size: 48px;
  color: var(--accent-green);
  margin-bottom: 8px;
}
.auth-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.auth-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 168, 132, 0.15);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  width: max-content;
}
.wizard-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent-green);
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--bg-header);
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border-color);
}
.qr-box img {
  width: 160px;
  height: 160px;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}
.qr-info {
  display: flex;
  gap: 6px;
  font-size: 12px;
}
.qr-info code {
  color: var(--accent-green);
  font-weight: 600;
  letter-spacing: 1px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover {
  background: var(--accent-green-hover);
}
.btn-primary:active {
  transform: scale(0.98);
}

.error-msg {
  color: #f87171;
  font-size: 13px;
  text-align: center;
}
.success-msg {
  color: #4ade80;
  font-size: 13px;
  text-align: center;
}

/* ==================== DASHBOARD LAYOUT ==================== */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 380px;
  min-width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: 60px;
  background: var(--bg-header);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}
.user-profile-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  text-transform: uppercase;
}
.admin-avatar {
  background: linear-gradient(135deg, #00a884, #005c4b);
}
.user-name {
  font-size: 14px;
  font-weight: 600;
}
.user-role-badge {
  font-size: 11px;
  color: var(--accent-green);
}
.header-actions {
  display: flex;
  gap: 8px;
}
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* CHANNEL SELECTOR */
.channel-selector-bar {
  padding: 12px 16px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
}
.channel-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.channel-tabs {
  display: flex;
  gap: 8px;
}
.channel-tab {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.channel-tab:hover {
  border-color: var(--accent-green);
  color: var(--text-primary);
}
.channel-tab.active {
  background: rgba(0, 168, 132, 0.15);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

/* CONTACT SEARCH */
.search-bar {
  padding: 10px 16px;
  background: var(--bg-sidebar);
}
.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
}
.search-input-wrapper input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
  outline: none;
}

/* CONTACTS LIST */
.contacts-list {
  flex: 1;
  overflow-y: auto;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s;
}
.contact-item:hover {
  background: var(--bg-header);
}
.contact-item.active {
  background: var(--bg-input);
}
.contact-info {
  flex: 1;
  min-width: 0;
}
.contact-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.contact-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-time {
  font-size: 11px;
  color: var(--text-muted);
}
.contact-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contact-last-msg {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unread-badge {
  background: var(--accent-green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* CHAT MAIN */
.chat-main {
  flex: 1;
  background: var(--bg-chat);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* EMPTY STATE */
.empty-chat-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}
.empty-illustration {
  font-size: 72px;
  color: var(--accent-green);
  margin-bottom: 20px;
  opacity: 0.8;
}
.empty-chat-state h2 {
  font-size: 24px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.empty-chat-state p {
  font-size: 14px;
  max-width: 460px;
  line-height: 1.5;
  margin-bottom: 24px;
}
.empty-features {
  display: flex;
  gap: 16px;
  font-size: 12px;
}
.empty-features span {
  background: var(--bg-header);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

/* ACTIVE CHAT VIEW */
.active-chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-header {
  height: 60px;
  background: var(--bg-header);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}
.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.contact-details h3 {
  font-size: 15px;
  font-weight: 600;
}
.contact-details span {
  font-size: 12px;
  color: var(--text-secondary);
}
.active-channel-pill {
  background: rgba(0, 168, 132, 0.15);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* MESSAGES FEED */
.messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0);
  background-size: 24px 24px;
}

.msg-row {
  display: flex;
  width: 100%;
}
.msg-row.outgoing {
  justify-content: flex-end;
}
.msg-row.incoming {
  justify-content: flex-start;
}

.msg-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 10px;
  position: relative;
  font-size: 14.5px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  word-wrap: break-word;
}
.msg-bubble.outgoing {
  background: var(--bg-message-out);
  color: var(--text-primary);
  border-top-right-radius: 2px;
}
.msg-bubble.incoming {
  background: var(--bg-message-in);
  color: var(--text-primary);
  border-top-left-radius: 2px;
}

.msg-media {
  margin-bottom: 6px;
  border-radius: 8px;
  overflow: hidden;
}
.msg-media img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
}
.msg-media-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  float: right;
  margin-left: 12px;
}
.msg-bubble.outgoing .msg-footer {
  color: rgba(255, 255, 255, 0.7);
}

.msg-status-tick {
  font-size: 12px;
}
.msg-status-tick.read {
  color: var(--accent-blue);
}

/* INPUT BAR */
.chat-input-bar {
  height: 62px;
  background: var(--bg-header);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border-color);
}
.btn-icon-input {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  transition: color 0.2s;
}
.btn-icon-input:hover {
  color: var(--accent-green);
}
.message-input-container {
  flex: 1;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 8px 14px;
}
.message-input-container input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.btn-send {
  background: var(--accent-green);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s, transform 0.1s;
}
.btn-send:hover {
  background: var(--accent-green-hover);
}

/* ==================== MODAL OVERLAYS ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
}
.modal-card.modal-large {
  max-width: 720px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}
.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}
.tab-btn {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
}
.tab-btn.active {
  background: var(--accent-green);
  color: #fff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.admin-table th {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group {
  flex: 1;
}
