/* ==========================================================================
   TSL Active Intelligence — Task Pane Styles
   Target: IE11 Trident WebView (Excel 2016)
   ========================================================================== */

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

html, body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  color: #24292f;
  background: #ffffff;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* position:absolute with top:0;bottom:0 guarantees a computed height
   even when the IE11 WebView iframe doesn't propagate height:100%. */
#app {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
  flex-direction: column;
}

/* ── App Header ── */
.app-header {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: justify;
  justify-content: space-between;
  padding: 10px 14px;
  background: #217346;
  color: white;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
}
.app-logo {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
}
.app-logo-icon {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.2);
  border-radius: 6px;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-size: 12px; font-weight: 700;
  margin-right: 8px;
}
.app-logo-text { font-size: 15px; font-weight: 600; }
.header-right {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
}
.settings-btn {
  background: none; border: none; color: white; cursor: pointer;
  padding: 4px; border-radius: 4px;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  opacity: 0.8;
}
.settings-btn:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* User badge */
.user-badge {
  font-size: 11px;
  background: rgba(255,255,255,0.2);
  padding: 3px 8px;
  border-radius: 12px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

/* ── Welcome ── */
.welcome {
  text-align: center;
  padding: 20px 14px 10px;
}
.welcome h2 { font-size: 16px; margin-bottom: 4px; color: #24292f; }
.welcome p  { font-size: 12px; color: #57606a; margin-bottom: 12px; }

/* Quick Actions — NO gap (IE11), use margin instead */
.quick-actions {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  padding: 4px 14px 8px;
  -ms-flex-pack: center;
  justify-content: center;
}
.action-chip {
  padding: 5px 10px;
  border: 1px solid #e1e4e8;
  border-radius: 16px;
  background: #ffffff;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  color: #24292f;
  margin: 3px;
}
.action-chip:hover {
  background: #217346;
  color: white;
  border-color: #217346;
}

/* ── Chat Container (scrollable middle) ── */
.chat-container {
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.message {
  margin-bottom: 14px;
  padding: 0 14px;
}

.message-content {
  padding: 10px 13px;
  border-radius: 8px;
  line-height: 1.5;
  max-width: 95%;
}
.message.assistant .message-content {
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
}
.message.user .message-content {
  background: #217346;
  color: white;
  margin-left: auto;
}
.message-content p { margin-bottom: 6px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul { margin: 4px 0; padding-left: 18px; }
.message-content li { margin-bottom: 3px; }
.message-content code {
  background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px;
  font-family: Consolas, monospace; font-size: 12px;
}

/* Action Results */
.actions-applied {
  margin-top: 8px;
  padding: 8px 10px;
  background: #eafbe7;
  border: 1px solid #a7f3a0;
  border-radius: 6px;
  font-size: 12px;
  color: #1a7f37;
}
.actions-applied .count { font-weight: 600; }

.actions-error {
  margin-top: 8px;
  padding: 8px 10px;
  background: #ffebe9;
  border: 1px solid #ffcecb;
  border-radius: 6px;
  font-size: 12px;
  color: #cf222e;
}

/* Follow-up suggestion */
.follow-up {
  margin-top: 8px;
  padding: 6px 10px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  font-size: 12px;
  color: #6d4c00;
  cursor: pointer;
}
.follow-up:hover { background: #fff3cd; }

/* Loading indicator */
.loading-dots {
  display: -ms-inline-flexbox;
  display: inline-flex;
  padding: 8px 0;
}
.loading-dots span {
  width: 6px; height: 6px;
  background: #8b949e;
  border-radius: 50%;
  margin-right: 4px;
  -webkit-animation: pulse 1.2s infinite;
  animation: pulse 1.2s infinite;
}
.loading-dots span:nth-child(2) { -webkit-animation-delay: 0.2s; animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { -webkit-animation-delay: 0.4s; animation-delay: 0.4s; margin-right: 0; }
@-webkit-keyframes pulse {
  0%, 80%, 100% { -webkit-transform: scale(0.6); opacity: 0.4; }
  40% { -webkit-transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area (pinned to bottom) ── */
.input-area {
  border-top: 1px solid #e1e4e8;
  padding: 8px 14px 10px;
  background: #ffffff;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
}

/* Input options bar */
.input-options {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: justify;
  justify-content: space-between;
  margin-bottom: 6px;
}
.context-toggle {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  font-size: 11px; color: #57606a; cursor: pointer;
}
.context-toggle input[type="checkbox"] {
  margin-right: 6px;
}
.btn-manage-sub {
  background: none; border: none; color: #0969da;
  font-size: 11px; cursor: pointer; padding: 2px 4px;
}
.btn-manage-sub:hover { text-decoration: underline; }

/* Input wrapper */
.input-wrapper {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: end;
  align-items: flex-end;
  width: 100%;
}
.input-field {
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
  max-height: 100px;
  margin-right: 6px;
}
.input-field:focus { border-color: #217346; }
.input-hint {
  font-size: 10px; color: #8b949e;
  margin-top: 4px; text-align: center;
}

/* Send button */
.send-btn {
  width: 36px; height: 36px;
  min-width: 36px; max-width: 36px;
  min-height: 36px; max-height: 36px;
  background: #217346;
  color: white; border: none;
  border-radius: 8px;
  cursor: pointer;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-size: 16px;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
}
.send-btn:hover { background: #2d9b5e; }
.send-btn:disabled { background: #8b949e; cursor: not-allowed; }
.send-btn svg { width: 16px !important; height: 16px !important; max-width: 16px; max-height: 16px; }

/* ── Template Panel ── */
.panel {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: #ffffff;
  z-index: 10;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
  flex-direction: column;
}
.panel.hidden { display: none !important; }
.panel-header {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: justify;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #e1e4e8;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
}
.panel-header h3 { font-size: 15px; font-weight: 600; }
.panel-close {
  background: none; border: none; color: #24292f; font-size: 18px; cursor: pointer;
}
.template-list {
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow-y: scroll;
  -ms-overflow-style: scrollbar;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px;
  min-height: 0;
}

.template-card {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: start;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}
.template-card:hover {
  border-color: #217346;
  background: #f0faf4;
}
.template-icon { font-size: 22px; -ms-flex: 0 0 auto; flex: 0 0 auto; margin-top: 2px; margin-right: 10px; }
.template-info h3 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.template-info p { font-size: 11.5px; color: #57606a; line-height: 1.4; }

/* ── Paywall ── */
.paywall-section {
  -ms-flex: 1;
  flex: 1;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.paywall-card {
  text-align: center;
  max-width: 320px;
  width: 100%;
}
.paywall-icon {
  width: 56px; height: 56px;
  background: #217346;
  color: white;
  border-radius: 14px;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-size: 20px; font-weight: 700;
  margin-bottom: 16px;
}
.paywall-card h2 {
  font-size: 20px; font-weight: 700;
  margin-bottom: 4px; color: #24292f;
}
.paywall-tagline {
  font-size: 13px; color: #57606a;
  margin-bottom: 20px;
}
.paywall-price { margin-bottom: 20px; }
.price-amount { font-size: 36px; font-weight: 700; color: #217346; }
.price-period { font-size: 14px; color: #57606a; }
.paywall-features {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}
.paywall-features li {
  padding: 6px 0 6px 22px;
  font-size: 12.5px;
  color: #24292f;
  border-bottom: 1px solid #e1e4e8;
  position: relative;
}
.paywall-features li:before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: #1a7f37;
  font-weight: 700;
}
.btn-subscribe {
  width: 100%;
  padding: 12px 20px;
  background: #217346;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-subscribe:hover { background: #2d9b5e; }
.paywall-note {
  font-size: 11px; color: #8b949e;
  margin-top: 10px;
}

/* ── Settings Panel ── */
.settings-panel {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: #ffffff;
  z-index: 20;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
  flex-direction: column;
}
.settings-panel.hidden { display: none; }
.settings-header {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: justify;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #e1e4e8;
}
.settings-header h3 { font-size: 15px; font-weight: 600; }
.settings-header .settings-btn { color: #24292f; }
.settings-body { padding: 14px; }
.setting-group { margin-bottom: 14px; }
.setting-group label { font-size: 12px; font-weight: 600; display: block; margin-bottom: 4px; }
.setting-group select, .setting-group input {
  width: 100%; padding: 7px 10px;
  border: 1px solid #e1e4e8; border-radius: 6px;
  font-size: 13px; font-family: inherit;
}

/* ── Status bar ── */
.status-bar {
  padding: 8px 14px;
  font-size: 12px;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: justify;
  justify-content: space-between;
}
.status-bar.error {
  background: #ffebe9;
  color: #cf222e;
  border-bottom: 1px solid #ffcecb;
}
.status-bar .dismiss {
  cursor: pointer;
  font-size: 14px;
}

/* Upload area */
.upload-area {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  margin-bottom: 4px;
}
.upload-btn {
  background: none; border: 1px solid #e1e4e8; border-radius: 4px;
  cursor: pointer; padding: 4px 8px; color: #57606a;
  display: -ms-flexbox; display: flex;
  -ms-flex-align: center; align-items: center;
  font-family: inherit;
}
.upload-btn:hover { background: #f0faf4; border-color: #217346; color: #217346; }
.upload-filename {
  font-size: 11px; color: #217346; margin-left: 6px;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-clear {
  background: none; border: none; color: #cf222e; cursor: pointer;
  font-size: 14px; margin-left: 4px; padding: 2px;
}

/* Utility */
.hidden { display: none !important; }
