:root {
  --primary-color: #CE2029; /* BNI Red */
  --primary-hover: #A81A21;
  --bg-color: #1a1a1a;
  --panel-bg: rgba(30, 30, 30, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #a1a1aa;
  --success-color: #10b981;
  --error-color: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

.background-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  filter: blur(80px);
  border-radius: 50%;
  opacity: 0.5;
  animation: float 10s infinite ease-in-out alternate;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(206, 32, 41, 0.6) 0%, rgba(206, 32, 41, 0) 70%);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(120, 120, 120, 0.4) 0%, rgba(120, 120, 120, 0) 70%);
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(30px) scale(1.1); }
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  padding: 40px;
  border-radius: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  margin: 20px;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  color: var(--primary-color);
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 16px;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

/* Upload Area */
.upload-card {
  background: rgba(15, 23, 42, 0.4);
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-card.dragover {
  border-color: var(--primary-color);
  background: rgba(206, 32, 41, 0.1);
}

.upload-card.has-file {
  border-color: var(--success-color);
  border-style: solid;
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: color 0.3s ease;
}

.upload-card:hover .upload-icon {
  color: var(--primary-color);
}

.upload-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-card p {
  font-size: 14px;
  color: var(--text-muted);
}

.or-text {
  margin-top: 8px;
  margin-bottom: 16px;
}

.file-label {
  color: var(--primary-color);
  cursor: pointer;
  font-weight: 500;
}

.file-label:hover {
  text-decoration: underline;
}

.file-status {
  font-size: 13px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  display: inline-block;
  color: var(--success-color);
  word-break: break-all;
  max-width: 100%;
  margin-top: auto;
  opacity: 0;
  transition: opacity 0.3s;
}

.has-file .file-status {
  opacity: 1;
}

.template-info {
  margin-top: 16px;
  background: rgba(255,255,255,0.05);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.info-icon {
  font-size: 18px;
  color: var(--primary-color);
}

/* Preview Area */
.preview-area {
  display: flex;
  flex-direction: column;
}

.preview-area h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.preview-container {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
  min-height: 240px;
}

.placeholder-text {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  opacity: 1;
  transition: opacity 0.3s;
}

.preview-stack {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.preview-stack.active {
  opacity: 1;
}

.preview-stack.active ~ .placeholder-text {
  opacity: 0;
}

/* Stack styling for canvas wrappers */
.stack-item {
  position: absolute;
  background: white;
  border-radius: 4px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  transform-origin: center center;
  /* Entrance animation applied dynamically in JS */
  width: 70%; /* Takes up 70% of preview container */
  aspect-ratio: 16 / 9; /* Assume 16:9 slides */
  overflow: hidden;
}

.stack-item canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stack-item .overlay-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through if needed */
}

/* Drop in animation */
@keyframes dropIn {
  0% { transform: translateY(-30px) scale(1.05); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Pagination Controls */
.preview-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

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

.icon-btn:hover:not(:disabled) {
  background: rgba(206, 32, 41, 0.2);
  border-color: rgba(206, 32, 41, 0.5);
  color: white;
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#page-indicator {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  min-width: 60px;
  text-align: center;
}

/* Actions */
.action-section {
  text-align: center;
}

.primary-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 16px 40px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  max-width: 380px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.primary-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(206, 32, 41, 0.4);
}

.primary-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.loader {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 3px solid white;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

.error-message, .success-message {
  margin-top: 24px;
  padding: 16px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  animation: slideFadeIn 0.3s ease-out;
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.success-message {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

@keyframes slideFadeIn {
  0% { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .container {
    padding: 24px;
  }
}
