/* ══════════════════════════════════════════════════════════════════
   SMS MARKETING TAB — Terror 29 Dashboard
   ══════════════════════════════════════════════════════════════════ */

.sms-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1a1a1a;
}
@media (max-width: 600px) {
  .sms-nav {
    grid-template-columns: repeat(2, 1fr);
  }
}
.sms-nav-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #aaa;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
}
.sms-nav-btn:hover { background: #252525; color: #fff; }
.sms-nav-btn.active { background: #FF2D55; border-color: #FF2D55; color: #fff; }

/* Stats grid */
.sms-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
@media (min-width: 600px) {
  .sms-stat-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
/* Last odd card fills full width on 2-col layout */
.sms-stat-grid .sms-stat-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}
.sms-stat-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 16px;
}
.sms-stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.sms-stat-card .stat-label {
  font-size: 0.72rem;
  color: #888;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tables */
.sms-table {
  width: 100%;
  border-collapse: collapse;
}
.sms-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.72rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #2a2a2a;
}
.sms-table td {
  padding: 12px;
  border-bottom: 1px solid #1a1a1a;
  color: #ddd;
  font-size: 0.85rem;
  vertical-align: middle;
}
.sms-table tr:hover td { background: #141414; cursor: pointer; }

/* Status badges */
.sms-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sms-badge.draft { background: #2a2a2a; color: #888; }
.sms-badge.scheduled { background: #0a2a4a; color: #4fc3f7; }
.sms-badge.sending { background: #3a2000; color: #ff9500; }
.sms-badge.sent { background: #0a2a18; color: #30D158; }
.sms-badge.failed { background: #2a0808; color: #FF3B30; }

/* Section headers */
.sms-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.sms-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

/* Buttons */
.sms-btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}
.sms-btn-primary { background: #FF2D55; color: #fff; }
.sms-btn-primary:hover { background: #e0263d; }
.sms-btn-secondary { background: #1a1a1a; border: 1px solid #333; color: #aaa; }
.sms-btn-secondary:hover { background: #252525; color: #fff; }
.sms-btn-danger { background: #2a0808; border: 1px solid #FF3B30; color: #FF3B30; }
.sms-btn-sm { padding: 5px 12px; font-size: 0.78rem; }

/* Compose layout */
.sms-compose-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 768px) {
  .sms-compose-layout { grid-template-columns: 1fr; }
  .phone-mockup-wrap { display: none; }
}

.sms-form-group { margin-bottom: 16px; }
.sms-form-group label {
  display: block;
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 6px;
  font-weight: 500;
}
.sms-input, .sms-textarea, .sms-select {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.sms-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
.sms-select option { background: #1a1a1a; }
.sms-input:focus, .sms-textarea:focus, .sms-select:focus {
  outline: none;
  border-color: #FF2D55;
}

.char-counter {
  font-size: 0.75rem;
  color: #30D158;
  margin-top: 5px;
  font-weight: 500;
}
.char-counter.warn { color: #ff9500; }
.char-counter.danger { color: #FF3B30; }

/* Audience section */
.sms-audience-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sms-radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ccc;
  font-size: 0.85rem;
  cursor: pointer;
}
.sms-radio-label input { accent-color: #FF2D55; }
.sms-audience-sub {
  margin-left: 20px;
  margin-top: 6px;
}
.audience-count-preview {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #aaa;
  margin-top: 10px;
}
.audience-count-preview strong { color: #fff; font-size: 1.1rem; }

/* Phone mockup */
.phone-mockup-wrap { position: sticky; top: 16px; }
.phone-mockup {
  background: #111;
  border: 2px solid #2a2a2a;
  border-radius: 36px;
  padding: 18px 10px;
  width: 220px;
  min-height: 400px;
  margin: 0 auto;
}
.phone-notch {
  width: 70px;
  height: 5px;
  background: #2a2a2a;
  border-radius: 3px;
  margin: 0 auto 14px;
}
.phone-screen {
  background: #000;
  border-radius: 18px;
  padding: 10px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.phone-header {
  font-size: 0.65rem;
  color: #666;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #1a1a1a;
  margin-bottom: 10px;
}
.chat-preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px 0;
}
.sms-bubble-preview {
  background: #1c1c1e;
  border: 1px solid #2a2a2a;
  color: #ddd;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 3px;
  font-size: 0.72rem;
  max-width: 95%;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
}
.phone-mockup-label {
  text-align: center;
  font-size: 0.72rem;
  color: #555;
  margin-top: 10px;
}

/* Token button */
.sms-token-btn {
  background: #1a1a1a;
  border: 1px solid #444;
  color: #aaa;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: monospace;
  transition: all 0.2s;
}
.sms-token-btn:hover { background: #252525; color: #FF2D55; border-color: #FF2D55; }

/* Compose action bar */
.sms-action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #1a1a1a;
}

/* Subscribers search bar */
.sms-search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.sms-search-input {
  flex: 1;
  min-width: 200px;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.85rem;
}

/* Inbox */
.sms-inbox-layout {
  display: flex;
  gap: 0;
  height: 620px;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  overflow: hidden;
}
.inbox-list {
  width: 280px;
  border-right: 1px solid #1a1a1a;
  overflow-y: auto;
  flex-shrink: 0;
  background: #0d0d0d;
}
.inbox-empty {
  padding: 24px;
  color: #555;
  font-size: 0.85rem;
  text-align: center;
}
.inbox-customer {
  padding: 14px 16px;
  border-bottom: 1px solid #1a1a1a;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.inbox-customer:hover { background: #141414; }
.inbox-customer.active { background: #1a0810; border-left: 3px solid #FF2D55; }
.inbox-customer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.inbox-customer-name { font-size: 0.85rem; color: #fff; font-weight: 600; }
.inbox-customer-time { font-size: 0.68rem; color: #555; }
.inbox-customer-preview {
  font-size: 0.75rem;
  color: #777;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-unread-dot {
  width: 8px;
  height: 8px;
  background: #FF2D55;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 6px;
}

.inbox-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
}
.inbox-thread-header {
  padding: 14px 18px;
  border-bottom: 1px solid #1a1a1a;
  background: #0d0d0d;
}
.inbox-thread-header h3 { margin: 0; font-size: 0.9rem; color: #fff; }
.inbox-thread-header p { margin: 2px 0 0; font-size: 0.75rem; color: #666; }
.inbox-thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  font-size: 0.9rem;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bubble.out {
  background: #FF2D55;
  color: #fff;
  border-radius: 16px 16px 3px 16px;
  align-self: flex-end;
}
.chat-bubble.in {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #ddd;
  border-radius: 16px 16px 16px 3px;
  align-self: flex-start;
}
.chat-bubble-time {
  font-size: 0.65rem;
  opacity: 0.55;
  margin-top: 4px;
  display: block;
}
.chat-reply-box {
  padding: 12px;
  border-top: 1px solid #1a1a1a;
  display: flex;
  gap: 8px;
  background: #0d0d0d;
}
.chat-reply-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  resize: none;
  height: 56px;
  font-family: inherit;
}
.chat-reply-input:focus { outline: none; border-color: #FF2D55; }

/* Analytics charts */
.sms-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}
.sms-chart-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 20px;
}
.sms-chart-card.full-width { grid-column: 1 / -1; }
.sms-chart-title {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
@media (max-width: 700px) {
  .sms-charts-grid { grid-template-columns: 1fr; }
  .sms-chart-card.full-width { grid-column: 1; }
}

/* Recent activity */
.sms-activity-feed {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  overflow: hidden;
}
.sms-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #111;
}
.sms-activity-item:last-child { border-bottom: none; }
.sms-activity-dir {
  width: 52px;
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
  margin-top: 2px;
}
.sms-activity-dir.in { background: #0a2a18; color: #30D158; }
.sms-activity-dir.out { background: #1a0810; color: #FF2D55; }
.sms-activity-body { flex: 1; }
.sms-activity-name { font-size: 0.8rem; color: #aaa; }
.sms-activity-text { font-size: 0.85rem; color: #ddd; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(400px, 55vw); }
.sms-activity-time { font-size: 0.7rem; color: #555; margin-top: 2px; }

/* Schedule row */
.sms-schedule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sms-schedule-row label { font-size: 0.85rem; color: #aaa; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.sms-schedule-row input[type="checkbox"] { accent-color: #FF2D55; width: 16px; height: 16px; }

/* Consent toggle */
.consent-toggle {
  background: none;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.consent-toggle.active { color: #30D158; border-color: #30D158; }
.consent-toggle.inactive { color: #FF3B30; border-color: #FF3B30; }

@media (max-width: 600px) {
  .sms-inbox-layout { flex-direction: column; height: auto; }
  .inbox-list { width: 100%; border-right: none; border-bottom: 1px solid #1a1a1a; max-height: 220px; }
  .inbox-thread { min-height: 400px; }
}

/* Remove excess top padding on SMS tab inherited from tab-content */
#tab-sms { padding-top: 4px !important; }

/* Full-width mobile fix */
#tab-sms {
  padding: 0 !important;
  overflow-x: hidden;
}
#smsContent {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
}
@media (min-width: 600px) {
  #smsContent {
    padding: 20px;
  }
}

/* Knowledge Base */
.knowledge-grid { display: flex; flex-direction: column; gap: 12px; }
.knowledge-card { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 12px; padding: 16px; }
.knowledge-card.knowledge-inactive { opacity: 0.5; border-style: dashed; }
.knowledge-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.knowledge-section-name { font-size: 0.95rem; font-weight: 600; color: #FF2D55; }
.knowledge-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.knowledge-content { font-size: 0.82rem; color: #999; white-space: pre-wrap; line-height: 1.5; max-height: 120px; overflow: hidden; position: relative; }
.knowledge-content::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 30px; background: linear-gradient(transparent, #1a1a1a); }

/* Tag picker chips */
.sms-tag-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ccc;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
  white-space: nowrap;
}
.sms-tag-chip:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sms-tag-chip.selected {
  background: #e53e3e;
  border-color: #e53e3e;
  color: #fff;
}
