/* ===== SMS CONTACTS PAGE STYLES ===== */

/* Contact Limit Bar */
.contact-limit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.contact-limit-info {
  font-size: 0.8em;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

.contact-limit-track {
  width: 140px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.contact-limit-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.contact-limit-fill.warning { background: #f59e0b; }
.contact-limit-fill.danger { background: #ef4444; }

/* Group Limit Bar */
.group-limit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.group-limit-info {
  font-size: 0.8em;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

.group-limit-track {
  width: 140px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.group-limit-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.group-limit-fill.warning { background: #f59e0b; }
.group-limit-fill.danger { background: #ef4444; }

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title h2 { margin: 0; color: #2c3e50; font-size: 1.8em; }
.page-subtitle { margin: 4px 0 0; color: #7f8c8d; font-size: 0.95em; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== CONTACTS LAYOUT ===== */
.contacts-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

/* ===== GROUPS PANEL ===== */
.groups-panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid #e9ecef;
  overflow: hidden;
  position: sticky;
  top: 20px;
}

.groups-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #e9ecef;
  background: linear-gradient(135deg, rgba(106,90,224,0.06), rgba(74,144,226,0.06));
}

.groups-header h4 { margin: 0; font-size: 0.95em; color: #2c3e50; font-weight: 700; }

.groups-list { padding: 8px 0; }

.group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.group-item:hover { background: #f5f6fa; }

.group-item.active {
  background: rgba(74,144,226,0.08);
  border-left-color: var(--primary, #4a90e2);
}

.group-item.active .group-name { color: var(--primary, #4a90e2); font-weight: 600; }

.group-icon { font-size: 1em; }
.group-name { flex: 1; font-size: 0.88em; color: #2c3e50; }

.group-count {
  background: #e9ecef;
  color: #7f8c8d;
  font-size: 0.72em;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.group-item.active .group-count {
  background: var(--primary, #4a90e2);
  color: #fff;
}

.groups-divider { height: 1px; background: #e9ecef; margin: 6px 12px; }

.group-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.group-item:hover .group-actions { opacity: 1; }

.group-action-btn {
  background: none;
  border: none;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  color: #95a5a6;
}

.group-action-btn:hover { background: #e9ecef; color: #2c3e50; }

.groups-footer {
  border-top: 1px solid #e9ecef;
  padding: 12px;
}

.automation-shortcuts { display: flex; flex-direction: column; gap: 6px; }
.automation-shortcut-title { font-size: 0.75em; color: #95a5a6; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }

.automation-shortcut-btn {
  background: none;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.82em;
  color: #555;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.automation-shortcut-btn:hover {
  background: rgba(74,144,226,0.06);
  border-color: rgba(74,144,226,0.3);
  color: var(--primary, #4a90e2);
}

/* ===== CONTACTS MAIN ===== */
.contacts-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ===== TOOLBAR ===== */
.contacts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid #e9ecef;
}

.toolbar-left { flex: 1; min-width: 200px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 8px 14px;
  transition: border-color 0.2s;
  max-width: 360px;
}

.search-box:focus-within { border-color: var(--primary, #4a90e2); }
.search-icon { font-size: 0.95em; }

.search-input {
  border: none;
  background: none;
  outline: none;
  flex: 1;
  font-size: 0.92em;
  color: #2c3e50;
  min-width: 0;
}

.search-clear {
  background: none;
  border: none;
  color: #95a5a6;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.9em;
  line-height: 1;
}

.search-clear:hover { color: #e74c3c; }

/* View Toggle */
.view-toggle {
  display: flex;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1em;
  color: #95a5a6;
  transition: all 0.15s;
}

.view-btn.active { background: var(--primary, #4a90e2); color: #fff; }
.view-btn:not(.active):hover { background: #e9ecef; }

/* Bulk Actions */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-count {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--primary, #4a90e2);
  padding: 4px 10px;
  background: rgba(74,144,226,0.1);
  border-radius: 8px;
}

/* ===== TABLE VIEW ===== */
.contacts-table-wrapper {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid #e9ecef;
  overflow: auto;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
}

.contacts-table thead {
  background: linear-gradient(135deg, rgba(106,90,224,0.05), rgba(74,144,226,0.05));
  border-bottom: 2px solid #e9ecef;
}

.contacts-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: #2c3e50;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.contacts-table th:hover { background: rgba(74,144,226,0.06); }
.th-check, .th-actions { cursor: default !important; }
.th-actions { text-align: center; }

.contacts-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
  color: #2c3e50;
}

.contacts-table tbody tr:hover { background: #fafbfc; }
.contacts-table tbody tr:last-child td { border-bottom: none; }

.contacts-table tbody tr.selected { background: rgba(74,144,226,0.06) !important; }

.contact-name-cell { display: flex; align-items: center; gap: 10px; }

.contact-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a5ae0, #4a90e2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95em;
  flex-shrink: 0;
}

.contact-avatar.female { background: linear-gradient(135deg, #e0649a, #c8449c); }
.contact-avatar.male { background: linear-gradient(135deg, #4a90e2, #357abd); }

.contact-name-text { font-weight: 600; }

.phone-badge {
  font-size: 0.82em;
  padding: 2px 8px;
  background: #f0f2f5;
  border-radius: 8px;
  font-family: monospace;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78em;
  padding: 2px 8px;
  background: rgba(74,144,226,0.1);
  color: var(--primary, #4a90e2);
  border-radius: 10px;
  margin: 1px;
}

.sort-indicator::after { content: ''; margin-left: 4px; }
.sort-indicator.asc::after { content: '▲'; }
.sort-indicator.desc::after { content: '▼'; }

/* Automation toggles in table */
.auto-toggles { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

.auto-badge {
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.auto-badge.on { background: rgba(39,174,96,0.12); color: #27ae60; }
.auto-badge.off { background: #f0f2f5; color: #bdc3c7; }

/* Table Actions */
.table-actions { display: flex; gap: 5px; justify-content: center; }

.loading-row td { text-align: center; padding: 40px; }
.table-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #7f8c8d; }

/* ===== GRID VIEW ===== */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.contact-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid #e9ecef;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
}

.contact-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(74,144,226,0.12); border-color: var(--primary,#4a90e2); }

.contact-card.selected { border-color: var(--primary,#4a90e2); background: rgba(74,144,226,0.03); }

.contact-card-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 18px;
  height: 18px;
}

.contact-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a5ae0, #4a90e2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.3em;
  margin: 0 auto 12px;
}

.contact-card-avatar.female { background: linear-gradient(135deg, #e0649a, #c8449c); }
.contact-card-avatar.male { background: linear-gradient(135deg, #4a90e2, #357abd); }

.contact-card-name { text-align: center; font-weight: 700; color: #2c3e50; font-size: 0.95em; margin-bottom: 4px; }
.contact-card-phone { text-align: center; font-size: 0.82em; color: #7f8c8d; font-family: monospace; margin-bottom: 8px; }
.contact-card-groups { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-bottom: 10px; }
.contact-card-autos { display: flex; gap: 5px; justify-content: center; margin-bottom: 12px; }
.contact-card-actions { display: flex; gap: 6px; justify-content: center; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid #e9ecef;
}

.empty-icon { font-size: 3.5em; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { margin: 0 0 8px; color: #2c3e50; }
.empty-state p { margin: 0 0 20px; color: #7f8c8d; }

/* ===== PAGINATION ===== */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid #e9ecef;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.pagination-info { font-size: 0.85em; color: #7f8c8d; }

.pagination-controls { display: flex; gap: 4px; }

.page-btn {
  background: none;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85em;
  color: #2c3e50;
  transition: all 0.15s;
  min-width: 36px;
}

.page-btn:hover:not(:disabled) { background: rgba(74,144,226,0.08); border-color: var(--primary,#4a90e2); }
.page-btn.active { background: var(--primary,#4a90e2); color: #fff; border-color: var(--primary,#4a90e2); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== MODALS ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-overlay, rgba(0,0,0,0.5));
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--modal-bg, #fff);
  border-radius: 16px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.06));
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}

.modal-xl .modal-content { max-width: 760px; }
.modal-large .modal-content { max-width: 680px; }
.modal-sm .modal-content { max-width: 420px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color, #e9ecef);
}

.modal-header h3 { margin: 0; color: var(--text-color, #2c3e50); font-size: 1.1em; font-weight: 650; }

.modal-header .close {
  font-size: 1.3em;
  color: var(--text-muted, #95a5a6);
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.15s;
}

.modal-header .close:hover { color: var(--danger, #e74c3c); background: rgba(231,76,60,0.06); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 26px 22px;
  border-top: 1px solid #e9ecef;
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 26px 0;
  border-bottom: 2px solid #e9ecef;
  overflow-x: auto;
  scrollbar-width: none;
}

.modal-tabs::-webkit-scrollbar { display: none; }

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.88em;
  font-weight: 600;
  color: #7f8c8d;
  margin-bottom: -2px;
  white-space: nowrap;
  border-radius: 8px 8px 0 0;
  transition: all 0.15s;
}

.modal-tab.active { color: var(--primary,#4a90e2); border-bottom-color: var(--primary,#4a90e2); background: rgba(74,144,226,0.05); }
.modal-tab:hover:not(.active) { color: #2c3e50; background: #f8f9fa; }

.modal-tab-content { display: none; padding: 22px 26px; }
.modal-tab-content.active { display: block; }

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; }
.form-group-full { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.88em;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  font-size: 0.9em;
  font-family: inherit;
  color: #2c3e50;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  background: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary,#4a90e2);
  box-shadow: 0 0 0 3px rgba(74,144,226,0.1);
}

textarea.form-control { resize: vertical; min-height: 70px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.78em; color: #95a5a6; margin-top: 4px; }

/* Group checkboxes */
.group-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.group-checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.group-checkbox-item:hover { border-color: var(--primary,#4a90e2); background: rgba(74,144,226,0.05); }
.group-checkbox-item.checked { background: rgba(74,144,226,0.1); border-color: var(--primary,#4a90e2); color: var(--primary,#4a90e2); }

.group-checkbox-item input[type="checkbox"] { display: none; }
.group-checkbox-item span { font-size: 0.85em; }

/* Phone rows */
#phonesList { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.phone-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.phone-row .form-control { margin: 0; }
.phone-type-select { width: 140px; flex-shrink: 0; }
.phone-number-input { flex: 1; }

.btn-add-phone {
  background: none;
  border: 2px dashed #dee2e6;
  border-radius: 10px;
  padding: 10px;
  width: 100%;
  text-align: center;
  cursor: pointer;
  color: #7f8c8d;
  font-size: 0.88em;
  transition: all 0.15s;
}

.btn-add-phone:hover { border-color: var(--primary,#4a90e2); color: var(--primary,#4a90e2); background: rgba(74,144,226,0.03); }

/* ===== AUTOMATION ===== */
.automation-settings { display: flex; flex-direction: column; gap: 16px; }

.automation-item {
  border: 1px solid #e9ecef;
  border-radius: 12px;
  overflow: hidden;
}

.automation-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #f8f9fa;
}

.automation-info { display: flex; align-items: center; gap: 12px; }
.automation-icon-lg { font-size: 1.8em; }
.automation-info strong { display: block; color: #2c3e50; }
.automation-info p { margin: 2px 0 0; font-size: 0.83em; color: #7f8c8d; }

.automation-config { padding: 16px 18px; border-top: 1px solid #e9ecef; }

.automation-info-box {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(74,144,226,0.06);
  border-radius: 10px;
  border: 1px solid rgba(74,144,226,0.15);
  font-size: 0.85em;
  color: #555;
  line-height: 1.5;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #dee2e6;
  border-radius: 26px;
  transition: background 0.25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 4px;
  top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: #27ae60; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== GROUP MODAL ===== */
.group-add-form { padding: 20px 26px 0; }

.input-row { display: flex; gap: 8px; }
.icon-select {
  width: 120px;
  flex-shrink: 0;
  font-size: 0.9em;
  padding: 10px 12px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  background: #f9fafb;
  color: #2c3e50;
  font-family: var(--font-family, inherit);
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237f8c8d' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.icon-select:focus {
  outline: none;
  border-color: var(--primary, #4a90e2);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
  background-color: white;
}

.icon-select option {
  font-size: 0.95em;
  padding: 8px 12px;
  font-family: var(--font-family, inherit);
}

.groups-manage-list { padding: 16px 26px; display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }

.group-manage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.group-manage-item .group-icon { font-size: 1.1em; }
.group-manage-item .group-name { flex: 1; font-size: 0.9em; color: #2c3e50; }
.group-manage-item .group-count-badge { font-size: 0.78em; color: #7f8c8d; background: #e9ecef; padding: 2px 8px; border-radius: 8px; }

/* ===== IMPORT MODAL ===== */
.import-dropzone {
  margin: 20px 26px;
  border: 2px dashed #dee2e6;
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.import-dropzone:hover, .import-dropzone.drag-over {
  border-color: var(--primary,#4a90e2);
  background: rgba(74,144,226,0.03);
}

.dropzone-icon { font-size: 2.5em; margin-bottom: 10px; }
.dropzone-text { color: #7f8c8d; font-size: 0.9em; line-height: 1.5; }

.import-preview { margin: 0 26px 20px; }
.import-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 16px;
  flex-wrap: wrap;
}

.import-preview-header span { font-weight: 700; color: #27ae60; font-size: 0.9em; }

.import-preview-table-wrapper { max-height: 280px; overflow: auto; border-radius: 10px; border: 1px solid #e9ecef; }
.import-preview-table { width: 100%; border-collapse: collapse; font-size: 0.82em; }
.import-preview-table th { padding: 8px 12px; background: #f8f9fa; text-align: left; font-weight: 700; color: #2c3e50; border-bottom: 1px solid #e9ecef; white-space: nowrap; }
.import-preview-table td { padding: 7px 12px; border-bottom: 1px solid #f0f2f5; color: #555; white-space: nowrap; }
.import-preview-table tbody tr:last-child td { border-bottom: none; }

/* ===== GOOGLE SYNC ===== */
.google-logo-area { text-align: center; padding: 16px 0; }
.google-sync-content { padding: 20px 26px; }
.google-sync-content h4 { margin: 0 0 8px; color: #2c3e50; }
.google-sync-content p { color: #7f8c8d; font-size: 0.9em; line-height: 1.5; margin: 0 0 16px; }
.google-features { display: flex; flex-direction: column; gap: 6px; }
.google-feature { font-size: 0.88em; color: #27ae60; }

/* ===== AUTOMATION PANEL ===== */
.automation-panel-tabs { display: flex; gap: 8px; padding: 20px 26px 0; }
.automation-panel-tab {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.88em;
  color: #7f8c8d;
  font-weight: 600;
  transition: all 0.15s;
}

.automation-panel-tab.active { background: var(--primary,#4a90e2); color: #fff; border-color: var(--primary,#4a90e2); }
.automation-panel-tab:hover:not(.active) { background: #e9ecef; color: #2c3e50; }

#automationPanelContent { padding: 20px 26px; }
.automation-panel-contacts-list { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow-y: auto; }

.automation-contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.automation-contact-row .contact-avatar { width: 30px; height: 30px; font-size: 0.85em; }
.automation-contact-name { flex: 1; font-size: 0.9em; font-weight: 600; color: #2c3e50; }
.automation-contact-phone { font-size: 0.82em; color: #7f8c8d; font-family: monospace; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary,#4a90e2), #357abd);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9em;
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(74,144,226,0.3); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: #f8f9fa;
  color: #2c3e50;
  border: 2px solid #e9ecef;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9em;
}

.btn-secondary:hover { background: #e2e6ea; border-color: #dde1e5; }

.btn-danger {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9em;
}

.btn-danger:hover { background: #c0392b; }

.btn-google {
  background: #fff;
  color: #2c3e50;
  border: 2px solid #e9ecef;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88em;
  transition: all 0.2s;
}

.btn-google:hover:not(:disabled) { border-color: #4285F4; color: #4285F4; }
.btn-google:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-google.btn-large { font-size: 1em; padding: 12px 24px; margin-top: 16px; }

.btn-icon {
  background: none;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #7f8c8d;
  font-size: 1.1em;
  font-weight: 700;
  transition: all 0.15s;
}

.btn-icon:hover { background: var(--primary,#4a90e2); color: #fff; border-color: var(--primary,#4a90e2); }

.btn-sm {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82em;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-sm.btn-secondary { border: 1px solid #e9ecef; }
.btn-sm.btn-danger { background: rgba(231,76,60,0.1); color: #e74c3c; }
.btn-sm.btn-danger:hover { background: #e74c3c; color: #fff; }

/* Table action buttons */
.btn-action {
  background: none;
  border: 1px solid #e9ecef;
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.15s;
  color: #555;
}

.btn-action:hover { background: #f0f2f5; }
.btn-action.edit:hover { border-color: var(--primary,#4a90e2); color: var(--primary,#4a90e2); background: rgba(74,144,226,0.06); }
.btn-action.delete:hover { border-color: #e74c3c; color: #e74c3c; background: rgba(231,76,60,0.06); }
.btn-action.sms:hover { border-color: #27ae60; color: #27ae60; background: rgba(39,174,96,0.06); }

/* ===== DROPDOWN ===== */
.dropdown-wrapper { position: relative; }

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dropdown-arrow { font-size: 0.75em; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  border: 1px solid #e9ecef;
  min-width: 200px;
  z-index: 1000;
  animation: dropIn 0.15s ease;
  overflow: hidden;
}

.dropdown-menu.open,
.dropdown-menu.show { display: block; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-section-title { font-size: 0.72em; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: #95a5a6; padding: 10px 14px 4px; }
.dropdown-divider { height: 1px; background: #e9ecef; margin: 4px 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.88em;
  color: #2c3e50;
  transition: background 0.12s;
}

.dropdown-item:hover { background: #1a73e8; color: #fff; }
.dropdown-item:hover .dropdown-item-icon svg { stroke: #fff; }
.dropdown-item-icon { font-size: 1em; }

/* ===== ALERT ===== */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 0.9em; font-weight: 500; }
.alert-error { background: rgba(231,76,60,0.1); color: #c0392b; border: 1px solid rgba(231,76,60,0.2); }
.alert-success { background: rgba(39,174,96,0.1); color: #27ae60; border: 1px solid rgba(39,174,96,0.2); }
.alert-info { background: rgba(74,144,226,0.1); color: #2980b9; border: 1px solid rgba(74,144,226,0.2); }
.alert-warning { background: rgba(243,156,18,0.1); color: #d68910; border: 1px solid rgba(243,156,18,0.2); }

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e9ecef;
  border-top-color: var(--primary,#4a90e2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SOURCE TABS (Own / Google) ===== */
.contacts-source-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
}

.source-tab {
  padding: 12px 24px;
  background: none;
  border: none;
  font-size: 0.95em;
  font-weight: 600;
  color: #7f8c8d;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-tab:hover { color: #2c3e50; }

.source-tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
}

/* Google Info Notice */
.google-info-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #1e40af;
  font-size: 0.88em;
  font-weight: 500;
  margin-bottom: 16px;
  line-height: 1.5;
}

.google-info-notice svg {
  flex-shrink: 0;
  stroke: #1e40af;
}

/* ===== GOOGLE CONTACTS ===== */
.google-contacts-area {
  background: white;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  padding: 30px;
}

.google-connect-box {
  text-align: center;
  padding: 60px 20px;
}

.google-connect-box h3 { margin: 20px 0 8px; color: #2c3e50; }
.google-connect-box p { color: #7f8c8d; margin-bottom: 24px; }

.google-logo-area { margin-bottom: 16px; }

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: white;
  border: 2px solid #dadce0;
  border-radius: 100px;
  font-size: 0.9em;
  font-weight: 600;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-google:hover { border-color: #4285f4; background: #f8f9ff; }

.btn-google.btn-large { padding: 14px 32px; font-size: 1em; }

.google-connected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.google-connected-header h3 { margin: 0; color: #2c3e50; }
.google-connected-header p { margin: 4px 0 0; color: #7f8c8d; font-size: 0.9em; }

.google-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.google-search-bar {
  margin-bottom: 14px;
}

.google-search-bar .search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 360px;
}

.google-search-bar .search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted, #999);
  pointer-events: none;
}

.google-search-bar input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  font-size: 0.88em;
  background: var(--surface-alt, #f8f9fa);
  color: var(--text-color, #333);
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.google-search-bar input:focus {
  outline: none;
  border-color: var(--primary, #4a90e2);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.08);
}

.google-search-bar input::placeholder {
  color: var(--text-muted, #aaa);
}

.btn-danger-outline {
  padding: 8px 18px;
  border: 1.5px solid #e74c3c;
  background: white;
  color: #e74c3c;
  border-radius: 8px;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger-outline:hover { background: #fdf0ef; }

/* ===== BIRTHDAY SMS SECTION (in modal) ===== */
.birthday-sms-section {
  border-top: 1px solid #e9ecef;
  margin: 16px 24px 0;
  padding-top: 16px;
}

.birthday-sms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.birthday-sms-header .automation-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.birthday-sms-config {
  padding: 12px 0;
}

.birthday-sms-config .form-group {
  margin-bottom: 12px;
}

/* ===== AUTOMATION BULK ===== */
.automation-bulk-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .contacts-layout { grid-template-columns: 190px 1fr; }
}

@media (max-width: 768px) {
  .contacts-layout { grid-template-columns: 1fr; }

  .groups-panel { position: static; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; flex-wrap: wrap; }

  .form-grid { grid-template-columns: 1fr; }
  .form-group-full { grid-column: 1; }

  .modal-tabs { padding: 12px 16px 0; }
  .modal-tab-content { padding: 16px; }
  .modal-footer, .modal-header { padding-left: 16px; padding-right: 16px; }

  .contacts-table { font-size: 0.82em; }
  .contacts-table td, .contacts-table th { padding: 9px 10px; }

  .pagination-wrapper { flex-direction: column; align-items: flex-start; }

  .phone-row { flex-direction: column; }
  .phone-type-select { width: 100%; }
}

@media (max-width: 480px) {
  .contacts-grid { grid-template-columns: 1fr; }
  .bulk-actions { gap: 5px; flex-wrap: wrap; }
  .bulk-actions button { flex: 1 1 calc(50% - 5px); min-height: 38px; }
  .modal-tabs { gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .modal-tab { padding: 8px 10px; font-size: 0.82em; white-space: nowrap; flex-shrink: 0; }
  .contacts-table { font-size: 0.75em; min-width: 600px; }
  .contacts-table td, .contacts-table th { padding: 7px 8px; }
  .import-preview-table { font-size: 0.78em; }
  .page-header h1 { font-size: 1.2em; }
  .page-header-actions button { flex: 1 1 calc(50% - 4px); justify-content: center; min-height: 42px; }
  .groups-panel { padding: 12px; }
  .modal-content { padding: 14px; }
  .contact-name-cell { gap: 8px; }
  .contact-avatar { width: 32px; height: 32px; font-size: 11px; }
}

@media (max-width: 360px) {
  .page-header h1 { font-size: 1.08em; }
  .contacts-table { font-size: 0.7em; min-width: 540px; }
  .page-header-actions button { flex: 1 1 100%; font-size: 0.85em; }
  .modal-tab { padding: 7px 9px; font-size: 0.78em; }
}

/* ===== GROUP CONTEXT MENU ===== */
.group-context-menu {
  position: fixed;
  z-index: 10000;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  min-width: 160px;
  animation: ctxIn 0.12s ease;
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.group-context-menu .ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 0.88em;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s;
}
.group-context-menu .ctx-item:hover {
  background: #f1f5f9;
}
.group-context-menu .ctx-item.ctx-danger {
  color: #ef4444;
}
.group-context-menu .ctx-item.ctx-danger:hover {
  background: #fef2f2;
}
body.dark-theme .group-context-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
body.dark-theme .group-context-menu .ctx-item {
  color: #cbd5e1;
}
body.dark-theme .group-context-menu .ctx-item:hover {
  background: #334155;
}
body.dark-theme .group-context-menu .ctx-item.ctx-danger {
  color: #f87171;
}
body.dark-theme .group-context-menu .ctx-item.ctx-danger:hover {
  background: rgba(239,68,68,0.1);
}

/* ===== BIRTHDAY SMS TAG EDITOR ===== */
.bday-editor {
  min-height: 42px;
  max-height: 100px;
  overflow-y: auto;
  padding: 8px 12px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  cursor: text;
}
.bday-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.bday-editor:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
  outline: none;
}
.bday-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #eff6ff;
  color: #3b82f6;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 0.82em;
  font-weight: 500;
  line-height: 1.6;
  vertical-align: baseline;
  user-select: all;
  cursor: default;
}
.bday-tag-x {
  cursor: pointer;
  font-size: 1.1em;
  color: #93c5fd;
  margin-left: 1px;
  line-height: 1;
  transition: color 0.15s;
}
.bday-tag-x:hover {
  color: #ef4444;
}
.bday-var-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.bday-var-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.8em;
  cursor: pointer;
  transition: all 0.15s;
}
.bday-var-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}

/* Dark theme */
body.dark-theme .bday-editor {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
body.dark-theme .bday-editor:empty::before {
  color: #64748b;
}
body.dark-theme .bday-tag {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.3);
  color: #60a5fa;
}
body.dark-theme .bday-tag-x {
  color: rgba(96,165,250,0.5);
}
body.dark-theme .bday-var-btn {
  background: #1e293b;
  border-color: #475569;
  color: #94a3b8;
}
body.dark-theme .bday-var-btn:hover {
  border-color: #60a5fa;
  color: #60a5fa;
  background: rgba(59,130,246,0.1);
}

/* ===== BIRTHDAY SMS RULES ===== */
.bday-rule-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  transition: border-color 0.15s;
}
.bday-rule-card:hover {
  border-color: #cbd5e1;
}
.bday-rule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.bday-rule-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 0.75em;
  font-weight: 600;
}
.bday-rule-remove {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.3em;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.bday-rule-remove:hover {
  background: #fef2f2;
  color: #ef4444;
}
.bday-rule-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.bday-rule-timing {
  flex: 1;
}
.bday-rule-time {
  width: 110px;
  flex-shrink: 0;
}
.bday-rule-row .form-group {
  margin-bottom: 0;
}
.bday-rule-row label {
  font-size: 0.8em;
  color: #64748b;
  margin-bottom: 4px;
  display: block;
}
.bday-rule-card .form-group > label {
  font-size: 0.8em;
  color: #64748b;
  margin-bottom: 4px;
}
.bday-time-input {
  padding: 8px 10px;
  font-family: inherit;
}
.bday-add-rule-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.15s;
}
.bday-add-rule-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}

/* Dark theme */
body.dark-theme .bday-rule-card {
  background: #1e293b;
  border-color: #334155;
}
body.dark-theme .bday-rule-card:hover {
  border-color: #475569;
}
body.dark-theme .bday-rule-remove:hover {
  background: rgba(239,68,68,0.1);
}
body.dark-theme .bday-rule-row label,
body.dark-theme .bday-rule-card .form-group > label {
  color: #94a3b8;
}
body.dark-theme .bday-add-rule-btn {
  border-color: #475569;
  color: #94a3b8;
}
body.dark-theme .bday-add-rule-btn:hover {
  border-color: #60a5fa;
  color: #60a5fa;
  background: rgba(59,130,246,0.1);
}
