/* NCC Autofill - Premium 3D Professional UI */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Premium Color Palette */
  --primary: #0052a3;
  --primary-light: #1e6bcf;
  --primary-dark: #003d7a;
  --secondary: #5a6c7d;
  --success: #1b8a4d;
  --warning: #d98800;
  --danger: #c41e3a;
  --info: #0c5aa0;

  /* Professional Gradients */
  --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  --gradient-success: linear-gradient(135deg, var(--success) 0%, #2db871 100%);
  --gradient-danger: linear-gradient(135deg, var(--danger) 0%, #e63946 100%);

  /* Neutral Colors */
  --bg-light: #f0f2f5;
  --bg-white: #ffffff;
  --border-light: #e0e3e8;
  --border-medium: #d0d5dd;
  --text-dark: #1a1d23;
  --text-medium: #4a5568;
  --text-light: #6b7280;

  /* 3D Shadows - Premium Depth */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 12px 24px rgba(0, 52, 163, 0.15);
  --shadow-xl: 0 20px 40px rgba(0, 52, 163, 0.2);
  --shadow-3d: 0 25px 50px rgba(0, 0, 0, 0.25), 0 0 1px rgba(0, 0, 0, 0.1);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
}

/* Base Styles */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #f8fafb 0%, #eef2f7 100%);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 14px;
  perspective: 1000px;
}

/* Screens */
.screen {
  display: none;
  padding: var(--space-xl);
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeInScale 0.4s ease-out;
}

.screen.active {
  display: block;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

/* Card Design - 3D Premium */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover {
  transform: translateY(-8px) translateZ(20px);
  box-shadow: var(--shadow-3d);
  border-color: var(--primary-light);
}

.card:hover::before {
  opacity: 1;
}

/* Typography */
h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: var(--space-sm);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.subtitle {
  color: var(--text-light);
  font-size: 15px;
  margin-bottom: var(--space-xl);
  font-weight: 400;
  letter-spacing: 0.3px;
}

h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: var(--space-lg);
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

/* Upload Screen */
.upload-container {
  text-align: center;
  padding: var(--space-xxl);
}

.drop-zone {
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-xxl);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 82, 163, 0.1), transparent);
  transition: left 0.6s ease;
}

.drop-zone:hover::before {
  left: 100%;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 82, 163, 0.2);
}

.drop-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  animation: float 3s ease-in-out infinite;
}

.drop-zone p {
  color: var(--text-medium);
  font-size: 16px;
  margin-bottom: var(--space-sm);
  font-weight: 500;
}

.drop-zone strong {
  color: var(--primary);
  font-weight: 600;
}

.hint {
  font-size: 13px;
  color: var(--text-light);
  margin-top: var(--space-md);
  font-weight: 400;
}

/* Sheet Select */
.sheet-select {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-top: var(--space-xl);
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.sheet-select label {
  font-weight: 500;
  color: var(--text-medium);
}

.sheet-select select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sheet-select select:hover {
  border-color: var(--primary);
}

.sheet-select select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 82, 163, 0.1);
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn.primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 82, 163, 0.3);
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 82, 163, 0.4);
}

.btn.secondary {
  background: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
  background: var(--bg-white);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #e63946 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(196, 30, 58, 0.3);
}

.btn.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(196, 30, 58, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.toolbar-center {
  flex: 1;
}

#searchInput {
  padding: 10px 16px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  font-size: 14px;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 300px;
}

#searchInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 82, 163, 0.1);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 82, 163, 0.2);
}

.badge-exact {
  background: linear-gradient(135deg, var(--success) 0%, #2db871 100%);
  box-shadow: 0 2px 8px rgba(27, 138, 77, 0.2);
}

.ncc-cell {
  transition: all 0.3s ease;
}

.ncc-cell.has-value {
  background: transparent;
}

.badge-fuzzy-sp-kho {
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.badge-fuzzy-sp {
  background: linear-gradient(135deg, #eab308 0%, #facc15 100%);
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.2);
  color: #1a1d23;
}

.badge-fallback-sp {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.2);
}

.badge-event-product {
  background: linear-gradient(135deg, var(--danger) 0%, #e63946 100%);
  box-shadow: 0 2px 8px rgba(196, 30, 58, 0.2);
}

.badge-no-match {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--bg-white);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
}

thead {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  font-weight: 600;
}

th {
  padding: 16px;
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: linear-gradient(90deg, rgba(0, 82, 163, 0.03) 0%, transparent 100%);
}

tbody tr.source-exact {
  background: linear-gradient(90deg, rgba(27, 138, 77, 0.05) 0%, transparent 100%);
}

tbody tr.source-fuzzy-sp-kho {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.05) 0%, transparent 100%);
}

tbody tr.source-event-product {
  background: linear-gradient(90deg, rgba(196, 30, 58, 0.05) 0%, transparent 100%);
}

.ncc-select {
  padding: 8px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-light);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.ncc-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px rgba(0, 82, 163, 0.1);
}

.ncc-cell.has-value .ncc-select {
  border: 2px solid #1b8a4d;
  border-radius: var(--radius-md);
  background: rgba(27, 138, 77, 0.05);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease, display 0.3s ease allow-discrete;
  opacity: 0;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-3d);
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s ease;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-dark);
}

/* Form */
.rule-form {
  padding: var(--space-lg);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-group label {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-light);
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px rgba(0, 82, 163, 0.1);
}

/* Error */
.error {
  background: linear-gradient(135deg, rgba(196, 30, 58, 0.1) 0%, transparent 100%);
  color: var(--danger);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--danger);
  font-size: 14px;
}

/* Checkbox */
.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.checkbox-wrap input {
  cursor: pointer;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-center,
  .toolbar-right {
    width: 100%;
    flex-direction: column;
  }

  #searchInput {
    max-width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  table {
    font-size: 12px;
  }

  td, th {
    padding: 8px;
  }
}
