/* --- 1. Global Variables & Reset --- */
:root {
  /* AI Gradient Palette */
  --primary-gradient: linear-gradient(135deg, #4F46E5 0%, #9333EA 100%); /* Indigo -> Purple */
  --primary-glow: rgba(147, 51, 234, 0.5);
  
  --bg-body: #F3F4F6;       /* Light gray background */
  --bg-panel: #FFFFFF;      /* White panels */
  --bg-preview: #E5E7EB;    /* Darker gray for preview area */
  
  --text-main: #111827;
  --text-sub: #6B7280;
  --border: #E5E7EB;
  
  --sidebar-width: 420px;   /* Slightly wider for better inputs */
  --nav-height: 64px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-body);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent global scroll */
}

/* --- 2. Main Studio Layout --- */
.studio-container {
  display: flex;
  height: calc(100vh - var(--nav-height));
  width: 100%;
  overflow: hidden;
}

/* --- 3. Left Pane: Command Center --- */
.editor-pane {
  width: var(--sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative; /* Context for absolute footer */
  height: 100%;
  z-index: 20;
  box-shadow: 4px 0 24px rgba(0,0,0,0.04);
}

.pane-header {
  padding: 24px 28px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid transparent;
}
.pane-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.pane-header p { color: var(--text-sub); font-size: 0.9rem; }

/* The Scrollable Form Area */
.editor-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px;
  /* Add padding bottom to ensure content doesn't sit behind the floating button */
  padding-bottom: 120px; 
}

/* Inputs Styling */
.input-group { margin-bottom: 28px; }

.input-label {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 0.85rem; color: var(--text-main);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}

.upload-link { 
  color: #4F46E5; 
  font-size: 0.75rem; 
  text-decoration: none; 
  cursor: pointer; 
  font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.upload-link:hover { text-decoration: underline; }

textarea, .modern-select {
  width: 100%;
  padding: 14px;
  border: 2px solid #F3F4F6;
  border-radius: 12px;
  background: #F9FAFB;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-main);
  transition: all 0.2s ease;
}

textarea { min-height: 140px; resize: vertical; line-height: 1.6; }

/* Focus States */
textarea:focus, .modern-select:focus {
  background: #fff;
  border-color: #A855F7; /* Purple focus */
  outline: none;
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.1);
}

/* --- 4. THE MAGIC FOOTER (Sticky) --- */
.editor-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 28px;
  /* Gradient fade to make it look like it's floating */
  background: linear-gradient(to top, rgba(255,255,255,1) 70%, rgba(255,255,255,0));
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
}

.credits-display {
  align-self: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  background: #F3F4F6;
  padding: 4px 12px;
  border-radius: 20px;
  display: flex; align-items: center; gap: 6px;
}

/* The Gradient Button */
.btn-magic {
  position: relative;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: var(--primary-gradient);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 10px 25px -5px var(--primary-glow);
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.btn-magic:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px -10px var(--primary-glow);
}
.btn-magic:active { transform: scale(0.98); }

/* --- 5. Right Pane: Preview --- */
.preview-pane {
  flex: 1;
  background: var(--bg-preview);
  position: relative;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* Floating HUD (Head-Up Display) */
.preview-hud {
  position: absolute;
  top: 24px;
  left: 49.5%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 800px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px); /* Glass effect */
  padding: 10px 20px;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255,255,255,0.5);
  z-index: 50;
}

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

.ats-score-pill {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--text-main); font-size: 0.9rem;
}

.score-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  /* Default conic gradient */
  background: conic-gradient(#10B981 var(--score-deg, 0deg), #E5E7EB 0deg);
  display: flex; align-items: center; justify-content: center;
}
.score-circle.high {
  background: conic-gradient(#10B981 var(--score-deg, 0deg), #E5E7EB 0deg); /* Green for high */
}
.score-circle.medium {
  background: conic-gradient(#F59E0B var(--score-deg, 0deg), #E5E7EB 0deg); /* Orange for medium */
}
.score-circle.low {
  background: conic-gradient(#EF4444 var(--score-deg, 0deg), #E5E7EB 0deg); /* Red for low */
}
.score-inner { 
  width: 26px; height: 26px; 
  background: white; border-radius: 50%; 
  display: flex; align-items: center; justify-content: center; 
  font-size: 0.75rem; 
  color: black; /* Keep text black */
}

.btn-ghost {
  background: transparent; 
  border: 1px solid var(--border);
  padding: 8px 16px; 
  border-radius: 8px; 
  font-weight: 600; 
  font-size: 0.85rem;
  cursor: pointer; 
  display: flex; align-items: center; gap: 6px;
  color: var(--text-main); 
  transition: all 0.2s;
}
.btn-ghost:hover { background: #F3F4F6; border-color: #d1d5db; }

/* The Paper Area */
.preview-scroller {
  width: 100%; 
  height: 100%;
  overflow-y: auto;
  padding-top: 100px; /* Make space for HUD */
  padding-bottom: 120px;
  display:block;
  text-align: center;
}

.paper-a4 {
  width: 210mm;
  min-height: 297mm;
    height: auto; 
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  padding: 40px;
    margin: 0 auto 40px auto; 
    display: flow-root; 
    text-align: left; 
    word-wrap: break-word;
}

.empty-state{
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  color: var(--text-sub);
  font-size: 1rem;
}

/* Material Icon Alignment Fix */
.material-icons-round { vertical-align: middle; }

/* Mobile Response */
@media (max-width: 1000px) {
  .studio-container { flex-direction: column; overflow-y: auto; height: auto; }
  .editor-pane { width: 100%; height: auto; border-right: none; overflow: visible; }
  .editor-footer { position: relative; background: white; margin-top: 20px; }
  .preview-pane { height: 800px; }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  flex-direction: column;
  gap: 30px;
}

.loading-overlay.show {
  display: flex;
}

.spinner {
  width: 80px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Enhanced gradient spinner */
.spinner::before {
  content: '';
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(
    #4F46E5 0deg,
    #9333EA 90deg,
    #EC4899 180deg,
    #4F46E5 360deg
  );
  animation: spinnerRotate 2s linear infinite;
}

.spinner::after {
  content: '';
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
}

/* Loading text styles */
.loading-overlay p {
  color: white;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Loading tip/fact styles */
.loading-overlay .loading-tip {
  color: #E5E7EB;
  font-size: 14px;
  text-align: center;
  max-width: 400px;
  line-height: 1.6;
  font-style: italic;
  animation: fadeInOut 4s ease-in-out infinite;
}

.spinning {
  animation: spin 1s linear infinite !important;
}

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

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

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

.refine-bar-container {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  z-index: 60;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.refine-input-wrapper {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 40px rgba(0,0,0,0.1);
  border-radius: 50px; /* Pill shape */
  padding: 8px 8px 8px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.refine-cost-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #EFF6FF;
  color: #3B82F6;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid #BFDBFE;
}
.refine-cost-badge .material-icons-round { font-size: 14px; }

.refine-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  min-width: 0; /* Prevents overflow */
}
.refine-input::placeholder { color: #9CA3AF; }

.btn-refine-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}
.btn-refine-send:hover { transform: scale(1.05); }
.btn-refine-send:active { transform: scale(0.95); }


/* Add to existing CSS */

/* --- TABS --- */
.view-toggle-container {
    background: #F3F4F6;
    padding: 4px;
    border-radius: 12px;
    display: flex;
    gap: 4px;
}

.view-tab {
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.view-tab.active {
    background: white;
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.view-tab:hover:not(.active) {
    color: var(--text-main);
}

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 { font-size: 1.5rem; font-weight: 700; }

.modal-subtitle {
    color: var(--text-sub);
    margin-bottom: 24px;
}

.modern-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #F3F4F6;
    border-radius: 10px;
    margin-bottom: 10px;
}

.modern-textarea.short {
    min-height: 80px;
    height: 80px;
}

.text-gradient {
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-icon {
    background: none; border: none; cursor: pointer; color: var(--text-sub);
}


/* Improve Empty State */
.empty-state {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: var(--text-sub);
  text-align: center;
  padding: 40px;
  border: 2px dashed var(--border); /* Dashed border for "drop zone" feel */
  border-radius: 16px;
  background: #FAFAFA;
}

.empty-icon {
  font-size: 64px;
  color: #E5E7EB;
  background: white;
  padding: 20px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text-main);
  font-weight: 600;
}

/* Polish Inputs */
textarea {
  transition: all 0.2s ease, height 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

textarea:focus {
  background: white;
  border-color: #4F46E5; /* Indigo focus */
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Custom Scrollbar for a premium feel */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}