/* ============================================================
   Object Detective — style.css
   Dark mode futuristik dengan aksen biru/ungu
   ============================================================ */

/* === DESIGN TOKENS === */
:root {
  --bg-base:       #080818;
  --bg-surface:    #0e0e24;
  --bg-card:       rgba(18, 18, 45, 0.85);
  --bg-card-hover: rgba(22, 22, 55, 0.95);
  --bg-input:      rgba(255, 255, 255, 0.05);

  --accent-purple: #6c63ff;
  --accent-cyan:   #00b4ff;
  --accent-mid:    #5087ff;
  --accent-glow:   rgba(108, 99, 255, 0.35);
  --accent-glow-c: rgba(0, 180, 255, 0.25);

  --success:       #22d3a5;
  --warning:       #f59e0b;
  --danger:        #f43f5e;

  --text-primary:  #eeeeff;
  --text-secondary:#9999cc;
  --text-muted:    #5a5a88;
  --text-link:     #7b97ff;

  --border-color:  rgba(108, 99, 255, 0.2);
  --border-glow:   rgba(108, 99, 255, 0.5);

  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --radius-xl:     28px;

  --shadow-card:   0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
  --shadow-glow:   0 0 30px var(--accent-glow);
  --shadow-btn:    0 4px 20px rgba(108, 99, 255, 0.4);

  --transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* === ANIMATED BACKGROUND === */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(108, 99, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108, 99, 255, 0.04) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
  animation: float-glow 8s ease-in-out infinite alternate;
}

.bg-glow-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(108, 99, 255, 0.12) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  animation-delay: 0s;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 180, 255, 0.1) 0%, transparent 70%);
  bottom: -150px;
  left: -150px;
  animation-delay: -4s;
}

@keyframes float-glow {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -30px) scale(1.1); }
}

/* === HEADER === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 24, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px var(--accent-purple));
  animation: pulse-logo 3s ease-in-out infinite;
}

@keyframes pulse-logo {
  0%, 100% { filter: drop-shadow(0 0 10px var(--accent-purple)); }
  50%       { filter: drop-shadow(0 0 18px var(--accent-cyan)); }
}

.app-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}

.badge-dot.ready {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink-dot 2s ease-in-out infinite;
}

.badge-dot.loading {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.badge-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* === MAIN CONTAINER === */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* === CARD BASE === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: var(--transition);
  animation: card-appear 0.5s ease both;
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.card-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* === API KEY SECTION === */
.api-key-form {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.input-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 44px 12px 16px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.input-wrapper input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(108, 99, 255, 0.06);
}

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

.toggle-visibility-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.toggle-visibility-btn:hover { color: var(--accent-cyan); }
.toggle-visibility-btn svg { width: 18px; height: 18px; }

.api-status {
  font-size: 0.82rem;
  min-height: 20px;
  margin-bottom: 12px;
  font-weight: 500;
  transition: var(--transition);
}

.api-status.success { color: var(--success); }
.api-status.error   { color: var(--danger); }

.api-hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.api-hint svg { flex-shrink: 0; margin-top: 2px; fill: var(--text-muted); }

/* === CAMERA SECTION === */
.camera-container {
  margin-bottom: 20px;
}

.camera-frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  border: 1px solid var(--border-color);
  box-shadow: 0 0 40px var(--accent-glow);
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Corner decorations */
.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 10;
  pointer-events: none;
}

.corner-tl { top: 10px; left: 10px; border-top: 2px solid var(--accent-cyan); border-left: 2px solid var(--accent-cyan); border-radius: 4px 0 0 0; }
.corner-tr { top: 10px; right: 10px; border-top: 2px solid var(--accent-cyan); border-right: 2px solid var(--accent-cyan); border-radius: 0 4px 0 0; }
.corner-bl { bottom: 10px; left: 10px; border-bottom: 2px solid var(--accent-cyan); border-left: 2px solid var(--accent-cyan); border-radius: 0 0 0 4px; }
.corner-br { bottom: 10px; right: 10px; border-bottom: 2px solid var(--accent-cyan); border-right: 2px solid var(--accent-cyan); border-radius: 0 0 4px 0; }

/* Scan line */
.scan-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  box-shadow: 0 0 8px var(--accent-cyan);
  display: none;
  pointer-events: none;
  z-index: 5;
}

.scan-line.active {
  display: block;
  animation: scan 2s linear infinite;
}

@keyframes scan {
  0%   { top: 0; opacity: 1; }
  95%  { top: calc(100% - 2px); opacity: 1; }
  100% { top: calc(100% - 2px); opacity: 0; }
}

/* Camera overlay / placeholder */
.camera-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 24, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
  transition: var(--transition-slow);
}

.camera-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.camera-placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.camera-placeholder-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.camera-placeholder p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.camera-controls {
  display: flex;
  justify-content: center;
}

.error-banner {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--danger);
  margin-top: 14px;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 50px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: var(--transition);
}

.btn:hover::before { background: rgba(255, 255, 255, 0.06); }
.btn:active::before { background: rgba(255, 255, 255, 0.12); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-mid));
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108, 99, 255, 0.6);
}

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

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--accent-purple);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(108, 99, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(108, 99, 255, 0.25);
  transform: translateY(-1px);
}

/* Capture button — special */
.btn-capture {
  background: linear-gradient(135deg, #6c63ff, #00b4ff);
  color: #fff;
  padding: 16px 40px;
  font-size: 1rem;
  border-radius: 50px;
  box-shadow: 0 6px 30px rgba(108, 99, 255, 0.5), 0 0 0 0 rgba(108, 99, 255, 0.3);
  animation: none;
}

.btn-capture:not(:disabled):hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 40px rgba(108, 99, 255, 0.7), 0 0 0 6px rgba(108, 99, 255, 0.15);
}

.btn-capture:not(:disabled) {
  animation: pulse-capture 3s ease-in-out infinite;
}

@keyframes pulse-capture {
  0%, 100% { box-shadow: 0 6px 30px rgba(108, 99, 255, 0.5), 0 0 0 0 rgba(108, 99, 255, 0); }
  50%       { box-shadow: 0 6px 30px rgba(108, 99, 255, 0.5), 0 0 0 8px rgba(108, 99, 255, 0); }
}

.capture-icon { font-size: 1.2rem; }
.btn-icon { font-size: 1rem; }

/* === RESULT SECTION === */
.result-section {
  animation: card-appear 0.5s ease both;
}

/* Detection result card */
.detection-result-card {
  background: rgba(108, 99, 255, 0.08);
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}

.detection-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.detection-badge {
  background: rgba(108, 99, 255, 0.2);
  border: 1px solid rgba(108, 99, 255, 0.4);
  border-radius: 50px;
  padding: 4px 14px;
}

.detection-badge-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.confidence-pill {
  background: rgba(34, 211, 165, 0.15);
  border: 1px solid rgba(34, 211, 165, 0.3);
  border-radius: 50px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
}

.detected-object-name {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
  line-height: 1.2;
}

.confidence-bar-container {
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 50px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--accent-cyan);
  width: 0%;
}

/* AI Explanation card */
.ai-explanation-card {
  background: rgba(0, 180, 255, 0.04);
  border: 1px solid rgba(0, 180, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
  height: auto;
  overflow: visible;
}

.ai-explanation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ai-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-icon { font-size: 1.1rem; }

.ai-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ai-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Loading dots */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  animation: bounce-dot 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* AI text */
.ai-text {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: break-word;
  animation: fade-in 0.4s ease;
}

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

.ai-text p { margin-bottom: 14px; }
.ai-text p:last-child { margin-bottom: 0; }

/* AI error */
.ai-error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.85rem;
  color: var(--danger);
  line-height: 1.5;
}

/* AI actions */
.ai-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Result footer */
.result-footer {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

/* === LINK ACCENT === */
.link-accent {
  color: var(--text-link);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

.link-accent:hover {
  color: var(--accent-cyan);
  text-decoration: underline;
}

/* === FOOTER === */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
}

/* === UTILITY === */
.hidden { display: none !important; }

/* === RESPONSIVE — TABLET === */
@media (max-width: 768px) {
  .main-container {
    padding: 20px 14px 50px;
    gap: 18px;
  }

  .card { padding: 20px 18px; }

  .header-inner { padding: 12px 16px; }

  .app-title { font-size: 1.1rem; }
  .app-subtitle { display: none; }

  .header-badge {
    font-size: 0.7rem;
    padding: 5px 10px;
  }

  .api-key-form { flex-direction: column; }
  .btn-primary { width: 100%; }

  .detected-object-name { font-size: 1.5rem; }

  .ai-actions {
    flex-direction: column;
  }

  .ai-actions .btn { width: 100%; }
}

/* === RESPONSIVE — SMALL MOBILE === */
@media (max-width: 420px) {
  .card { padding: 16px 14px; border-radius: var(--radius-lg); }

  .card-title { font-size: 1rem; }

  .btn-capture { padding: 14px 28px; font-size: 0.9rem; }

  .detected-object-name { font-size: 1.3rem; }
}
