/* ========================================
   BESSERAI TERMINAL - MAIN STYLES
   ======================================== */

:root {
  /* Terminal Colors */
  --terminal-bg: #0a0e1a;
  --terminal-bg-gradient: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 100%);
  --terminal-surface: #141824;
  --terminal-surface-hover: #1e2330;
  --terminal-border: #2a2f3f;
  --terminal-text: #e4e7eb;
  --terminal-text-muted: #8b92a8;
  --terminal-accent: #00d9ff;
  --terminal-accent-glow: rgba(0, 217, 255, 0.3);
  --terminal-success: #00ff88;
  --terminal-warning: #ffaa00;
  --terminal-error: #ff3366;
  
  /* AI Message Colors */
  --ai-message-bg: #1a1f2e;
  --user-message-bg: #0f3460;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow-accent: 0 0 20px var(--terminal-accent-glow);
  
  /* Fonts */
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--terminal-bg-gradient);
  color: var(--terminal-text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

/* ========================================
   TERMINAL WRAPPER
   ======================================== */

.terminal-wrapper {
  width: 100%;
  max-width: 1400px;
  height: 90vh;
  max-height: 900px;
  background: var(--terminal-surface);
  border-radius: 16px;
  border: 1px solid var(--terminal-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: terminalFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes terminalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ========================================
   TERMINAL HEADER
   ======================================== */

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(20, 24, 36, 0.9);
  border-bottom: 1px solid var(--terminal-border);
  backdrop-filter: blur(10px);
}

.terminal-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--terminal-accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.terminal-logo i {
  font-size: 20px;
}

.terminal-logo strong {
  color: var(--terminal-success);
}

.terminal-controls {
  display: flex;
  gap: 8px;
}

.terminal-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--terminal-surface-hover);
  color: var(--terminal-text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.terminal-btn:hover {
  background: var(--terminal-border);
  color: var(--terminal-text);
  transform: translateY(-1px);
}

.terminal-btn.close:hover {
  background: var(--terminal-error);
  color: white;
}

/* ========================================
   TERMINAL BODY
   ======================================== */

.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.terminal-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.terminal-messages::-webkit-scrollbar {
  width: 8px;
}

.terminal-messages::-webkit-scrollbar-track {
  background: transparent;
}

.terminal-messages::-webkit-scrollbar-thumb {
  background: var(--terminal-border);
  border-radius: 4px;
}

.terminal-messages::-webkit-scrollbar-thumb:hover {
  background: var(--terminal-text-muted);
}

/* ========================================
   MESSAGES
   ======================================== */

.terminal-message {
  display: flex;
  gap: 16px;
  animation: messageSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ai-message .message-avatar {
  background: linear-gradient(135deg, var(--terminal-accent), var(--terminal-success));
  color: var(--terminal-bg);
  box-shadow: var(--glow-accent);
}

.user-message .message-avatar {
  background: var(--user-message-bg);
  color: var(--terminal-accent);
}

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.message-sender {
  font-weight: 600;
  font-size: 14px;
  color: var(--terminal-accent);
}

.user-message .message-sender {
  color: var(--terminal-text);
}

.message-time {
  font-size: 12px;
  color: var(--terminal-text-muted);
  font-family: var(--font-mono);
}

.message-text {
  background: var(--ai-message-bg);
  padding: 16px 20px;
  border-radius: 12px;
  line-height: 1.6;
  border: 1px solid var(--terminal-border);
}

.user-message .message-text {
  background: var(--user-message-bg);
  border-color: rgba(0, 217, 255, 0.2);
}

.message-text h2 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--terminal-accent);
}

.message-text p {
  margin-bottom: 12px;
  color: var(--terminal-text);
}

.message-text p:last-child {
  margin-bottom: 0;
}

/* ========================================
   CATEGORY GRID
   ======================================== */

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.category-card {
  background: var(--terminal-surface);
  border: 1px solid var(--terminal-border);
  border-radius: 12px;
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--terminal-accent), var(--terminal-success));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-card:hover {
  transform: translateY(-4px);
  border-color: var(--terminal-accent);
  box-shadow: 0 8px 24px rgba(0, 217, 255, 0.2);
}

.category-card:hover::before {
  opacity: 0.1;
}

.category-card > * {
  position: relative;
  z-index: 1;
}

.category-icon {
  font-size: 32px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--terminal-accent), var(--terminal-success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.category-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--terminal-text);
}

.category-desc {
  font-size: 12px;
  color: var(--terminal-text-muted);
  line-height: 1.4;
}

/* ========================================
   SERVER TABS
   ======================================== */

.server-tabs-container {
  border-top: 1px solid var(--terminal-border);
  background: rgba(10, 14, 26, 0.6);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.server-tabs-container.has-servers {
  max-height: 400px;
  overflow-y: auto;
}

.server-tab {
  border-bottom: 1px solid var(--terminal-border);
  transition: all 0.3s ease;
}

.server-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
  background: var(--terminal-surface);
  transition: all 0.2s ease;
}

.server-tab-header:hover {
  background: var(--terminal-surface-hover);
}

.server-tab-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terminal-success);
  box-shadow: 0 0 8px var(--terminal-success);
  animation: pulse 2s ease-in-out infinite;
}

.server-status-dot.offline {
  background: var(--terminal-text-muted);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.server-tab-name {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--terminal-text);
}

.server-tab-type {
  font-size: 11px;
  color: var(--terminal-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.server-tab-toggle {
  color: var(--terminal-text-muted);
  transition: transform 0.3s ease;
}

.server-tab.expanded .server-tab-toggle {
  transform: rotate(180deg);
}

.server-tab-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.server-tab.expanded .server-tab-content {
  max-height: 300px;
}

.server-details {
  padding: 16px 20px;
  background: var(--terminal-bg);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.server-detail-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.server-detail-label {
  font-size: 11px;
  color: var(--terminal-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.server-detail-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--terminal-text);
  font-weight: 500;
}

.server-detail-value.selectable {
  cursor: text;
  user-select: text;
  padding: 4px 8px;
  background: var(--terminal-surface);
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.server-detail-value.selectable:hover {
  border-color: var(--terminal-accent);
}

.server-detail-value.selectable::selection {
  background: var(--terminal-accent);
  color: var(--terminal-bg);
}

/* ========================================
   INPUT AREA
   ======================================== */

.terminal-input-wrapper {
  border-top: 1px solid var(--terminal-border);
  background: rgba(20, 24, 36, 0.95);
  backdrop-filter: blur(10px);
  padding: 16px 20px;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.terminal-prompt {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--terminal-accent);
  font-weight: 600;
  flex-shrink: 0;
}

.input-container {
  flex: 1;
  position: relative;
}

.terminal-input {
  width: 100%;
  background: var(--terminal-surface);
  border: 1px solid var(--terminal-border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  transition: all 0.3s ease;
}

.terminal-input:focus {
  border-color: var(--terminal-accent);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}

.terminal-input::placeholder {
  color: var(--terminal-text-muted);
}

.selection-indicator {
  position: absolute;
  top: -30px;
  left: 0;
  background: var(--terminal-accent);
  color: var(--terminal-bg);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(5px);
  pointer-events: none;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.selection-indicator.active {
  opacity: 1;
  transform: translateY(0);
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: linear-gradient(135deg, var(--terminal-accent), var(--terminal-success));
  color: var(--terminal-bg);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 217, 255, 0.4);
}

.send-btn:active {
  transform: translateY(0);
}

.input-hints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--terminal-text-muted);
}

.hint-shortcuts {
  display: flex;
  gap: 12px;
}

kbd {
  background: var(--terminal-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--terminal-border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--terminal-text);
}

/* ========================================
   PRODUCT CARDS (for offers)
   ======================================== */

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.product-card {
  background: var(--terminal-surface);
  border: 1px solid var(--terminal-border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.product-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--terminal-accent), var(--terminal-success));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--terminal-accent);
  box-shadow: 0 8px 24px rgba(0, 217, 255, 0.2);
}

.product-card:hover::before {
  opacity: 0.05;
}

.product-card > * {
  position: relative;
  z-index: 1;
}

.product-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.product-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--terminal-text);
  margin-bottom: 4px;
}

.product-type {
  font-size: 12px;
  color: var(--terminal-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.product-badge {
  background: linear-gradient(135deg, var(--terminal-accent), var(--terminal-success));
  color: var(--terminal-bg);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.product-specs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.product-spec {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--terminal-text);
}

.product-spec i {
  color: var(--terminal-accent);
  width: 16px;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--terminal-border);
}

.product-price {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--terminal-success);
}

.product-price small {
  font-size: 12px;
  color: var(--terminal-text-muted);
  font-weight: 400;
}

.product-action {
  background: var(--terminal-accent);
  color: var(--terminal-bg);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.product-action:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  body {
    padding: 0;
  }
  
  .terminal-wrapper {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .product-grid {
    grid-template-columns: 1fr;
  }
  
  .server-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .terminal-header {
    padding: 12px 16px;
  }
  
  .terminal-logo {
    font-size: 14px;
  }
  
  .terminal-messages {
    padding: 16px;
  }
  
  .category-grid {
    grid-template-columns: 1fr;
  }
  
  .message-text h2 {
    font-size: 16px;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-success {
  color: var(--terminal-success);
}

.text-warning {
  color: var(--terminal-warning);
}

.text-error {
  color: var(--terminal-error);
}

.text-muted {
  color: var(--terminal-text-muted);
}

.loading-dots::after {
  content: '...';
  animation: loadingDots 1.5s steps(4, end) infinite;
}

@keyframes loadingDots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}
