/* ── FOLIO — main.css ── */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e8e6e0;
  --text: #1a1a18;
  --muted: #8a8880;
  --accent: #2d5a3d;
  --accent-light: #e8f0ea;
  --accent-hover: #234830;
  --danger: #c0392b;
  --danger-light: #fdf2f2;
  --danger-border: #f5c6c6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
}

/* ── DARK MODE ── */
body.dark {
  --bg: #111210;
  --surface: #1a1c1a;
  --border: #2e302e;
  --text: #e8e6e0;
  --muted: #6a6860;
  --accent: #4a9060;
  --accent-light: #1e2e22;
  --accent-hover: #5aa870;
  --danger: #e05545;
  --danger-light: #2a1818;
  --danger-border: #5a2020;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  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;
  z-index: 20;
  transition: background 0.25s, border-color 0.25s;
}
.logo { padding: 0 22px 24px; 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: 10px; color: var(--muted); font-weight: 300; letter-spacing: 1px; text-transform: uppercase; }

.nav { padding: 14px 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: background 0.15s, color 0.15s;
  border: none; background: none; width: 100%; text-align: left;
  font-family: 'DM Sans', sans-serif;
}
.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; flex-shrink: 0; }

.nav-badge {
  margin-left: auto; background: var(--border); color: var(--muted);
  font-size: 10px; padding: 1px 7px; border-radius: 20px; font-weight: 600;
}
.nav-item.active .nav-badge { background: var(--accent); color: white; }

.sidebar-footer {
  padding: 14px 22px 0; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); line-height: 1.6;
}
.dark-toggle {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 12px; font-family: 'DM Sans', sans-serif;
  cursor: pointer; width: 100%; margin-top: 10px; transition: background 0.15s;
}
.dark-toggle:hover { background: var(--accent-light); color: var(--accent); }

/* ── MAIN ── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  padding: 18px 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; transition: background 0.25s, border-color 0.25s;
}
.page-title h2 { font-family: 'DM Serif Display', serif; font-size: 20px; font-weight: 400; line-height: 1.2; }
.page-title p { font-size: 12px; color: var(--muted); margin-top: 3px; }

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

/* ── SECTIONS ── */
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 24px;
  text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s;
  background: var(--surface); margin-bottom: 24px; user-select: none;
}
.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 ── */
.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, background 0.25s;
}
.file-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }

.file-card-preview {
  height: 130px; background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 48px; cursor: pointer;
  overflow: hidden; position: relative;
}
.file-card-preview canvas, .file-card-preview img {
  width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0;
}
.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; flex-wrap: wrap; }

/* ── EDITOR LAYOUT ── */
.editor-layout {
  display: grid; grid-template-columns: 260px 1fr; gap: 20px;
  height: calc(100vh - 130px); min-height: 400px;
}
.file-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-y: auto; display: flex; flex-direction: column;
}
.file-list-header {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap;
  font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.search-input {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 11px; outline: none; font-family: 'DM Sans', sans-serif; width: 90px;
  background: var(--bg); color: var(--text); transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }

.list-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }
.list-item.active { background: var(--accent-light); }
.list-item-title { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.list-item-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-date { font-size: 10px; color: var(--muted); margin-top: 4px; }
.list-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; flex: 1; display: flex; align-items: center; justify-content: center; }

.editor-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; transition: background 0.25s;
}
.editor-toolbar {
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 42px;
}
.toolbar-btn { min-width: 32px; }
.toolbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.toolbar-select { cursor: pointer; background: var(--surface); color: var(--text); }
.save-status { font-size: 11px; color: var(--muted); white-space: nowrap; }

.editor-title {
  font-family: 'DM Serif Display', serif; font-size: 20px; border: none; outline: none;
  padding: 16px 20px 8px; width: 100%; color: var(--text); background: transparent;
  border-bottom: 1px solid var(--border);
}
.editor-title::placeholder { color: var(--muted); opacity: 0.4; }

.editor-body {
  flex: 1; padding: 14px 20px 20px; font-size: 14px; line-height: 1.75; border: none;
  outline: none; overflow-y: auto; font-family: 'DM Sans', sans-serif; color: var(--text); background: transparent;
}
.editor-body:empty::before { content: attr(data-placeholder); color: var(--muted); opacity: 0.4; pointer-events: none; }

.word-body h1 { font-family: 'DM Serif Display', serif; font-size: 26px; margin: 16px 0 8px; }
.word-body h2 { font-size: 19px; font-weight: 600; margin: 14px 0 6px; }
.word-body h3 { font-size: 15px; font-weight: 600; margin: 10px 0 4px; }
.word-body ul, .word-body ol { padding-left: 24px; margin: 8px 0; }
.word-body li { margin-bottom: 4px; }
.word-body p { margin-bottom: 8px; }

/* ── DASHBOARD ── */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  transition: box-shadow 0.2s, transform 0.2s, background 0.25s; cursor: pointer;
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.stat-icon {
  font-size: 28px; width: 50px; height: 50px; background: var(--accent-light);
  border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-value { font-family: 'DM Serif Display', serif; font-size: 30px; line-height: 1; color: var(--accent); margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

.storage-bar-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px;
}
.storage-bar-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; }
.storage-bar-bg { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.storage-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.6s ease; min-width: 2px; }

.dashboard-recent { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dashboard-recent-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.8px; text-transform: uppercase;
}
.recent-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--bg); }
.recent-item-icon { font-size: 22px; flex-shrink: 0; }
.recent-item-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.recent-item-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.dashboard-empty { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── SUBTITLE ── */
.subtitle-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 20px;
  height: calc(100vh - 130px); min-height: 400px;
}
.subtitle-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; transition: background 0.25s;
}
.subtitle-panel-header {
  padding: 10px 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; flex-shrink: 0;
  background: var(--surface); position: sticky; top: 0; z-index: 1;
}
.subtitle-list { flex: 1; overflow-y: auto; }

.sub-item {
  border-bottom: 1px solid var(--border); padding: 10px 14px; cursor: pointer;
  transition: background 0.15s; display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start;
}
.sub-item:hover { background: var(--bg); }
.sub-item.active { background: var(--accent-light); }
.sub-item-num { font-size: 11px; color: var(--muted); font-weight: 600; padding-top: 2px; text-align: center; }
.sub-item-time { font-size: 10px; color: var(--accent); font-weight: 500; margin-bottom: 3px; font-family: monospace; }
.sub-item-text { font-size: 12px; color: var(--text); line-height: 1.4; }

.subtitle-detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; transition: background 0.25s;
}
.subtitle-detail-top { padding: 14px 16px; border-bottom: 1px solid var(--border); flex: 1; overflow-y: auto; }
.subtitle-detail-top h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px; }

.sub-time-row { display: grid; grid-template-columns: 1fr 24px 1fr; gap: 6px; align-items: center; margin-bottom: 12px; }
.sub-time-input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: monospace; background: var(--bg); color: var(--text);
  outline: none; width: 100%; text-align: center; transition: border-color 0.15s;
}
.sub-time-input:focus { border-color: var(--accent); }
.sub-time-sep { font-size: 14px; color: var(--muted); text-align: center; }

.sub-text-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text);
  outline: none; resize: vertical; min-height: 80px; line-height: 1.6; transition: border-color 0.15s;
}
.sub-text-input:focus { border-color: var(--accent); }

.sub-actions-row { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; flex-wrap: wrap; }
.sub-shift-section { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg); }
.sub-shift-section h4 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.sub-shift-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-shift-input {
  width: 80px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: 'DM Sans', sans-serif; background: var(--surface);
  color: var(--text); outline: none; text-align: center;
}
.sub-convert-section { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg); }
.sub-convert-section h4 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.sub-convert-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.select-format {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: 'DM Sans', sans-serif; background: var(--surface);
  color: var(--text); outline: none; cursor: pointer;
}

/* ── 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; }
