/* ==========================================
   KTZ-Utility-Sender - Bright Corporate Theme
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Bright Color Palette - Corporate Light Theme */
  --bg-deep: #f8fafc;        /* Slate 50 */
  --bg-darker: #0f172a;      /* Slate 900 (Sidebar) */
  --bg-card: #ffffff;        /* Pure White Card */
  --bg-active: #f1f5f9;      /* Slate 100 active selections */
  --border-light: #e2e8f0;   /* Slate 200 border */
  --border-focus: #0284c7;   /* Sky Blue border focus */
  
  /* Primary & Accent Colors (Kwality Logo Themed) */
  --color-primary: #0284c7;  /* Corporate Sky Blue */
  --color-primary-hover: #0369a1;
  --color-secondary: #0f172a; /* Navy Slate */
  --color-accent: #e11d48;    /* Soft Red */
  
  /* Text Colors */
  --text-main: #0f172a;      /* Dark Navy text */
  --text-muted: #475569;     /* Muted Slate text */
  --text-dark: #94a3b8;      /* Greyed out text */
  --text-white: #ffffff;
  
  /* Functional Status Colors */
  --status-sent: #0284c7;      /* Blue */
  --status-delivered: #d97706; /* Amber */
  --status-read: #16a34a;      /* Emerald Green */
  --status-failed: #dc2626;    /* Red */
  
  /* Border & Shadows */
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 4px;
  --shadow-main: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  
  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Transition */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.25s ease-in-out;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ==========================================
   Login Page Overlays & Auth Layout
   ========================================== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f1f5f9; /* Soft bright slate */
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity var(--transition-normal);
}

.auth-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  text-align: center;
}

.auth-card-logo {
  height: 60px;
  object-fit: contain;
  margin-bottom: 20px;
}

.auth-logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 30px;
}

.auth-form-group {
  margin-bottom: 20px;
  text-align: left;
}

.auth-form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.auth-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  transition: all var(--transition-fast);
}

.auth-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.auth-btn {
  width: 100%;
  background: var(--color-primary);
  color: var(--text-white);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 10px;
}

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

.auth-card-footer {
  margin-top: 24px;
  font-size: 13px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}

.auth-error {
  color: var(--color-accent);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
  font-weight: 600;
}

/* ==========================================
   Main Dashboard Layout
   ========================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling (High-Contrast Navy Dark) */
.sidebar {
  width: 280px;
  background: var(--bg-darker);
  border-right: 1px solid rgba(255,255,255,0.05);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  color: #94a3b8;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 32px;
}

.sidebar-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 2px;
}

.logo-text {
  font-weight: 800;
  font-size: 16px;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.logo-text span {
  display: block;
  font-size: 9px;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 800;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item button {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #94a3b8;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--transition-fast);
}

.nav-item button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.nav-item.active button {
  background: var(--color-primary);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-badge {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-subtitle {
  font-size: 10px;
  color: #64748b;
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e; /* green dot */
}

.logout-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.logout-btn:hover {
  color: #ffffff;
}

/* Main Content Area */
.main-viewport {
  margin-left: 280px;
  flex-grow: 1;
  padding: 40px;
  min-height: 100vh;
}

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

.viewport-title h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.viewport-title p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* Credentials Status indicator */
.credentials-status {
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-indicator.connected {
  background: var(--status-read);
}

.status-indicator.disconnected {
  background: var(--status-failed);
}

/* ==========================================
   Tab Viewports Styling
   ========================================== */
.tab-content {
  display: none;
  animation: fadeIn var(--transition-normal);
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   Corporate Card Layout (Flat White Panel)
   ========================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.dashboard-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-main);
}

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

.stat-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
}

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
}

.badge-primary { background: rgba(2, 132, 199, 0.1); color: var(--color-primary); }
.badge-success { background: rgba(22, 163, 74, 0.1); color: var(--status-read); }
.badge-info { background: rgba(79, 70, 229, 0.1); color: #4f46e5; }

.stat-value-box {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-main);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* Content cards */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-main);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
}

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

.form-group.horizontal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-control::placeholder {
  color: var(--text-dark);
}

.form-control:disabled {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

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

.help-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

.btn-secondary {
  background: #ffffff;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: #f8fafc;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.btn-accent {
  background: #0f172a;
  color: var(--text-white);
}

.btn-accent:hover {
  background: #1e293b;
}

.btn:active {
  transform: translateY(1px);
}

/* ==========================================
   Dual Columns Dashboard layouts
   ========================================== */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

/* Console Logs Inspector (Dark block is retained for read/syntax contrast) */
.console-card {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-main);
}

.console-header {
  background: #111827;
  padding: 12px 20px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.console-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
}

.console-dots {
  display: flex;
  gap: 6px;
}

.console-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.console-dot.red { background: #f87171; }
.console-dot.yellow { background: #fbbf24; }
.console-dot.green { background: #34d399; }

.console-body {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #34d399; /* Console green text */
  background-color: #090d16;
  overflow-x: auto;
  max-height: 480px;
  line-height: 1.6;
}

.console-body pre {
  margin: 0;
  white-space: pre-wrap;
}

.console-meta { color: #60a5fa; }
.console-payload { color: #f3f4f6; }
.console-success { color: #34d399; }
.console-error { color: #f87171; }

/* ==========================================
   Table Lists
   ========================================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: #ffffff;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.logs-table th {
  background: #f8fafc;
  padding: 14px 20px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}

.logs-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.logs-table tbody tr {
  transition: background var(--transition-fast);
}

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

/* Badges for status */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-badge.sent {
  background: rgba(2, 132, 199, 0.1);
  color: var(--status-sent);
  border: 1px solid rgba(2, 132, 199, 0.2);
}

.status-badge.delivered {
  background: rgba(217, 119, 6, 0.1);
  color: var(--status-delivered);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.status-badge.read {
  background: rgba(22, 163, 74, 0.1);
  color: var(--status-read);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.status-badge.failed {
  background: rgba(220, 38, 38, 0.1);
  color: var(--status-failed);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.status-badge.pending {
  background: rgba(217, 119, 6, 0.1);
  color: var(--status-delivered);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-mock {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-live {
  background: rgba(2, 132, 199, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(2, 132, 199, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ==========================================
   Templates Card Grid Styling
   ========================================== */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.template-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 200px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.template-card:hover {
  border-color: #cbd5e1;
}

.template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}

.template-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  word-break: break-all;
}

.template-category {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  background: rgba(2, 132, 199, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.template-body {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.template-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
}

.template-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.delete-tpl-btn {
  background: transparent;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  transition: color var(--transition-fast);
  padding: 2px;
  display: flex;
  align-items: center;
}

.delete-tpl-btn:hover {
  color: var(--color-accent);
}

/* API Docs block styling */
.code-block {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #f8fafc;
  overflow-x: auto;
  margin-bottom: 20px;
  position: relative;
}

.code-block button.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #94a3b8;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-block button.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Embedded Signup Card specific styling */
.coex-hero {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 30px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.05) 0%, rgba(22, 163, 74, 0.05) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.coex-hero h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
}

.coex-hero p {
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 24px auto;
  font-size: 14px;
}

/* Alerts */
.alert {
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-info {
  background: rgba(2, 132, 199, 0.08);
  color: #0369a1;
  border: 1px solid rgba(2, 132, 199, 0.15);
}

.alert-success {
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.15);
}

.alert-warning {
  background: rgba(217, 119, 6, 0.08);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.15);
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dark);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* Loader */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.05);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s infinite linear;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
