/* ==========================================================================
   AeroRotate - CSS Stylesheet
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #080b11;
  --bg-secondary: #0f1422;
  --color-primary: #6366f1;       /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-primary-glow: rgba(99, 102, 241, 0.15);
  --color-purple: #a855f7;        /* Purple */
  --color-purple-hover: #9333ea;
  --color-teal: #0ea5e9;          /* Light Blue / Teal */
  --color-emerald: #10b981;       /* Emerald */
  --color-emerald-hover: #059669;
  --color-danger: #f43f5e;        /* Rose / Red */
  --color-danger-hover: #e11d48;
  --color-text-main: #f8fafc;
  --color-text-muted: #64748b;
  --color-text-light: #cbd5e1;

  /* Glassmorphism Styles */
  --glass-bg: rgba(17, 24, 39, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.5);

  /* Borders & Spacing */
  --border-radius-lg: 20px;
  --border-radius-md: 14px;
  --border-radius-sm: 8px;
  
  /* Transitions */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

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

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

/* Background Glow Effects */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}

.bg-glow-1 {
  top: -10%;
  left: 20%;
  width: 50vw;
  height: 50vh;
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
}

.bg-glow-2 {
  bottom: 10%;
  right: 15%;
  width: 45vw;
  height: 45vh;
  background: radial-gradient(circle, var(--color-purple) 0%, transparent 70%);
}

/* Containers */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 13px;
  color: var(--color-text-muted);
}

.security-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
  color: var(--color-emerald);
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
}

/* Glassmorphism Card base */
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 40px var(--glass-shadow);
  border-radius: var(--border-radius-lg);
}

/* Toolbar */
.toolbar-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  margin-bottom: 32px;
  gap: 20px;
  flex-wrap: wrap;
  animation: fadeIn 0.4s ease-out;
}

.toolbar-left {
  display: flex;
  align-items: center;
}

.doc-info {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-info::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-emerald);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.divider {
  width: 1px;
  height: 24px;
  background-color: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-text-light);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, var(--color-emerald), #047857);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background-color: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: var(--color-danger);
}

.btn-danger:hover {
  background-color: var(--color-danger);
  color: white;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}

/* Upload Container & Dropzone */
.upload-container {
  padding: 12px;
  margin-bottom: 32px;
  transition: var(--transition-smooth);
}

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: calc(var(--border-radius-lg) - 4px);
  padding: 60px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  background: rgba(255, 255, 255, 0.01);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.03);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.05);
}

.drop-icon {
  font-size: 54px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

.dropzone h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

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

.file-formats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.format-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.red-icon { color: #f43f5e; }
.blue-icon { color: #0ea5e9; }

.privacy-note {
  font-size: 12px;
  color: var(--color-text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* Editor Workspace */
.editor-section {
  animation: fadeIn 0.5s ease-out;
}

.grid-header {
  margin-bottom: 24px;
}

.grid-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

/* Page Card Styles */
.page-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 380px;
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  user-select: none;
  cursor: grab;
}

.page-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.page-card.dragging {
  cursor: grabbing;
  opacity: 0.4;
  transform: scale(0.95);
  border: 2px dashed var(--color-primary);
  box-shadow: none;
}

.page-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 10;
}

.page-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.drag-handle {
  cursor: grab;
  color: var(--color-text-muted);
  font-size: 14px;
}

.btn-card-delete {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-smooth);
}

.btn-card-delete:hover {
  color: var(--color-danger);
}

/* Page Preview Area */
.page-preview-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.15);
  overflow: hidden;
  padding: 12px;
}

/* Wrapper that gets rotated & scaled */
.page-preview-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: var(--transition-spring);
}

/* Canvas/HTML nested pages inside preview wrapper */
.page-preview-wrapper canvas, 
.page-preview-wrapper img, 
.page-preview-wrapper .docx-page-slice {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  background-color: white;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: block;
}

/* Sliced CSS Viewport for DOCX pages */
.docx-page-slice {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  aspect-ratio: 0.707; /* A4 aspect ratio */
}

.docx-page-slice-content {
  position: absolute;
  left: 0;
  width: 794px; /* Render width */
  transform-origin: top left;
  background: white;
  color: black;
  box-shadow: none !important;
  border: none !important;
}

/* Card Control Panel */
.page-card-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  gap: 4px;
  z-index: 10;
}

.btn-card-ctrl {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--color-text-light);
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition-smooth);
}

.btn-card-ctrl:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: white;
}

.btn-card-ctrl.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--color-primary);
}

.btn-card-ctrl-danger:hover {
  background-color: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--color-danger);
}

.ctrl-spacer {
  width: 1px;
  height: 20px;
  background-color: rgba(255, 255, 255, 0.08);
  margin: 0 4px;
}

/* Processing Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.25s ease-out;
}

.overlay-card {
  width: 90%;
  max-width: 440px;
  padding: 40px 32px;
  text-align: center;
  border-radius: var(--border-radius-lg);
}

.spinner {
  font-size: 48px;
  color: var(--color-primary);
  margin-bottom: 24px;
  display: inline-block;
}

.overlay-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  margin-bottom: 8px;
}

.overlay-card p {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-purple));
  border-radius: 10px;
  transition: width 0.1s linear;
}

.progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-light);
}

/* Footer */
.app-footer {
  margin-top: auto;
  text-align: center;
  padding: 40px 0 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.app-footer p {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Responsive Overrides */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
  
  .security-badge {
    align-self: stretch;
    justify-content: center;
  }

  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .divider {
    display: none;
  }
}
