/* =========================================
   NOTAS APP — Notebook Aesthetic
   ========================================= */

:root {
  --paper: #fef9e7;
  --paper-dark: #fdf3c0;
  --line-color: #d4c89a;
  --ink: #2c1810;
  --ink-light: #6b5344;
  --ink-muted: #9e8a7a;
  --sidebar-bg: #2c1810;
  --sidebar-text: #f5ead8;
  --sidebar-muted: #9e8a7a;
  --sidebar-hover: #3d261a;
  --sidebar-active: #5c3d2e;
  --accent: #c0392b;
  --accent2: #27ae60;
  --accent-hover: #a93226;
  --shadow: rgba(44, 24, 16, 0.15);
  --border: #d4c89a;
  --font-hand: 'Caveat', cursive;
  --font-body: 'Lato', sans-serif;
  --line-h: 36px;
}

[data-dark="true"] {
  --paper: #1a1a2e;
  --paper-dark: #16213e;
  --line-color: #2d3561;
  --ink: #e8e0d5;
  --ink-light: #b0a898;
  --ink-muted: #7a7060;
  --sidebar-bg: #0f0f1a;
  --sidebar-text: #e8e0d5;
  --sidebar-muted: #7a7060;
  --sidebar-hover: #1a1a2e;
  --sidebar-active: #2d3561;
  --border: #2d3561;
  --shadow: rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

.hidden { display: none !important; }

/* =========================================
   LOGIN
   ========================================= */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
  z-index: 1000;
}

.login-card {
  background: var(--paper);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--accent), #e67e22, #f1c40f);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-icon { font-size: 48px; display: block; margin-bottom: 12px; }

.login-logo h1 {
  font-family: var(--font-hand);
  font-size: 2rem;
  color: var(--ink);
  font-weight: 700;
}

.login-logo p {
  font-size: 0.8rem;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-light);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-error {
  background: #ffeaea;
  color: var(--accent);
  border: 1px solid #ffcccc;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s, transform 0.1s;
}

.btn-login:hover { background: var(--accent-hover); }
.btn-login:active { transform: scale(0.98); }

/* =========================================
   APP LAYOUT
   ========================================= */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 10;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-hand);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--sidebar-text);
  margin-bottom: 14px;
}

.btn-new {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}

.btn-new:hover { background: var(--accent-hover); }
.btn-new span { font-size: 1.2rem; }

.search-box {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.search-box input {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--sidebar-text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 8px 12px;
}

.search-box input::placeholder { color: var(--sidebar-muted); }
.search-box input:focus { outline: none; border-color: var(--accent); }

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.notes-list::-webkit-scrollbar { width: 4px; }
.notes-list::-webkit-scrollbar-track { background: transparent; }
.notes-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.note-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.note-item:hover { background: var(--sidebar-hover); }
.note-item.active { background: var(--sidebar-active); border-left: 3px solid var(--accent); }

.note-item-title {
  font-family: var(--font-hand);
  font-size: 1rem;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-date {
  font-size: 0.7rem;
  color: var(--sidebar-muted);
  margin-top: 3px;
}

.note-item-preview {
  font-size: 0.78rem;
  color: var(--sidebar-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--sidebar-muted);
  font-size: 0.85rem;
}

.notes-loading {
  padding: 24px 16px;
  text-align: center;
  color: var(--sidebar-muted);
  font-size: 0.85rem;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* Disk Widget */
.disk-widget {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}

.disk-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  margin-bottom: 6px;
}

.disk-label span:last-child {
  font-weight: 700;
  color: var(--sidebar-text);
}

.disk-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.disk-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #27ae60, #f39c12, #e74c3c);
  transition: width 0.8s ease;
  width: 0%;
}

.disk-detail {
  font-size: 0.7rem;
  color: var(--sidebar-muted);
}

.sidebar-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-icon {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--sidebar-text);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover { background: rgba(255,255,255,0.18); }

/* =========================================
   EDITOR AREA
   ========================================= */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
}

.no-note-selected {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-muted);
}

.no-note-icon { font-size: 64px; opacity: 0.3; }

.no-note-selected h2 {
  font-family: var(--font-hand);
  font-size: 1.6rem;
  color: var(--ink-light);
}

.no-note-selected p { font-size: 0.9rem; }

.btn-new-lg {
  margin-top: 8px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-new-lg:hover { background: var(--accent-hover); }

.note-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--paper-dark);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover { background: var(--paper-dark); }
.btn-action.btn-danger { border-color: var(--accent); color: var(--accent); }
.btn-action.btn-danger:hover { background: var(--accent); color: #fff; }

.save-status {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
  transition: opacity 0.3s;
}

.save-status.saving { color: #e67e22; }
.save-status.saved { color: var(--accent2); }

/* =========================================
   NOTEBOOK PAPER STYLE
   ========================================= */
.note-paper {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px 48px;
  background: var(--paper);
  position: relative;
}

/* Lined paper background */
.note-paper::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(var(--line-h) - 1px),
    var(--line-color) calc(var(--line-h) - 1px),
    var(--line-color) var(--line-h)
  );
  background-position: 0 72px;
  pointer-events: none;
  opacity: 0.5;
}

/* Red margin line */
.note-paper::after {
  content: '';
  position: absolute;
  top: 0; left: 88px; bottom: 0;
  width: 2px;
  background: rgba(192, 57, 43, 0.25);
  pointer-events: none;
}

.note-title-input {
  font-family: var(--font-hand);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  line-height: var(--line-h);
  padding: 0;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.note-title-input::placeholder { color: var(--ink-muted); font-weight: 400; }

.note-meta {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-bottom: 20px;
  font-style: italic;
  position: relative;
  z-index: 1;
}

/* Quill overrides for notebook feel */
#quill-editor {
  position: relative;
  z-index: 1;
}

.ql-toolbar {
  background: rgba(255,255,255,0.6) !important;
  border-radius: 8px 8px 0 0 !important;
  border-color: var(--border) !important;
  backdrop-filter: blur(4px);
}

.ql-container {
  border-color: var(--border) !important;
  border-radius: 0 0 8px 8px !important;
  font-family: var(--font-hand) !important;
  font-size: 1.1rem !important;
  color: var(--ink) !important;
  background: transparent !important;
  min-height: 200px;
}

.ql-editor {
  line-height: var(--line-h) !important;
  padding: 16px 16px !important;
  background: transparent !important;
  min-height: 200px;
}

.ql-editor.ql-blank::before {
  color: var(--ink-muted) !important;
  font-style: italic !important;
  font-family: var(--font-hand) !important;
}

/* =========================================
   FILES SECTION
   ========================================= */
.files-section {
  margin-top: 32px;
  position: relative;
  z-index: 1;
}

.files-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
  font-family: var(--font-hand);
  font-size: 1rem;
  color: var(--ink-light);
  font-weight: 600;
}

.btn-upload {
  padding: 4px 12px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: opacity 0.2s;
}

.btn-upload:hover { opacity: 0.8; }

.files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.file-item {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  max-width: 220px;
}

.file-item-image img {
  width: 220px;
  height: 160px;
  object-fit: cover;
  display: block;
}

.file-item-audio {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

.file-item-audio audio { width: 100%; }

.file-item-name {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 8px;
}

.file-item-delete {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(192, 57, 43, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.file-item:hover .file-item-delete { opacity: 1; }

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

.modal-card {
  background: var(--paper);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}

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

.modal-header h2 {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.modal-close:hover { background: var(--border); }

.modal-body {
  padding: 24px;
}

.modal-body h3 {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  color: var(--ink-light);
  margin-bottom: 16px;
}

.cfg-msg {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.cfg-msg.success { background: #eafaf1; color: #27ae60; border: 1px solid #a9dfbf; }
.cfg-msg.error { background: #ffeaea; color: var(--accent); border: 1px solid #ffcccc; }

/* =========================================
   MOBILE SIDEBAR TOGGLE
   ========================================= */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border: none;
  width: 40px; height: 40px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }

  .note-paper { padding: 20px 20px 32px; }
  .note-paper::after { left: 60px; }

  .editor-topbar { padding: 8px 16px; }
}

/* =========================================
   SCROLLBAR
   ========================================= */
.note-paper::-webkit-scrollbar { width: 6px; }
.note-paper::-webkit-scrollbar-track { background: var(--paper-dark); }
.note-paper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* =========================================
   DARK MODE ADJUSTMENTS
   ========================================= */
[data-dark="true"] .form-group input {
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  border-color: var(--border);
}

[data-dark="true"] .ql-toolbar {
  background: rgba(255,255,255,0.05) !important;
}

[data-dark="true"] .ql-toolbar .ql-stroke { stroke: var(--ink) !important; }
[data-dark="true"] .ql-toolbar .ql-fill { fill: var(--ink) !important; }
[data-dark="true"] .ql-toolbar .ql-picker { color: var(--ink) !important; }
[data-dark="true"] .ql-container { background: rgba(255,255,255,0.02) !important; }
[data-dark="true"] .file-item { background: rgba(255,255,255,0.05); }
[data-dark="true"] .btn-action { background: rgba(255,255,255,0.05); color: var(--ink); border-color: var(--border); }
[data-dark="true"] .btn-action:hover { background: rgba(255,255,255,0.1); }
[data-dark="true"] .modal-card { background: #1a1a2e; }
[data-dark="true"] .modal-header { background: #16213e; }
[data-dark="true"] .btn-upload { background: rgba(255,255,255,0.1); }
[data-dark="true"] .login-card { background: #1a1a2e; }
[data-dark="true"] .form-group input { background: rgba(255,255,255,0.06); color: #e8e0d5; }
