/* ===================================================
   QV MARKETING TOOL — GOOGLE MATERIAL DESIGN SYSTEM
   =================================================== */

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

:root {
  /* Colors - Material Light Theme */
  --bg-base:       #f8f9fa; /* Classic Google Drive background */
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-elevated:   #f1f3f4;
  --bg-hover:      #f8f9fa;
  --border:        #dadce0;
  --border-focus:  #1a73e8;

  --purple:        #1a73e8; /* Aliased to blue for compatibility */
  --purple-glow:   rgba(26,115,232,0.15);
  --blue:          #1a73e8;
  --blue-glow:     rgba(26,115,232,0.15);
  --teal:          #0f9d58; /* Google green */
  --teal-glow:     rgba(15,157,88,0.15);
  --orange:        #f4b400; /* Google yellow */
  --orange-glow:   rgba(244,180,0,0.15);
  --red:           #d93025;
  --green:         #188038;

  --text-primary:  #202124;
  --text-secondary:#5f6368;
  --text-muted:    #80868b;

  /* Sizes */
  --sidebar-w: 256px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --tr: 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

html, body {
  height: 100%;
  font-family: 'Roboto', 'Google Sans', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 99px; border: 2px solid var(--bg-base); }
::-webkit-scrollbar-thumb:hover { background: #bdc1c6; }

/* ==================== LAYOUT ==================== */
body { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 10;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ==================== SIDEBAR ==================== */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid transparent; /* No border for cleaner look */
}

.logo-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.logo-icon svg { width: 20px; height: 20px; }

.logo-text {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.2px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0 12px 0; /* padding right removed for pill shape */
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 24px;
  margin-right: 12px; /* For pill effect */
  border-radius: 0 24px 24px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--tr), color var(--tr);
  position: relative;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav-item.active {
  background: #e8f0fe;
  color: #1967d2;
  font-weight: 600;
}
.nav-item.active .nav-icon { color: #1967d2; }

.nav-icon {
  width: 20px; height: 20px; flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--bg-elevated);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
.nav-item.active .nav-badge { background: #d2e3fc; color: #1967d2; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.api-status.online .status-dot { background: var(--green); }
.api-status.offline .status-dot { background: var(--red); }
.api-status.online .status-text { color: var(--green); }
.api-status.offline .status-text { color: var(--red); }

/* ==================== TOPBAR ==================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.page-title {
  font-size: 22px;
  font-weight: 400; /* Google typically uses lighter weights for larger headers */
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.api-base-input {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.api-base-input input {
  background: #f1f3f4;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
  width: 220px;
  font-family: 'Roboto', monospace;
  outline: none;
  transition: all var(--tr);
}
.api-base-input input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  border-radius: 20px; /* Pill shape for Google UI */
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--tr), box-shadow var(--tr), border-color var(--tr);
  white-space: nowrap;
  font-family: 'Roboto', sans-serif;
  letter-spacing: 0.25px;
}

.btn-primary {
  background: #1a73e8;
  color: #fff;
}
.btn-primary:hover { 
  background: #1b66c9; 
  box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15); 
}
.btn-primary:active { box-shadow: none; background: #185abc; }

.btn-ghost, .btn-secondary {
  background: #ffffff;
  color: #1a73e8;
  border: 1px solid #dadce0 !important;
}
.btn-ghost:hover, .btn-secondary:hover { 
  background: #f8f9fa; 
  color: #174ea6; 
}
.btn-ghost:active, .btn-secondary:active { background: #e8eaed; }

.btn-sm { padding: 6px 16px; font-size: 13px; border-radius: 16px; }
.btn-danger { background: #fff; color: var(--red); border-color: #dadce0; }
.btn-danger:hover { background: #fce8e6; color: #c5221f; border-color: transparent; }

/* ==================== PAGE CONTENT ==================== */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.page { display: block; }
.page.hidden { display: none; }

/* ==================== DASHBOARD ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: box-shadow var(--tr);
}
.stat-card:hover { box-shadow: 0 1px 2px rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15); }

.stat-card-icon {
  width: 48px; height: 48px;
  border-radius: 50%; /* Circle icons for Google style */
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon svg { width: 24px; height: 24px; }
.stat-card-icon.purple { background: #e8f0fe; color: #1a73e8; }
.stat-card-icon.blue   { background: #e8f0fe; color: #1a73e8; }
.stat-card-icon.teal   { background: #e6f4ea; color: #137333; }
.stat-card-icon.orange { background: #fef7e0; color: #b06000; }

.stat-value { font-size: 32px; font-weight: 400; color: var(--text-primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

.dash-lower {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 16px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
}

.dash-card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.dash-card-header h2 { font-size: 16px; font-weight: 500; color: var(--text-primary); }

.dash-list { padding: 0 24px 24px; }
.dash-campaign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.dash-campaign-row:last-child { border-bottom: none; }
.dash-campaign-name { font-weight: 500; font-size: 14px; color: var(--text-primary); }
.dash-campaign-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.status-breakdown { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.status-row { display: flex; align-items: center; gap: 12px; }
.status-row-label { font-size: 13px; color: var(--text-secondary); width: 80px; font-weight: 500; }
.progress-bar-wrap { flex: 1; height: 8px; background: #f1f3f4; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.progress-bar.draft     { background: #bdc1c6; }
.progress-bar.active    { background: #137333; }
.progress-bar.paused    { background: #f4b400; }
.progress-bar.completed { background: #1a73e8; }
.status-row-count { font-size: 13px; font-weight: 500; color: var(--text-secondary); width: 30px; text-align: right; }

/* ==================== PAGE TOOLBAR ==================== */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 250px;
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-secondary);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 16px 10px 42px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  outline: none;
  transition: box-shadow var(--tr);
}
.search-wrap input:focus { border-color: transparent; box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 0 0 2px var(--blue); }
.search-wrap input::placeholder { color: var(--text-muted); }

.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--tr);
  font-family: 'Roboto', sans-serif;
}
.pill:hover { background: #f8f9fa; }
.pill.active { background: #e8f0fe; border-color: #e8f0fe; color: #1967d2; }

/* ==================== TABLE ==================== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: #fff;
  padding: 12px 24px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--tr); }
.data-table tbody tr:hover { background: var(--bg-hover); }

.td-primary { color: var(--text-primary); font-weight: 500; }
.td-mono { font-family: 'Roboto Mono', 'Courier New', monospace; font-size: 13px; color: var(--text-secondary); }

.loading-row { text-align: center; padding: 48px !important; color: var(--text-muted); }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 64px 24px; color: var(--text-secondary); font-size: 14px; }
.empty-state-icon { font-size: 40px; display: block; margin-bottom: 16px; opacity: 0.6; }

/* ==================== STATUS BADGE ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-draft     { background: #f1f3f4; color: #5f6368; }
.badge-active    { background: #e6f4ea; color: #137333; }
.badge-paused    { background: #fef7e0; color: #b06000; }
.badge-completed { background: #e8f0fe; color: #1967d2; }
.badge-one-time  { background: #e8eaed; color: #202124; }
.badge-recurring { background: #ceead6; color: #137333; }

/* ==================== CARDS GRID ==================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: box-shadow var(--tr);
  cursor: pointer;
}
.item-card:hover {
  box-shadow: 0 1px 2px rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
}

.item-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-card-title { font-size: 16px; font-weight: 500; color: var(--text-primary); }
.item-card-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; min-height: 20px; }
.item-card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.item-card-body { font-size: 14px; color: var(--text-secondary); }
.item-card-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 16px; }
.item-card-date { font-size: 12px; color: var(--text-muted); margin-left: auto; }

.condition-chip {
  display: inline-flex;
  align-items: center;
  background: #f1f3f4;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'Roboto Mono', monospace;
}

/* ==================== PAGINATION ==================== */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 20px;
}
.pagination .page-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  transition: all var(--tr);
}
.pagination .page-btn:hover { background: var(--bg-hover); }
.pagination .page-btn.active { background: #e8f0fe; border-color: #1a73e8; color: #1967d2; font-weight: 500; }
.pagination .page-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.page-info { font-size: 14px; color: var(--text-secondary); margin-right: 8px; }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(32,33,36,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadein 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-up { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal {
  background: #fff;
  border-radius: 8px;
  width: 560px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scale-up 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 24px 38px 3px rgba(0,0,0,0.14), 0 9px 46px 8px rgba(0,0,0,0.12), 0 11px 15px -7px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 20px; font-weight: 500; color: var(--text-primary); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 50%;
  transition: all var(--tr);
}
.modal-close:hover { background: rgba(60,64,67,0.08); color: var(--text-primary); }

.modal-body {
  padding: 8px 24px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 0 0 8px 8px;
}

/* ==================== FORM ==================== */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.form-control {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
  width: 100%;
}
.form-control:hover { border-color: #80868b; }
.form-control:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.5; }
select.form-control { cursor: pointer; padding-right: 32px; }
.form-hint { font-size: 12.5px; color: var(--text-secondary); margin-top: -4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.code-editor {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 140px;
  background: #f8f9fa;
  color: #c5221f; /* slightly different code color */
  border: 1px solid var(--border);
  padding: 12px;
}

/* ==================== DRAWER ==================== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(32,33,36,0.6);
  display: flex;
  justify-content: flex-end;
  z-index: 900;
  animation: fadein 0.2s ease;
}
.drawer-overlay.hidden { display: none !important; }

.drawer {
  width: 480px;
  max-width: 90vw;
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: slide-in-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
}
@keyframes slide-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-header h2 { font-size: 20px; font-weight: 500; color: var(--text-primary); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 24px; }

.detail-section { display: flex; flex-direction: column; gap: 12px; }
.detail-section h3 { font-size: 14px; font-weight: 500; color: var(--text-primary); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.detail-row { display: flex; gap: 16px; }
.detail-label { font-size: 13px; color: var(--text-secondary); width: 120px; flex-shrink: 0; }
.detail-value { flex: 1; font-size: 14px; color: var(--text-primary); word-break: break-all; }
.detail-actions { display: flex; gap: 12px; padding-top: 16px; }

.preview-html {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  min-height: 200px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: auto;
}

/* ==================== TOAST ==================== */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px; /* Google toasts usually bottom-left */
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #323232; /* Classic dark toast / Snackbar for light theme */
  border-radius: 4px;
  padding: 14px 24px;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 3px 5px -1px rgba(0,0,0,0.2), 0 6px 10px 0 rgba(0,0,0,0.14), 0 1px 18px 0 rgba(0,0,0,0.12);
  animation: slide-up-toast 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 288px;
  max-width: 568px;
}
@keyframes slide-up-toast { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.toast-icon { display: none; /* Google dark snackbars rarely use bold colored icons, text is enough */ }
.toast-success { border-left: 4px solid var(--green); }
.toast-error   { border-left: 4px solid var(--red); }
.toast-info    { border-left: 4px solid var(--blue); }
.toast-fade-out { animation: fadeout-toast 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes fadeout-toast { to { opacity: 0; } }

/* ==================== ACTION BTNS ==================== */
.action-btn {
  background: transparent;
  border: none;
  border-radius: 50%; /* Circle icon buttons */
  cursor: pointer;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--tr), color var(--tr);
}
.action-btn:hover { background: rgba(60,64,67,0.08); color: var(--text-primary); }
.action-btn.danger:hover { background: #fce8e6; color: #c5221f; }
.action-btn svg { width: 18px; height: 18px; }
.actions-cell { display: flex; gap: 4px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .dash-lower { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  :root { --sidebar-w: 64px; }
  .logo-text, .nav-item span:not(.nav-badge), .nav-badge, .sidebar-footer .status-text { display: none; }
  .nav-item { justify-content: center; padding: 12px; margin-right: 0; border-radius: 0; }
  .sidebar-logo { justify-content: center; padding: 16px 12px; }
  .api-base-input label { display: none; }
  .api-base-input input { width: 140px; }
}
