/* ==========================================================================
   SignBridge - Sign Language to Text with Google Gemini AI Integration
   ========================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-hover: rgba(26, 37, 61, 0.85);
  --bg-card-solid: #121a2b;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(0, 245, 160, 0.35);

  --accent-cyan: #00f5a0;
  --accent-teal: #00d2ff;
  --accent-blue: #3b82f6;
  --accent-gemini-glow: #00d2ff;
  --accent-danger: #ff4757;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 245, 160, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(0, 210, 255, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header Navbar */
.app-header {
  height: 70px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 245, 160, 0.4);
}

.logo-icon svg {
  width: 24px;
  height: 24px;
  fill: #090d16;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, var(--accent-cyan));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.nav-tab {
  padding: 8px 18px;
  border-radius: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: var(--accent-cyan);
  color: #090d16;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(0, 245, 160, 0.4);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0, 245, 160, 0.1);
  border: 1px solid rgba(0, 245, 160, 0.3);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Main Workspace Layout */
.main-container {
  flex: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.grid-top {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .grid-top {
    grid-template-columns: 1fr;
  }
}

/* Video Card */
.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
}

.video-card-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
}

.video-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.video-view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.video-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #05070d;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: none;
}

#output_canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  pointer-events: none;
}

.webcam-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.placeholder-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.hud-overlay {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.hud-tag {
  background: rgba(9, 13, 22, 0.85);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-tag.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Control Panel */
.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  backdrop-filter: blur(10px);
}

.btn-primary-cyan {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
  border: none;
  color: #090d16;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 245, 160, 0.4);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary-cyan:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(0, 245, 160, 0.6);
}

.btn-danger {
  background: linear-gradient(135deg, #ff4757, #ff6b81) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4) !important;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.btn-secondary {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.detection-status-box {
  background: rgba(9, 13, 22, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detected-sign-preview {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sign-badge {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.15), rgba(0, 210, 255, 0.15));
  border: 1px solid var(--border-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.sign-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sign-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.sign-confidence {
  font-size: 0.75rem;
  color: var(--accent-cyan);
}

.confidence-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-teal));
  border-radius: 3px;
  transition: width 0.2s ease;
}

/* Transcribed Stream & Gemini Engine Card */
.transcript-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.transcript-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.transcript-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.transcript-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-pill {
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.action-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.action-pill.accent {
  background: rgba(0, 245, 160, 0.12);
  border-color: rgba(0, 245, 160, 0.4);
  color: var(--accent-cyan);
}

.action-pill.gemini-pill {
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.2), rgba(0, 210, 255, 0.2));
  border-color: rgba(0, 245, 160, 0.5);
  color: var(--accent-cyan);
  font-weight: 700;
}

.stream-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .stream-grid {
    grid-template-columns: 1fr;
  }
}

.stream-box-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stream-box-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.transcript-area {
  min-height: 140px;
  max-height: 240px;
  width: 100%;
  background: rgba(9, 13, 22, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  color: var(--text-main);
  font-size: 1.15rem;
  line-height: 1.6;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.transcript-area.gemini-box {
  background: rgba(0, 245, 160, 0.04);
  border-color: rgba(0, 245, 160, 0.3);
  color: #f1f5f9;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dictionary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.dict-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  transition: all 0.2s;
}

.dict-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 245, 160, 0.05);
  transform: translateY(-2px);
}

.dict-symbol {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.dict-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.dict-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card-solid);
  border: 1px solid var(--accent-cyan);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
