/* PO Watcher - Shared Theme & Animations */
/* Version 2.0 - Unified Platform Design */

/* ========== CSS VARIABLES ========== */
:root {
  --bg: #0a0f1a;
  --bg-card: #141b2d;
  --bg-input: #1e293b;
  --border: #2d3748;
  --text-1: #f1f5f9;
  --text-2: #a1a1aa;
  --text-3: #6b7280;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-dim: rgba(245,158,11,0.1);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.12);
  --purple: #8b5cf6;
  --purple-dim: rgba(139,92,246,0.12);
}

/* ========== BASE STYLES ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ========== MICRO-ANIMATIONS ========== */

/* Typing cursor */
.typing-cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--accent);
  margin-left: 4px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Error shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.shake {
  animation: shake 0.5s ease-in-out;
}

/* Success checkmark draw */
@keyframes drawCheck {
  0% { stroke-dashoffset: 50; }
  100% { stroke-dashoffset: 0; }
}
.check-animated path {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
}
.check-animated.animate path {
  animation: drawCheck 0.5s ease-out forwards;
}

/* Stagger entrance */
.stagger-item {
  opacity: 0;
  transform: translateY(30px);
}
.stagger-item.visible {
  animation: staggerIn 0.6s ease-out forwards;
}
.stagger-item:nth-child(1) { animation-delay: 0s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.2s; }
.stagger-item:nth-child(4) { animation-delay: 0.3s; }
.stagger-item:nth-child(5) { animation-delay: 0.4s; }
.stagger-item:nth-child(6) { animation-delay: 0.5s; }
@keyframes staggerIn {
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Card entrance */
@keyframes cardEntrance {
  0% { opacity: 0; transform: translateY(30px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.card-animate {
  animation: cardEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Pulse glow for buttons */
.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 15px rgba(245,158,11,0.3); }
  50% { box-shadow: 0 4px 30px rgba(245,158,11,0.6), 0 0 60px rgba(245,158,11,0.3); }
}

/* Toast slide in */
@keyframes toastSlideIn {
  0% { opacity: 0; transform: translateX(100%) scale(0.8); }
  60% { transform: translateX(-10px) scale(1.02); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
.toast-animated {
  animation: toastSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Fade in up */
@keyframes fadeInUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
  animation: fadeInUp 0.5s ease-out forwards;
}
.fade-in-up.delay-1 { animation-delay: 0.1s; }
.fade-in-up.delay-2 { animation-delay: 0.2s; }
.fade-in-up.delay-3 { animation-delay: 0.3s; }

/* Spin animation */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 0.6s linear infinite;
}

/* Scale in */
@keyframes scaleIn {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}
.scale-in {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Bounce animation */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.bounce {
  animation: bounce 1s ease-in-out infinite;
}

/* ========== BACKGROUND EFFECTS ========== */

/* Gradient backgrounds */
.bg-gradient-top {
  background-image: radial-gradient(ellipse at top, rgba(245,158,11,0.1) 0%, transparent 50%);
}
.bg-gradient-center {
  background-image: 
    radial-gradient(ellipse at top, rgba(245,158,11,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(59,130,246,0.05) 0%, transparent 50%);
}
.bg-gradient-subtle {
  background-image: radial-gradient(ellipse at 50% 0%, rgba(245,158,11,0.06) 0%, transparent 60%);
}

/* Floating particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 15s infinite ease-in-out;
}
.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 12s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 14s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 16s; }
.particle:nth-child(4) { left: 40%; animation-delay: 6s; animation-duration: 13s; }
.particle:nth-child(5) { left: 50%; animation-delay: 1s; animation-duration: 15s; }
.particle:nth-child(6) { left: 60%; animation-delay: 3s; animation-duration: 17s; }
.particle:nth-child(7) { left: 70%; animation-delay: 5s; animation-duration: 14s; }
.particle:nth-child(8) { left: 80%; animation-delay: 7s; animation-duration: 12s; }
.particle:nth-child(9) { left: 90%; animation-delay: 2s; animation-duration: 16s; }
@keyframes float {
  0%, 100% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 0.3; }
  90% { opacity: 0.3; }
  50% { transform: translateY(-100px) scale(1); }
}

/* ========== CARD STYLES ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  transition: all 0.3s ease;
}
.card:hover {
  border-color: rgba(245,158,11,0.3);
}
.card-glow:hover {
  box-shadow: 0 8px 32px rgba(245,158,11,0.15);
}

/* ========== BUTTON STYLES ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #000;
  box-shadow: 0 4px 15px rgba(245,158,11,0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245,158,11,0.4);
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-primary.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--text-2);
  color: var(--text-1);
}

.btn-success {
  background: var(--green);
  color: #000;
}
.btn-danger {
  background: var(--red);
  color: #fff;
}

/* Button loading state */
.btn-loading {
  pointer-events: none;
}
.btn-loading .btn-text {
  opacity: 0;
}
.btn-loading .btn-spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Magnetic button effect */
.btn-magnetic {
  transition: transform 0.2s ease-out;
}

/* ========== FORM STYLES ========== */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 1rem;
  transition: all 0.2s ease;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.form-input::placeholder {
  color: var(--text-3);
}
.form-hint {
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-top: 6px;
}

/* Input with icon */
.input-icon-wrapper {
  position: relative;
}
.input-icon-wrapper .form-input {
  padding-left: 44px;
}
.input-icon-wrapper .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: toastSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success {
  background: var(--green);
  color: #000;
}
.toast-error {
  background: var(--red);
  color: #fff;
}
.toast-info {
  background: var(--blue);
  color: #fff;
}

/* ========== ERROR MESSAGES ========== */
.error-msg {
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 20px;
  display: none;
}
.error-msg.show {
  display: block;
  animation: shake 0.5s ease-in-out;
}

/* Success message */
.success-msg {
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 20px;
}

/* ========== HEADER STYLES ========== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-1);
}
.brand svg {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 8px rgba(245,158,11,0.3));
}
.brand span {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========== TAB STYLES ========== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  overflow-x: auto;
}
.tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text-1);
  background: var(--accent-dim);
}
.tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ========== MODAL STYLES ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.3s ease-out;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--text-1);
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ========== TABLE STYLES ========== */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-input);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover td {
  background: var(--accent-dim);
}
tr:last-child td {
  border-bottom: none;
}

/* ========== BADGE STYLES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-success {
  background: var(--green-dim);
  color: var(--green);
}
.badge-warning {
  background: var(--accent-dim);
  color: var(--accent);
}
.badge-danger {
  background: var(--red-dim);
  color: var(--red);
}
.badge-info {
  background: var(--blue-dim);
  color: var(--blue);
}

/* ========== STATUS ICONS ========== */
.status-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}
.status-icon.success {
  background: var(--green);
}
.status-icon.success svg {
  stroke: #000;
}
.status-icon.warning {
  background: var(--accent);
}
.status-icon.error {
  background: var(--red);
}
.status-icon.error svg {
  stroke: #fff;
}

/* ========== LOADING SPINNER ========== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ========== PROGRESS BAR ========== */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  .card {
    padding: 24px 20px;
  }
  .header {
    flex-wrap: wrap;
    gap: 12px;
  }
  .tabs {
    gap: 4px;
  }
  .tab {
    padding: 8px 14px;
    font-size: 0.875rem;
  }
}

/* ========== CONFETTI HELPER ========== */
.confetti-piece {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
}
