/* Writer Studio / Admin Styling for Evolution Journal */
.admin-wrap { max-width: 1400px; margin: 0 auto; padding: 20px 30px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 25px; flex-wrap: wrap; gap: 15px; }
.admin-header .brand-group { display: flex; align-items: center; gap: 15px; }
.admin-header .admin-badge { font: 11px/1.8 monospace; letter-spacing: 1px; background: var(--green); color: var(--ink); padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line); }
.admin-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-btn { background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 8px 16px; border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 6px; }
.admin-btn:hover { background: var(--panel); border-color: var(--ink); }
.admin-btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.admin-btn.primary:hover { opacity: 0.9; }
.admin-btn.danger { background: #fdf2f0; color: #b73225; border-color: #f2beba; }
.admin-btn.danger:hover { background: #b73225; color: #ffffff; border-color: #b73225; }
.admin-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.editor-subbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--panel, #edf0e6); border: 1px solid var(--line); border-radius: 4px; margin-bottom: 6px; flex-wrap: wrap; gap: 10px; }
.editor-meta-info { display: flex; align-items: center; gap: 12px; }
.post-status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.post-status-badge .status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.post-status-badge.published { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.post-status-badge.published .status-dot { background: #2e7d32; box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2); }
.post-status-badge.unpublished { background: #f5f5f5; color: #616161; border: 1px solid #e0e0e0; }
.post-status-badge.unpublished .status-dot { background: #9e9e9e; }
.status-live-btn { font-size: 11px; color: #1b5e20; text-decoration: underline; margin-left: 6px; }
.status-live-btn:hover { color: #0d3813; }
.badge-status { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-status.published { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.badge-status.unpublished { background: #f5f5f5; color: #757575; border: 1px solid #e0e0e0; }

html[data-theme="dark"] .admin-btn.danger { background: #381f1c; color: #ff8a80; border-color: #5a2c27; }
html[data-theme="dark"] .admin-btn.danger:hover { background: #d32f2f; color: #ffffff; border-color: #d32f2f; }
html[data-theme="dark"] .post-status-badge.published { background: #1c3323; color: #a3e0b2; border-color: #2e5538; }
html[data-theme="dark"] .post-status-badge.published .status-dot { background: #4caf50; box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.25); }
html[data-theme="dark"] .post-status-badge.unpublished { background: #262c28; color: #a3af9f; border-color: #39483c; }
html[data-theme="dark"] .post-status-badge.unpublished .status-dot { background: #778078; }
html[data-theme="dark"] .status-live-btn { color: #a3e0b2; }
html[data-theme="dark"] .badge-status.published { background: #1c3323; color: #a3e0b2; border-color: #2e5538; }
html[data-theme="dark"] .badge-status.unpublished { background: #262c28; color: #a3af9f; border-color: #39483c; }

.status-bar { padding: 12px 18px; border-radius: 4px; font-size: 13px; margin-bottom: 20px; display: none; align-items: center; justify-content: space-between; }
.status-bar.info { background: #e8eddf; color: #233f35; border: 1px solid #dfe3d8; display: flex; }
.status-bar.success { background: #d7e8d5; color: #1e4620; border: 1px solid #b7d5b3; display: flex; }
.status-bar.error { background: #fbe6e2; color: #8a2717; border: 1px solid #f2beba; display: flex; }

.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
@media (max-width: 960px) { .editor-grid { grid-template-columns: 1fr; } }

.editor-pane { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; font-family: monospace; letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase; }
.field-group input, .field-group select, .field-group textarea { background: var(--bg); border: 1px solid var(--line); color: var(--ink); padding: 10px 12px; font-size: 14px; border-radius: 4px; outline: none; transition: border-color 0.15s; }
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { border-color: var(--ink); }

.field-group input#post-title { font: normal 22px/1.4 Georgia, "Songti SC", serif; padding: 12px 14px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.toolbar button { background: var(--bg); border: 1px solid var(--line); color: var(--ink); font-size: 12px; padding: 4px 9px; border-radius: 3px; cursor: pointer; }
.toolbar button:hover { background: var(--green); border-color: var(--ink); }

.editor-textarea { min-height: 520px; font: 15px/1.8 Menlo, Monaco, Consolas, "Courier New", monospace; padding: 16px; resize: vertical; tab-size: 2; border-radius: 4px; }
.editor-stats { display: flex; justify-content: space-between; font: 12px monospace; color: var(--muted); padding: 4px 2px; }

.preview-pane { border: 1px solid var(--line); border-radius: 4px; background: var(--bg); padding: 30px 40px; min-height: 700px; position: sticky; top: 20px; overflow-y: auto; max-height: calc(100vh - 50px); }
.preview-pane .preview-header-tag { display: flex; justify-content: space-between; font: 11px monospace; letter-spacing: 1px; color: var(--muted); border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 25px; }

/* Modal Styling */
.admin-modal { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 6px; padding: 28px; width: min(600px, calc(100% - 40px)); margin: 10vh auto; }
.admin-modal::backdrop { background: rgba(16, 35, 25, 0.6); backdrop-filter: blur(4px); }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 20px; }
.modal-header h3 { font: normal 20px Georgia, serif; margin: 0; }
.modal-body { display: flex; flex-direction: column; gap: 16px; font-size: 14px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.post-list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 8px; cursor: pointer; transition: background 0.15s; }
.post-list-item:hover { background: var(--panel); border-color: var(--ink); }

/* Gemini Import Box */
.gemini-import-box {
  background: #f2f5ec;
  border: 1px solid #dce2d4;
  border-radius: 6px;
  padding: 18px 22px;
  margin-bottom: 22px;
  transition: all 0.2s ease;
}
.gemini-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gemini-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.gemini-badge .sparkle {
  color: #b58022;
  font-size: 16px;
}
.gemini-badge .tag {
  background: #dfe6d2;
  color: #244333;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
}
.gemini-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin: 10px 0 14px;
}
.gemini-hint code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
}
.gemini-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.gemini-input-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.gemini-input-row input:focus {
  border-color: var(--ink);
}
.gemini-options-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 10px;
}
.gemini-key-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gemini-key-field input {
  width: 230px;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--ink);
}
.gemini-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 500;
}
.admin-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: adminSpin 0.8s linear infinite;
  display: inline-block;
}
@keyframes adminSpin {
  to { transform: rotate(360deg); }
}
.quiet-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
}
.quiet-btn:hover {
  color: var(--ink);
}

/* Tables and Math in Preview */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.article-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
}
.article-preview th,
.article-preview td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.article-preview th {
  background: var(--panel, #edf0e6);
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--line);
}
.article-preview tbody tr:last-child td {
  border-bottom: 0;
}
.article-preview tbody tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}
.math-display {
  margin: 24px 0;
  text-align: center;
  overflow-x: auto;
  padding: 10px 0;
}
.katex-display {
  margin: 20px 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
}
