/**
 * George Portal - Portal-specific Styles
 * Extends george.css for the internal portal layout
 */

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

html, body {
  height: 100%;
  overflow: hidden;
}

/* App Layout */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--george-parchment-dark);
  border-right: 1px solid var(--george-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--george-border);
}

.sidebar-header .george-logo {
  margin-bottom: 16px;
}

.sidebar-header .george-btn {
  width: 100%;
}

.sidebar-filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--george-border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-filters .george-select,
.sidebar-filters .george-input {
  font-size: 13px;
  padding: 8px 10px;
}

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

.sidebar-footer .george-btn {
  width: 100%;
  margin-top: 8px;
}

#user-info {
  font-size: 13px;
  color: var(--george-text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

#user-info .user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.conversation-item {
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.conversation-item:hover {
  background: var(--george-parchment-light);
}

.conversation-item.active {
  background: var(--george-parchment-light);
  border-left-color: var(--george-green);
}

.conversation-item .george-badge {
  font-size: 10px;
  padding: 2px 6px;
  margin-bottom: 4px;
}

.conversation-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--george-text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-preview {
  font-size: 12px;
  color: var(--george-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.conversation-time {
  font-size: 11px;
  color: var(--george-text-light);
}

/* Platform Badges */
.badge-slack {
  background: #611f69 !important;
}

.badge-salesforce {
  background: #00a1e0 !important;
}

.badge-zendesk {
  background: #03363d !important;
}

.badge-george_site {
  background: var(--george-green) !important;
}

/* Main Content */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--george-parchment);
}

/* Views */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* Chat View */
#chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--george-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.chat-messages {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Messages */
.message {
  margin-bottom: 16px;
  max-width: 100%;
}

.message-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-user .message-content {
  background: var(--george-green);
  color: white;
  border-radius: 18px;
  border-bottom-right-radius: 4px;
  padding: 10px 16px;
  max-width: 70%;
  line-height: 1.5;
  word-wrap: break-word;
}

.message-assistant {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-assistant .message-content {
  background: white;
  border: 1px solid var(--george-border-light);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 10px 16px;
  max-width: 85%;
  line-height: 1.6;
  word-wrap: break-word;
}

.message-meta {
  font-size: 11px;
  color: var(--george-text-light);
  margin-top: 4px;
  padding: 0 8px;
}

/* Chat Input */
.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--george-border-light);
  background: var(--george-parchment-light);
}

.chat-input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input-wrapper .george-textarea {
  min-height: 44px;
  max-height: 200px;
  resize: none;
  padding: 12px 16px;
}

.chat-input-wrapper .george-btn {
  height: 44px;
  min-width: 80px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--george-text-muted);
  text-align: center;
  padding: 40px;
}

.empty-state .george-logo {
  font-size: 32px;
  margin-bottom: 24px;
}

.empty-state .george-logo-dot {
  width: 20px;
  height: 20px;
}

.empty-state p {
  font-size: 16px;
  max-width: 400px;
}

/* Typing Indicator */
.typing-message {
  margin-bottom: 16px;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: white;
  border: 1px solid var(--george-border-light);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--george-green);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Paths View */
#paths-view {
  padding: 24px;
  overflow-y: auto;
}

.paths-header {
  max-width: 1000px;
  margin: 0 auto 24px;
}

.paths-header h2 {
  margin-bottom: 8px;
}

.paths-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
}

.path-card {
  cursor: pointer;
  transition: all 0.15s;
}

.path-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--george-shadow);
}

.path-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.path-card h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.path-card p {
  color: var(--george-text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  text-align: center;
}

.login-card .george-logo {
  justify-content: center;
  font-size: 24px;
  margin-bottom: 32px;
}

.login-card .george-logo-dot {
  width: 16px;
  height: 16px;
}

.login-card .george-label {
  text-align: left;
}

.login-card .george-input {
  text-align: left;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--george-text);
  color: white;
  border-radius: var(--george-radius);
  box-shadow: var(--george-shadow-lg);
  z-index: 1000;
  animation: toast-in 0.3s ease-out;
  transition: opacity 0.3s ease-out;
}

.toast.error {
  background: var(--george-error);
}

.toast.success {
  background: var(--george-success);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Send button loading state */
#send-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#send-btn .george-spinner {
  border-width: 2px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(245, 241, 235, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay .george-spinner {
  width: 32px;
  height: 32px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s;
  }

  #sidebar.open {
    left: 0;
  }

  .mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
    display: none;
  }

  .mobile-overlay.active {
    display: block;
  }

  .mobile-menu-btn {
    display: block;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn,
  .mobile-overlay {
    display: none;
  }
}

/* ============================================
   Tool Drawer Styles
   ============================================ */

/* Tool drawer toggle button */
.tool-drawer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--george-parchment);
  border: 1px solid var(--george-border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--george-text);
  transition: all 0.15s;
}

.tool-drawer-toggle:hover {
  background: var(--george-parchment-dark);
  border-color: var(--george-green);
}

.tool-icon {
  font-size: 13px;
}

.tool-count {
  background: var(--george-green);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.tool-count.zero {
  background: var(--george-border);
}

/* Tool drawer panel */
.tool-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--george-parchment);
  border-bottom: 1px solid var(--george-border);
}

.tool-drawer.open {
  max-height: 300px;
}

.tool-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--george-border-light);
  gap: 16px;
}

.tool-search {
  padding: 8px 12px;
  border: 1px solid var(--george-border);
  border-radius: 6px;
  width: 200px;
  font-size: 13px;
}

.tool-drawer-hint {
  font-size: 12px;
  color: var(--george-text-muted);
  font-style: italic;
}

/* Tool list (scrollable, filterable) */
.tool-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  padding: 12px 16px;
  max-height: 200px;
  overflow-y: auto;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--george-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.tool-card:hover {
  border-color: var(--george-green);
  box-shadow: var(--george-shadow-sm);
}

.tool-card.active {
  background: rgba(60, 103, 66, 0.1);
  border-color: var(--george-green);
}

.tool-card.george-activated {
  animation: george-pulse 0.5s ease;
}

@keyframes george-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 0 12px var(--george-green); }
}

.tool-card-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--george-green);
  margin-top: 2px;
  flex-shrink: 0;
}

.tool-card-info {
  flex: 1;
  min-width: 0;
}

.tool-card-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--george-text);
}

.tool-card-desc {
  font-size: 12px;
  color: var(--george-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* Active tool bar (persistent indicator) */
.active-tool-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(60, 103, 66, 0.1);
  border-bottom: 1px solid var(--george-green);
  font-size: 13px;
}

.active-tool-label {
  color: var(--george-text-muted);
}

.active-tool-name {
  font-weight: 500;
  color: var(--george-green);
}

.active-tool-clear {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--george-text-muted);
  padding: 0 4px;
  line-height: 1;
}

.active-tool-clear:hover {
  color: var(--george-error);
}

/* System message for tool activation */
.message-system {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.system-msg-text {
  font-size: 12px;
  color: var(--george-text-muted);
  background: var(--george-parchment-dark);
  padding: 4px 12px;
  border-radius: 12px;
  font-style: italic;
}
