/* style.css - Journal Matrix v3 (Global Standard) */
/* EMERGENCY FIX: Ensure loading overlay is NEVER visible on page load */
#loading-overlay {
  display: none !important;
}

:root {
  --cream: #fdf6e3;
  --brown: #5c4b37;
  --light-brown: #8b7355;
  --white: #ffffff;
  --gray: #f8f6f2;
  --dark-gray: #333;
  --border: #dcdcdc;
  --shadow: rgba(0,0,0,0.1);
  --primary: #5c4b37;
  --secondary: #8b7355;
  --success: #2e7d32;
  --warning: #ed6c02;
  --error: #d32f2f;
  --info: #1976d2;
}

.theme-dark {
  --cream: #2d2a26;
  --brown: #d4c8b0;
  --light-brown: #b8a99a;
  --white: #1e1c19;
  --gray: #2a2825;
  --dark-gray: #e0e0e0;
  --border: #444;
  --shadow: rgba(0,0,0,0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* TYPOGRAPHY - ACADEMIC STANDARD */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Georgia', 'Times New Roman', serif;
  background-color: var(--cream);
  color: var(--dark-gray);
  transition: background-color 0.3s, color 0.3s;
  line-height: 1.6;
  font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 16px;
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }

p, label {
  margin-bottom: 8px;
  font-size: 16px;
}

/* VISIBILITY */
.hidden { display: none !important; }
.view { display: none; }
.view.active { display: block; }

/* BUTTONS - CONSISTENT SYSTEM */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: #4a3c2d;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 75, 55, 0.25);
}

.btn-secondary {
  background: var(--gray);
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}

/* FORM ELEMENTS */
.form-select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  font-size: 16px;
  color: var(--dark-gray);
}

.form-select:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

/* CHECKBOXES */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 16px;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* AUTH SCREEN */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 24px;
  padding: 20px;
  text-align: center;
}

.logo-svg {
  width: 120px;
  height: 120px;
}

.auth-container h2 {
  font-size: 32px;
  color: var(--primary);
  margin: 10px 0;
}

.subtitle {
  font-size: 18px;
  color: var(--light-brown);
  margin-bottom: 8px;
}

.auth-note {
  color: var(--light-brown);
  font-size: 0.95em;
  max-width: 500px;
  line-height: 1.5;
}

/* LAYOUT */
#main-app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 280px;
  background: var(--white);
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.logo-svg.small {
  width: 60px;
  height: 60px;
  margin: 0 auto 24px;
}

.nav-btn {
  width: 100%;
  padding: 16px 20px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: var(--dark-gray);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
  font-size: 16px;
}

.nav-icon {
  font-size: 20px;
  min-width: 24px;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--gray);
  color: var(--primary);
  transform: translateX(4px);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.theme-label {
  font-weight: 600;
  color: var(--dark-gray);
}

#logout-btn {
  margin-top: auto;
  padding: 14px;
  font-size: 16px;
}

.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.header h1 {
  color: var(--primary);
  font-size: 28px;
  margin: 0;
}

.back-btn {
  background: none;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
}

.back-btn:hover {
  background: var(--gray);
  transform: translateX(-4px);
}

/* DASHBOARD CARDS */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
}

.manuscript-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 16px var(--shadow);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.manuscript-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border-color: var(--primary);
}

.manuscript-card h3 {
  margin-bottom: 16px;
  color: var(--primary);
  font-size: 19px;
  flex-grow: 0;
}

.status {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 24px;
  font-size: 0.9em;
  font-weight: 600;
  margin: 8px 0;
  text-align: center;
}

.status.pending { 
  background: #fff8e1; 
  color: #5c4b37; 
  border: 1px solid #ffecb3;
}
.status.submitted { 
  background: #e8f5e9; 
  color: #2e7d32; 
  border: 1px solid #c8e6c9;
}

.continue-review {
  margin-top: auto;
  padding: 12px;
  width: 100%;
  font-size: 16px;
}

/* REVIEW FORM - ACADEMIC STANDARD */
.review-form {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 32px;
}

.form-section {
  background: var(--white);
  padding: 28px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.form-section h3 {
  margin-bottom: 20px;
  color: var(--primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* NUMERIC RATINGS (NOT STARS) */
.rating-select {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-size: 16px;
  color: var(--dark-gray);
  margin-top: 8px;
}

.rating-select:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

/* LARGE COMMENT BOXES */
.comment-textarea {
  width: 100%;
  min-height: 140px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
  margin-top: 8px;
}

.comment-textarea:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.export-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* AUTO-REVIEWER */
.ai-guidelines-card {
  margin-bottom: 32px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.ai-guidelines-card h2 {
  margin-bottom: 16px;
  color: var(--primary);
}

.guidelines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.guideline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--gray);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.guideline-item:hover {
  background: var(--white);
  transform: translateX(4px);
}

.guideline-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 36px;
  background: var(--gray);
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--white);
  transform: scale(1.02);
}

.upload-icon {
  font-size: 56px;
  margin-bottom: 20px;
  color: var(--primary);
}

.upload-zone h3 {
  margin-bottom: 16px;
  color: var(--primary);
}

.upload-link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

#manuscript-file {
  display: none;
}

/* AUTO-REVIEW REPORT */
#auto-review-result {
  animation: fadeIn 0.4s ease;
}

.report-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.report-meta {
  display: flex;
  justify-content: space-between;
  color: var(--light-brown);
  font-size: 0.95em;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.report-seal {
  background: var(--primary);
  color: white;
  padding: 6px 16px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 14px;
}

.ai-findings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.finding-card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.finding-error { border-left: 4px solid var(--error); }
.finding-warning { border-left: 4px solid var(--warning); }
.finding-success { border-left: 4px solid var(--success); }

.finding-card h3 {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.finding-card ul {
  list-style: none;
  padding-left: 0;
}

.finding-card li {
  margin-bottom: 12px;
  padding-left: 28px;
  position: relative;
  line-height: 1.5;
}

.finding-card li::before {
  position: absolute;
  left: 0;
  top: 2px;
  font-size: 18px;
}

.finding-error li::before { content: "⚠️"; }
.finding-warning li::before { content: "📝"; }
.finding-success li::before { content: "✅"; }

.overall-assessment {
  margin-bottom: 32px;
}

.assessment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-top: 20px;
}

.assessment-item {
  text-align: center;
}

.assessment-item label {
  display: block;
  color: var(--light-brown);
  font-size: 14px;
  margin-bottom: 8px;
  font-weight: 500;
}

.score-display, .recommendation-display, .confidence-display {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.recommendation-display {
  color: var(--info);
}

.confidence-display {
  color: var(--success);
}

/* ANALYTICS */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.metric-card h3 {
  color: var(--light-brown);
  font-size: 16px;
  margin-bottom: 12px;
  font-weight: 600;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.analytics-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.chart-container {
  background: var(--white);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chart-container h3 {
  margin-bottom: 16px;
  color: var(--primary);
}

/* HELP PAGE STYLES */
.help-container {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.7;
}

.help-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
}

.help-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.help-card h3 {
  color: var(--primary);
  margin-bottom: 12px;
}

/* SETTINGS */
.setting-row {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-row label {
  font-weight: 600;
  color: var(--dark-gray);
}

.premium-card {
  border-left: 4px solid var(--primary);
}

.premium-features {
  list-style: none;
  padding-left: 0;
  margin: 20px 0;
}

.premium-features li {
  margin-bottom: 12px;
  padding-left: 28px;
  position: relative;
  color: var(--dark-gray);
}

.premium-features li::before {
  content: "✅";
  position: absolute;
  left: 0;
  top: 2px;
  color: var(--success);
  font-weight: bold;
}

/* CHARTS */
.chart-container canvas {
  width: 100% !important;
  height: 300px !important;
}

/* NOTIFICATIONS */
.notification-center {
  position: fixed;
  top: 28px;
  right: 28px;
  z-index: 1000;
}

.notification {
  background: var(--primary);
  color: white;
  padding: 18px 28px;
  margin-bottom: 16px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 4.7s forwards;
  max-width: 360px;
  word-wrap: break-word;
}

.notification.success { background: var(--success); }
.notification.error { background: var(--error); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* LOADING OVERLAY */
#loading-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  color: white;
  font-size: 22px;
  font-weight: 600;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255,255,255,0.3);
  border-top: 6px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar {
    width: 70px;
    padding: 20px 10px;
  }
  .logo-svg.small {
    width: 45px;
    height: 45px;
    margin: 0 auto 20px;
  }
  .nav-btn span:not(.nav-icon) { 
    display: none; 
  }
  .nav-icon {
    font-size: 22px;
    min-width: auto;
  }
  .header {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions, .export-group {
    flex-direction: column;
  }
  .btn, .form-select, .comment-textarea {
    width: 100%;
  }
  .main-content {
    padding: 20px;
  }
  .card-grid, .ai-findings, .assessment-grid, .metrics-grid {
    grid-template-columns: 1fr;
  }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
}

/* ACCESSIBILITY */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* HIGH CONTRAST MODE */
.high-contrast {
  --cream: #000000;
  --white: #ffffff;
  --dark-gray: #ffffff;
  --border: #ffffff;
  --primary: #ffffff;
  --secondary: #cccccc;
}

.high-contrast .manuscript-card,
.high-contrast .form-section,
.high-contrast .card {
  border: 2px solid white;
}