/* ══════════════════════════════════════════════════════════════
   Folio — styles.css
   Design System: Refined Minimal · Warm Neutrals · Forest Accent
   ══════════════════════════════════════════════════════════════ */

/* ── CSS VARIABLES ── */
:root {
  --bg:           #fafaf8;
  --surface:      #ffffff;
  --border:       #e8e6e0;
  --text:         #1a1a18;
  --muted:        #8a8880;
  --accent:       #2d5a3d;
  --accent-light: #e8f0ea;
  --accent-hover: #234830;
  --danger:       #c0392b;
  --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --radius:       10px;
}

/* ── RESET ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── BASE ── */
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
}

.logo {
  padding: 0 22px 28px;
  border-bottom: 1px solid var(--border);
}

.logo h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.logo span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* ── Navigation ── */
.nav {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.nav-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--border);
  color: var(--muted);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 500;
}

.nav-item.active .nav-badge {
  background: var(--accent);
  color: white;
}

.sidebar-footer {
  padding: 16px 22px 0;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

/* ════════════════════════════════════════
   MAIN LAYOUT
════════════════════════════════════════ */
.main {
  margin-left: 220px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 20px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  font-weight: 400;
}

.page-title p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Sections ── */
.section          { display: none; }
.section.active   { display: block; }

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
}

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

.btn-ghost                { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover          { background: var(--bg); }

.btn-danger               { background: #fdf2f2; color: var(--danger); border: 1px solid #f5c6c6; }
.btn-danger:hover         { background: #fce8e8; }

.btn-sm                   { padding: 5px 10px; font-size: 12px; }

/* ════════════════════════════════════════
   UPLOAD ZONE
════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  margin-bottom: 24px;
}

.upload-zone:hover,
.upload-zone.drag {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone .upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone h3           { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.upload-zone p            { font-size: 12px; color: var(--muted); }

input[type=file]          { display: none; }

/* ════════════════════════════════════════
   FILE GRID & CARDS
════════════════════════════════════════ */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.file-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.file-card-preview {
  height: 130px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.file-card-preview canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-card-info    { padding: 10px 12px; }

.file-card-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.file-card-meta    { font-size: 11px; color: var(--muted); }

.file-card-actions {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

/* ════════════════════════════════════════
   NOTES
════════════════════════════════════════ */
.notes-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  height: calc(100vh - 160px);
}

/* Notes List */
.notes-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notes-list-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.note-item:hover          { background: var(--bg); }
.note-item.active         { background: var(--accent-light); }

.note-item-title          { font-size: 13px; font-weight: 500; margin-bottom: 3px; }

.note-item-preview {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-date           { font-size: 10px; color: var(--muted); margin-top: 4px; }

.notes-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Note Editor */
.note-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.note-editor-toolbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.note-title-input {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  border: none;
  outline: none;
  padding: 16px 20px 8px;
  width: 100%;
  color: var(--text);
  background: transparent;
}

.note-title-input::placeholder { color: var(--border); }

.note-body {
  flex: 1;
  padding: 8px 20px 20px;
  font-size: 14px;
  line-height: 1.7;
  border: none;
  outline: none;
  resize: none;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: transparent;
}

/* contenteditable placeholder */
#note-body:empty::before {
  content: attr(data-placeholder);
  color: #d0cec8;
  pointer-events: none;
}

.note-status { font-size: 11px; color: var(--muted); }

/* ════════════════════════════════════════
   EXCEL TABLE
════════════════════════════════════════ */
.excel-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 500px;
  margin-top: 16px;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.excel-table th {
  background: var(--bg);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.excel-table td {
  padding: 6px 12px;
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.excel-table tr:nth-child(even) td { background: #fafaf8; }

/* ════════════════════════════════════════
   MODALS
════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3  { font-size: 15px; font-weight: 500; }
.modal-body       { flex: 1; overflow: auto; padding: 0; }

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

/* PDF Viewer */
#pdf-viewer-canvas  { display: block; margin: 0 auto; max-width: 100%; }

.pdf-controls {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

/* ════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  animation: slideIn 0.25s ease;
  max-width: 280px;
}

.toast.success  { background: var(--accent); }
.toast.error    { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state .empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-state h3           { font-size: 16px; color: var(--text); margin-bottom: 6px; font-weight: 500; }
.empty-state p            { font-size: 13px; }

/* ════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 700px)
════════════════════════════════════════ */
@media (max-width: 700px) {
  .sidebar                          { width: 60px; }
  .sidebar .logo h1,
  .sidebar .logo span,
  .nav-item span,
  .nav-badge,
  .sidebar-footer                   { display: none; }
  .nav-item                         { justify-content: center; padding: 10px; }
  .main                             { margin-left: 60px; }
  .content                          { padding: 16px; }
  .notes-layout                     { grid-template-columns: 1fr; }
  .topbar                           { padding: 14px 16px; }
}
