/**
 * OCP Pipeline Expert — aesthetic theme layer
 * Dark forest green OCP identity
 */

:root {
  --ocp-brand-deep: #052e16;
  --ocp-brand-mid: #15803d;
  --ocp-glow: rgba(34, 197, 94, 0.4);
  --glass: rgba(20, 83, 45, 0.95);
  --glass-border: rgba(34, 197, 94, 0.35);
  --shadow-lift: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(34, 197, 94, 0.15);
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-header: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Ambient page background */
body:not(.theme-dark) {
  background:
    radial-gradient(ellipse 90% 60% at 50% -15%, rgba(34, 197, 94, 0.2), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(22, 163, 74, 0.15), transparent 50%),
    linear-gradient(165deg, #022c22 0%, var(--bg-page) 38%, #14532d 100%);
  position: relative;
}

body:not(.theme-dark)::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(34, 197, 94, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 197, 94, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black 20%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: min(100%, 860px);
}

body:not(.theme-dark) .chat-container {
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lift);
  background: var(--surface);
}

/* Header — OCP dark green gradient */
body:not(.theme-dark) .app-header {
  background: linear-gradient(128deg, #1DA13D 0%, #15803d 35%, #14532d 70%, #052e16 100%);
  box-shadow: var(--shadow-header);
  position: relative;
  overflow: hidden;
}

body:not(.theme-dark) .app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 42%),
    radial-gradient(circle at 88% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 35%);
  pointer-events: none;
}

.app-header__row,
.app-toolbar,
.app-toolbar__primary,
.toolbar-drawer {
  position: relative;
  z-index: 1;
}

.header-text h1 {
  font-weight: 700;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.header-text p {
  opacity: 0.95;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.status-pill {
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Toolbar */
body:not(.theme-dark) .app-toolbar {
  background: linear-gradient(180deg, #166534 0%, #14532d 100%);
  border-top: 1px solid rgba(34, 197, 94, 0.25);
}

body:not(.theme-dark) .btn {
  background: #15803d;
  border-color: #22c55e;
  color: #ecfdf5;
  border-radius: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

body:not(.theme-dark) .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  background: #166534;
}

body:not(.theme-dark) .btn--ghost:hover {
  background: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
}

body:not(.theme-dark) .toolbar-menu-btn {
  background: #15803d;
  border-color: #22c55e;
  color: #ecfdf5;
}

body:not(.theme-dark) .toolbar-drawer {
  background: #14532d;
  border-top-color: rgba(34, 197, 94, 0.25);
}

body:not(.theme-dark) .select-lang {
  background-color: #15803d;
  border-color: #22c55e;
  color: #ecfdf5;
}

.toolbar-menu-btn[aria-expanded="true"] {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

/* Chat area */
body:not(.theme-dark) .chat-messages {
  background: linear-gradient(180deg, #0a3d22 0%, #052e16 100%);
  scroll-padding-bottom: 16px;
}

body:not(.theme-dark) .chat-messages::-webkit-scrollbar-thumb {
  background: #166534;
}

.message {
  border-radius: 14px;
  transition: box-shadow 0.2s ease;
}

body:not(.theme-dark) .message.user {
  background: linear-gradient(145deg, #15803d 0%, #166534 100%);
  border-color: #22c55e;
  color: #ecfdf5;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

body:not(.theme-dark) .message.user .message-header,
body:not(.theme-dark) .message.user .message-content,
body:not(.theme-dark) .message.user .message-content strong {
  color: #ecfdf5;
}

body:not(.theme-dark) .message.user .message-content .section-title {
  color: #bbf7d0;
}

body:not(.theme-dark) .message.assistant {
  background: linear-gradient(145deg, #14532d 0%, #166534 100%);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
  border-color: #15803d;
  color: #ecfdf5;
}

body:not(.theme-dark) .message.assistant .message-header {
  color: #86efac;
}

body:not(.theme-dark) .message.assistant .message-content {
  color: #ecfdf5;
}

body:not(.theme-dark) .message.assistant .message-content .section-title {
  color: #4ade80;
}

.message-header {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
}

.qa-badge--q {
  background: linear-gradient(145deg, #22c55e, var(--ocp-green));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

body:not(.theme-dark) .qa-badge--a {
  background: linear-gradient(145deg, #166534, #15803d);
  color: #bbf7d0;
  font-weight: 600;
}

.message-content .section-title {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Quick actions */
body:not(.theme-dark) .quick-actions {
  background: linear-gradient(180deg, transparent, rgba(5, 46, 22, 0.95));
  padding-top: 4px;
}

body:not(.theme-dark) .quick-btn {
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-color: #22c55e;
  background: #14532d;
  color: #bbf7d0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

body:not(.theme-dark) .quick-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  border-color: #4ade80;
  background: #166534;
  color: #ecfdf5;
}

/* Composer */
body:not(.theme-dark) .input-area {
  background: linear-gradient(180deg, #14532d, #052e16);
  border-top: 1px solid #166534;
}

body:not(.theme-dark) .input-wrapper {
  background: #0a3d22;
  border: 1px solid #22c55e;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  padding: 6px 8px 6px 14px;
}

body:not(.theme-dark) .mic-btn {
  background: #15803d;
  border-color: #22c55e;
  color: #ecfdf5;
  border-radius: 12px;
}

body:not(.theme-dark) .app-footer {
  background: linear-gradient(180deg, #14532d, #052e16);
  border-top-color: #166534;
}

body:not(.theme-dark) .app-footer__inner {
  color: #86efac;
}

body:not(.theme-dark) .app-footer__brand {
  color: #bbf7d0;
  font-weight: 700;
}

body:not(.theme-dark) .composer-hint {
  color: #6ee7b7;
}

.input-wrapper:focus-within {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25), 0 4px 16px rgba(0, 0, 0, 0.3);
  border-color: #4ade80;
}

.send-btn {
  background: linear-gradient(145deg, #28c955 0%, var(--ocp-green) 50%, var(--ocp-brand-mid) 100%);
  border-radius: 12px;
  box-shadow: 0 4px 14px var(--ocp-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.send-btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.45);
}

.send-btn:active {
  transform: scale(0.96);
}

body:not(.theme-dark) .mic-btn.listening {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.15); }
}

/* Modals */
.modal {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(2, 44, 34, 0.75);
}

body:not(.theme-dark) .modal__panel {
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  background: #14532d;
  border-color: #166534;
}

body:not(.theme-dark) .modal__title {
  color: #ecfdf5;
}

body:not(.theme-dark) .modal__body {
  color: #bbf7d0;
}

body:not(.theme-dark) .modal__btn--secondary {
  background: #0a3d22;
  color: #ecfdf5;
  border-color: #166534;
}

body:not(.theme-dark) .modal__btn--secondary:hover {
  background: #166534;
}

.modal__btn {
  background: linear-gradient(145deg, #28c955, var(--ocp-green));
  box-shadow: 0 4px 12px var(--ocp-glow);
}

.modal__btn:hover {
  filter: brightness(1.05);
}

/* Toast */
.toast {
  background: linear-gradient(145deg, #14532d, #052e16);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* Typing indicator */
body:not(.theme-dark) .typing-indicator {
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  background: #14532d;
  border-color: #166534;
}

.typing-dot {
  background: #4ade80;
}

.safety-badge {
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Industry 4.0 */
.i40-panel {
  background: linear-gradient(180deg, #052e16 0%, #0a3d22 35%, #0c1929 100%);
  border-bottom: 1px solid rgba(34, 197, 94, 0.25);
}

.i40-panel__head {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
}

.i40-kpi {
  border-radius: 10px;
  backdrop-filter: blur(4px);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.i40-kpi:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 197, 94, 0.35);
}

.i40-kpi__value {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.i40-asset-row select {
  border-radius: 10px;
}

.i40-asset-row .quick-btn {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
}

/* Dark theme toggle — near-black green */
body.theme-dark {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(34, 197, 94, 0.1), transparent 55%),
    linear-gradient(165deg, #010a06 0%, #0f172a 45%, #111827 100%);
}

body.theme-dark::before {
  background-image:
    linear-gradient(rgba(34, 197, 94, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 197, 94, 0.04) 1px, transparent 1px);
}

body.theme-dark .chat-container {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(34, 197, 94, 0.2);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

body.theme-dark .app-header {
  background: linear-gradient(128deg, #15803d 0%, #166534 40%, #020617 100%);
}

body.theme-dark .chat-messages {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

body.theme-dark .message.user {
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1));
  border-color: rgba(34, 197, 94, 0.4);
}

body.theme-dark .input-wrapper {
  background: #0f172a;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

body.theme-dark .quick-btn {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(51, 65, 85, 0.9);
}

body.theme-dark .quick-btn:hover {
  background: rgba(34, 197, 94, 0.12);
}

/* Tablet/desktop */
@media (min-width: 768px) {
  body:not(.theme-dark) {
    padding: clamp(16px, 3vw, 32px);
  }

  body:not(.theme-dark) .chat-container {
    min-height: min(94dvh, 920px);
  }

  .app-header__row {
    padding: 14px 22px;
  }

  .header-logo {
    height: 52px;
  }
}

@media (max-width: 767px) {
  body:not(.theme-dark) .chat-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn:hover,
  .quick-btn:hover,
  .i40-kpi:hover,
  .send-btn:hover {
    transform: none;
  }
  .mic-btn.listening {
    animation: none;
  }
}
