/* Terminal Feature Styles */

.terminal-feature {
  display: flex;
  height: 100%;
  background: #0a0a0f;
}

/* Terminal List Panel */
.terminal-list-panel {
  width: 280px;
  min-width: 280px;
  background: #12121a;
  border-right: 1px solid #1e1e2e;
  display: flex;
  flex-direction: column;
}

.terminal-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #1e1e2e;
}

.terminal-list-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
}

.btn-new-terminal {
  background: #f97316;
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-new-terminal:hover {
  background: #ea580c;
  transform: scale(1.05);
}

.terminal-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.terminal-list-empty {
  padding: 2rem;
  text-align: center;
  color: #64748b;
  font-size: 0.875rem;
}

.terminal-list-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0.25rem;
}

.terminal-list-item:hover {
  background: #1e1e2e;
}

.terminal-list-item.active {
  background: #f9731620;
  border: 1px solid #f9731640;
}

.session-icon {
  font-size: 1.25rem;
  margin-right: 0.75rem;
}

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

.session-name {
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Terminal View Area */
.terminal-view-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Empty State */
.terminal-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.terminal-empty-state h3 {
  margin: 0 0 0.5rem 0;
  color: #e2e8f0;
  font-size: 1.5rem;
}

.terminal-empty-state p {
  margin: 0 0 1.5rem 0;
  color: #64748b;
}

.btn-primary {
  background: #f97316;
  border: none;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #ea580c;
}

/* Toolbar */
.terminal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #12121a;
  border-bottom: 1px solid #1e1e2e;
}

.terminal-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.terminal-name {
  font-weight: 600;
  color: #e2e8f0;
}

.terminal-cwd {
  font-size: 0.875rem;
  color: #64748b;
  font-family: monospace;
}

.terminal-actions {
  display: flex;
  gap: 0.5rem;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid #2d2d3d;
  color: #94a3b8;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.toolbar-btn:hover {
  background: #1e1e2e;
  border-color: #f97316;
  color: #f97316;
}

/* Context Menu */
.context-menu {
  position: absolute;
  background: #1e1e2e;
  border: 1px solid #2d2d3d;
  border-radius: 8px;
  padding: 0.5rem 0;
  min-width: 180px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
}

.context-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

.context-item:hover {
  background: #2d2d3d;
}

.context-item.danger {
  color: #ef4444;
}

.context-item.danger:hover {
  background: #ef444420;
}

.context-divider {
  height: 1px;
  background: #2d2d3d;
  margin: 0.5rem 0;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #1e1e2e;
  border: 1px solid #2d2d3d;
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 300px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  margin: 0 0 1rem 0;
  color: #e2e8f0;
}

.modal-content input {
  width: 100%;
  padding: 0.75rem;
  background: #0a0a0f;
  border: 1px solid #2d2d3d;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.modal-content input:focus {
  outline: none;
  border-color: #f97316;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-secondary {
  background: transparent;
  border: 1px solid #2d2d3d;
  color: #94a3b8;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #2d2d3d;
  color: #e2e8f0;
}

/* Responsive */
@media (max-width: 768px) {
  .terminal-list-panel {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  
  .terminal-list-panel.open {
    transform: translateX(0);
  }
}

/* Custom Scrollbar */
.terminal-list::-webkit-scrollbar {
  width: 6px;
}

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

.terminal-list::-webkit-scrollbar-thumb {
  background: #2d2d3d;
  border-radius: 3px;
}

.terminal-list::-webkit-scrollbar-thumb:hover {
  background: #3d3d4d;
}

/* ========================================
   TERMINAL LAYOUT — Exact fix pattern
   ======================================== */

/* =========================
   TERMINAL CONTAINER - fills panel
   ========================= */
.terminal-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  width: auto;
  height: 100%;
}

/* =========================
   PANEL — contains everything
   ========================= */
.terminal-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #0a0a0f;
}

/* Collapsed state - 30px sliver */
.terminal-panel.collapsed {
  flex: 0 0 30px;
  min-width: 30px;
  max-width: 30px;
}

.terminal-panel.collapsed .terminal-content {
  display: none;
}

.terminal-panel.collapsed .terminal-toggle {
  width: 30px;
}

/* Expanded state - 60% of parent */
.terminal-panel.expanded {
  flex: 0 0 60%;
  min-width: 200px;
  max-width: 60%;
}

/* =========================
   TOGGLE BUTTON
   ========================= */
.terminal-toggle {
  width: 30px;
  height: 100%;
  background: #1e1e2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 15px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.terminal-toggle:hover {
  background: #2d2d3d;
}

.terminal-icon {
  color: #94a3b8;
}

/* =========================
   CONTENT — fills panel
   ========================= */
.terminal-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Header */
.terminal-header {
  background: #12121a;
  border-bottom: 1px solid #1e1e2e;
  flex-shrink: 0;
}

.terminal-tabs {
  display: flex;
  background: #0a0a0f;
}

.terminal-tab {
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #64748b;
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.terminal-tab:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
}

.terminal-tab.active {
  color: #f97316;
  border-bottom-color: #f97316;
  background: rgba(249, 115, 22, 0.1);
}

/* =========================
   WRAPPER — one per terminal
   ========================= */
.terminal-wrapper {
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#terminal-wrapper-ivy.active,
#terminal-wrapper-isabella.active {
  display: flex;
}

/* =========================
   TERMINAL ROOT
   ========================= */
.terminal {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

/* =========================
   XTERM MUST FILL
   ========================= */
.terminal,
.xterm,
.xterm-viewport,
.xterm-screen {
  width: 100% !important;
  height: 100% !important;
}

.terminal .xterm-viewport {
  background: #0a0a0f !important;
  overflow-y: auto !important;
}

/* Status Bar */
.terminal-status-bar {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #12121a;
  border-top: 1px solid #1e1e2e;
  font-size: 0.75rem;
  font-family: monospace;
  flex-shrink: 0;
}

#terminal-status {
  color: #64748b;
}

#terminal-status.connected {
  color: #22c55e;
}

#terminal-status.disconnected {
  color: #ef4444;
}

#terminal-status.error {
  color: #ef4444;
}

#terminal-size {
  color: #64748b;
}
