/* Eleos Support - Config Page Styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
}

/* ============================================
   Login View
   ============================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.login-header {
  padding: 40px 30px 30px;
  text-align: center;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.login-header .logo-icon {
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.login-header .subtitle {
  font-size: 14px;
  color: #64748b;
}

.login-body {
  padding: 30px;
}

/* ============================================
   App Layout
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  width: 240px;
  background: white;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.sidebar-header .logo-icon {
  flex-shrink: 0;
}

.sidebar-header .logo-text {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-items {
  margin-top: 4px;
}

.nav-item {
  display: block;
  padding: 10px 20px 10px 48px;
  font-size: 14px;
  color: #64748b;
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: #f8fafc;
  color: #1e293b;
}

.nav-item.active {
  background: #eff6ff;
  color: #0066cc;
  border-left-color: #0066cc;
  font-weight: 500;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  background: white;
  border-bottom: 1px solid #e2e8f0;
}

.top-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-connected {
  background: #dcfce7;
  color: #16a34a;
}

.status-connected::before {
  background: #22c55e;
}

.status-disconnected {
  background: #fee2e2;
  color: #dc2626;
}

.status-disconnected::before {
  background: #ef4444;
}

.content-area {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* ============================================
   Content Sections
   ============================================ */
.content-section {
  display: none;
}

.content-section.active {
  display: block;
}

.section-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

.section-description {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 20px;
}

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

.section-header h3 {
  margin-bottom: 0;
}

.section-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-group input:disabled,
.form-group select:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

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

.input-with-toggle {
  position: relative;
}

.input-with-toggle input {
  padding-right: 45px;
}

.btn-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #64748b;
  transition: color 0.15s;
}

.btn-toggle:hover {
  color: #1e293b;
}

.hint {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
}

.char-count {
  text-align: right;
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #0066cc;
  color: white;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: #0052a3;
}

.btn-google {
  background: white;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  width: 100%;
  font-weight: 500;
}

.btn-google:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.login-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #64748b;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-small {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: white;
  border: 1px solid #e2e8f0;
  color: #64748b;
}

.btn-small:hover:not(:disabled) {
  background: #f8fafc;
  color: #1e293b;
}

.btn-small.btn-danger {
  border-color: #fecaca;
  color: #dc2626;
  background: white;
}

.btn-small.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.button-group .btn {
  flex: 1;
}

/* ============================================
   Alerts
   ============================================ */
.error {
  padding: 12px 16px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 14px;
  margin-bottom: 16px;
}

.success {
  padding: 12px 16px;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #16a34a;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ============================================
   Tables
   ============================================ */
.table-container {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead {
  background: #f8fafc;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
}

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

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table .empty-message {
  text-align: center;
  color: #94a3b8;
  padding: 40px 16px;
}

.data-table .message-cell {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status badges in tables */
.data-table .status-badge {
  padding: 4px 10px;
  font-size: 11px;
}

.data-table .status-badge::before {
  display: none;
}

.status-badge.sent,
.status-badge.delivered,
.status-badge.success,
.status-badge.completed {
  background: #dcfce7;
  color: #16a34a;
}

.status-badge.failed,
.status-badge.undelivered {
  background: #fee2e2;
  color: #dc2626;
}

.status-badge.pending,
.status-badge.queued {
  background: #fef3c7;
  color: #d97706;
}

.status-badge.received {
  background: #dbeafe;
  color: #2563eb;
}

/* Direction badge */
.direction-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.direction-badge.outbound {
  background: #dcfce7;
  color: #16a34a;
}

.direction-badge.inbound {
  background: #dbeafe;
  color: #2563eb;
}

/* ============================================
   Info Box
   ============================================ */
.info-box {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1e40af;
}

.info-box svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.info-box strong {
  display: block;
  margin-bottom: 8px;
}

.info-box ul {
  margin: 8px 0;
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 4px;
  font-size: 13px;
}

.info-box code {
  background: rgba(255, 255, 255, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
}

.info-box p {
  margin-top: 12px;
  font-size: 13px;
  opacity: 0.9;
}

/* ============================================
   Help Links
   ============================================ */
.help-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.help-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #64748b;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s ease;
}

.help-link:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #0066cc;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .button-group {
    flex-direction: column;
  }
}

/* ============================================
   Sync Progress (for extension popup compatibility)
   ============================================ */
#sync-progress-container {
  margin: 16px 0;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.sync-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#sync-progress-text {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
}

#sync-progress-percent {
  font-size: 13px;
  font-weight: 600;
  color: #0066cc;
}

.sync-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.sync-progress-fill {
  height: 100%;
  background: #0066cc;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.sync-progress-details {
  font-size: 12px;
  color: #64748b;
}

/* ============================================
   Integration Cards
   ============================================ */
.integration-card {
  margin-top: 20px;
  padding: 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

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

.integration-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.integration-icon.twilio {
  background: #f22f46;
  color: white;
}

.integration-icon.brevo {
  background: #0b996e;
  color: white;
}

.integration-icon.aircall {
  background: #00b388;
  color: white;
}

.integration-info {
  flex: 1;
}

.integration-info h4 {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.integration-info p {
  font-size: 13px;
  color: #64748b;
}

.integration-status {
  display: flex;
  align-items: center;
}

.integration-status .status-badge {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.status-loading {
  background: #f1f5f9;
  color: #64748b;
}

.status-badge.status-loading::before {
  background: #94a3b8;
}

.status-badge.status-configured {
  background: #dcfce7;
  color: #16a34a;
}

.status-badge.status-configured::before {
  background: #22c55e;
}

.status-badge.status-not-configured {
  background: #fef3c7;
  color: #d97706;
}

.status-badge.status-not-configured::before {
  background: #f59e0b;
}

.status-badge.status-error {
  background: #fee2e2;
  color: #dc2626;
}

.status-badge.status-error::before {
  background: #ef4444;
}

.integration-env-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.integration-env-vars code {
  background: white;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  color: #64748b;
}

/* ============================================
   Active Sync Progress
   ============================================ */
.status-badge.status-processing {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.status-processing::before {
  background: #3b82f6;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sync-job-item {
  padding: 16px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 12px;
}

.sync-job-item:last-child {
  margin-bottom: 0;
}

.sync-job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sync-job-title {
  font-weight: 600;
  color: #1e293b;
}

.sync-job-meta {
  font-size: 13px;
  color: #64748b;
}

.sync-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sync-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.sync-progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #64748b;
}

.sync-progress-stats .stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sync-progress-stats .stat.created {
  color: #059669;
}

.sync-progress-stats .stat.failed {
  color: #dc2626;
}

/* ============================================
   Phone Detail Modal
   ============================================ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover {
  color: #1e293b;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

/* Brevo Link Container */
#brevo-link-container {
  margin-bottom: 20px;
}

#brevo-link-container:empty {
  display: none;
}

.brevo-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #0b996e;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.brevo-link-btn:hover {
  background: #087a57;
}

.brevo-link-btn svg {
  flex-shrink: 0;
}

/* Phone Messages List */
#phone-messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-item {
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 85%;
}

.message-item.outbound {
  background: #dcfce7;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-item.inbound {
  background: #dbeafe;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-item .message-text {
  font-size: 14px;
  color: #1e293b;
  line-height: 1.5;
  word-break: break-word;
}

.message-item .message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
}

.message-item .message-status {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  font-weight: 500;
}

/* Clickable Phone Numbers */
.phone-link {
  color: #0066cc;
  cursor: pointer;
  text-decoration: none;
}

.phone-link:hover {
  text-decoration: underline;
}

/* Loading State in Modal */
.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #64748b;
}

.modal-loading svg {
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

.no-messages {
  text-align: center;
  padding: 40px;
  color: #94a3b8;
}
