/* ═══════════════════════════════════════════════════════════════
   ClickUp + GSheets Summary Dashboard — style.css
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg-base:        #0A0B0F;
  --bg-surface:     #111318;
  --bg-card:        #16181F;
  --bg-card-hover:  #1C1F28;
  --bg-glass:       rgba(255, 255, 255, 0.04);
  --bg-input:       rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(255, 255, 255, 0.10);

  --border:         rgba(255, 255, 255, 0.08);
  --border-focus:   rgba(108, 142, 239, 0.6);

  --text-primary:   #F0F2F8;
  --text-secondary: #8B90A7;
  --text-dim:       #4A4F63;
  --text-link:      #6C8EEF;

  --accent:         #6C8EEF;
  --accent-glow:    rgba(108, 142, 239, 0.18);
  --success:        #4ECDC4;
  --danger:         #FF6B9D;
  --warning:        #FFB347;

  --sidebar-w:      280px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  --shadow-card:    0 8px 32px rgba(0, 0, 0, 0.5);
  --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET & BASE ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg-base); color: var(--text-primary); font-size: 14px; overflow: hidden; }

/* ── APP SHELL ──────────────────────────────────────────────── */
#app { height: 100vh; flex-direction: row; }

/* ── SIDEBAR & TABS ─────────────────────────────────────────── */
#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; overflow: hidden; }
.sidebar-header { padding: 20px 20px 10px; border-bottom: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 700; color: var(--text-primary); }

.tab-switcher {
  display: flex;
  background: var(--bg-body);
  border-radius: 12px;
  padding: 4px;
  margin-top: 20px;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#service-selector-wrap select {
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
#service-selector-wrap select:hover {
  border-color: var(--primary);
}

.sidebar-search { display: flex; align-items: center; gap: 8px; background: var(--bg-glass); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.sidebar-search input { background: none; border: none; outline: none; color: var(--text-primary); font-size: 13px; width: 100%; }
.sidebar-section-label { padding: 14px 20px 6px; font-size: 10px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-clients { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--border); font-size: 11px; display: flex; align-items: center; justify-content: space-between; color: var(--text-secondary); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-right: 6px; display: inline-block; animation: pulse 2s infinite; }

.client-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; cursor: pointer; transition: background var(--transition); position: relative; border-bottom: 1px solid rgba(255,255,255,0.02); }
.client-item:hover { background: var(--bg-glass); }
.client-item.active { background: var(--accent-glow); }
.client-item.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 0 2px 2px 0; }

.client-avatar { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: white; flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.client-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.client-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.client-sources { display: flex; gap: 6px; font-size: 10px; opacity: 0.8; }

/* ── MAIN CONTENT ───────────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; background: var(--bg-base); overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.topbar-client { display: flex; align-items: center; gap: 12px; }
.topbar-client-avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: white; }
.topbar-client-name { font-weight: 700; font-size: 16px; letter-spacing: -0.2px; }
.topbar-client-sub { font-size: 11px; color: var(--text-secondary); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }

/* Connection Status [RESTORED] */
.save-indicator { font-size: 11px; font-weight: 700; color: var(--success); background: rgba(78, 205, 196, 0.1); padding: 6px 12px; border-radius: 20px; border: 1px solid rgba(78, 205, 196, 0.2); white-space: nowrap; }

/* Google OAuth Button */
.btn-google { padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: white; color: #333; cursor: pointer; font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 8px; transition: all var(--transition); white-space: nowrap; }
.btn-google.connected { background: var(--success); border-color: var(--success); color: white; }
.btn-google:hover { opacity: 0.9; transform: translateY(-1px); }

/* Refresh Button [RESTORED] */
.refresh-btn { background: var(--bg-glass); border: 1px solid var(--border); color: var(--text-secondary); padding: 8px 14px; border-radius: var(--radius-sm); font-family: inherit; font-size: 11px; font-weight: 700; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; gap: 6px; }
.refresh-btn:hover { background: var(--bg-input); border-color: var(--accent); color: var(--accent); }

/* Trigger Button */
.btn-add {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}
.btn-add:hover { background: var(--accent); transform: scale(1.1); }

.btn-del {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.3;
  margin-left: 8px;
  font-size: 14px;
  transition: opacity 0.2s;
}
.btn-del:hover { opacity: 1; color: #EF4444; }

.btn-trigger {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.2s;
}
.btn-trigger:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(108,142,239,0.3); }

.new-line {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 8px !important;
  margin-top: 8px;
  border: 1px dashed rgba(255,255,255,0.2);
}
.new-line .field-label { display: none; }

.field-status-actions { display: flex; gap: 5px; }
.btn-save-sm, .btn-cancel-sm {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
  transition: 0.2s;
}
.btn-save-sm { color: #10B981; }
.btn-save-sm:hover { background: rgba(16,185,129,0.1); }
.btn-cancel-sm { color: #EF4444; }
.btn-cancel-sm:hover { background: rgba(239,68,68,0.1); }

/* ── CARDS GRID ─────────────────────────────────────────────── */
#cards-area { flex: 1; overflow-y: auto; padding: 24px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 2fr)); gap: 20px; align-items: start; animation: fadeIn 0.4s ease; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); transition: transform var(--transition); }
.card-header { padding: 14px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); background: var(--bg-glass); }
.card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-primary); flex: 1; }
.card-body { padding: 12px 18px; }

/* ── MODIFIED FIELD ROW (FOR GSHEETS) ───────────────────────── */
.field-row { padding: 8px 0; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.field-label { font-size: 10px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.field-input-wrap { position: relative; display: flex; align-items: center; }
.field-input { width: 100%; padding: 7px 10px; background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; font-family: inherit; outline: none; transition: 0.2s; }
.field-input:focus { border-color: var(--primary); outline: none; }
.field-input:disabled { background: var(--bg-body); cursor: not-allowed; opacity: 0.7; }

/* Textarea specific styles */
.field-textarea {
  resize: none;
  min-height: 40px;
  max-height: 400px;
  overflow-y: hidden;
  line-height: 1.5;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Specific for KPI items */
.kpi-item { background: var(--bg-glass); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; margin-bottom: 10px; }
.control-grid {
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)) !important;
  align-items: start;
}
.card-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.toggle-row {
  display: grid !important;
  grid-template-columns: minmax(140px, 140px) 1fr 60px 40px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 4px 0;
}
.plat-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

/* Custom Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.1);
  transition: .4s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(16px); }

.kpi-header { display: flex; justify-content: space-between; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.kpi-title { font-weight: 700; color: var(--accent); }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Toggle Styles */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-input); transition: .4s; border-radius: 34px; border: 1px solid var(--border); }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 4px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(22px); }

/* Status Labels */
.field-status { position: absolute; right: 10px; font-size: 10px; font-weight: 700; opacity: 0; transition: opacity 0.3s; color: var(--success); }
.field-status:not(:empty) { opacity: 1; }

.state-panel { padding-top: 100px; text-align: center; display: flex; flex-direction: column; gap: 20px; align-items: center; color: var(--text-secondary); }
.state-icon { font-size: 60px; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── MULTI-SELECT COMPONENT ─────────────────────────────────── */
.multi-select-container { position: relative; width: 100%; }
.multi-select-display {
  width: 100%; 
  padding: 7px 10px; 
  background: var(--bg-input); 
  border: 1px solid transparent; 
  border-radius: var(--radius-sm); 
  color: var(--text-primary); 
  font-size: 13px; 
  font-family: inherit; 
  cursor: pointer;
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  min-height: 33px; 
  display: flex; 
  align-items: center; 
  user-select: none;
  transition: 0.2s;
}
.multi-select-display:hover { background: var(--bg-input-focus); }
.multi-select-dropdown {
  position: absolute; 
  top: 100%; 
  left: 0; 
  right: 0; 
  background: var(--bg-card); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  z-index: 100; 
  max-height: 250px; 
  overflow-y: auto; 
  display: none; 
  box-shadow: var(--shadow-card); 
  padding: 8px; 
  margin-top: 4px; 
}
.multi-select-option { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  padding: 8px 10px; 
  cursor: pointer; 
  font-size: 13px; 
  color: var(--text-primary); 
  border-radius: 4px; 
  margin-bottom: 2px;
}
.multi-select-option:hover { background: var(--bg-glass); }
.multi-select-checkbox { 
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
