/* ══════════════════════════════════════════════════════════════
   CUADERNOS.CSS — Repositorio de Cuadernos Colaborativos
   ReaderPDF · Design System v1.0
══════════════════════════════════════════════════════════════ */

:root {
  --primary: #195B8B;
  --primary-dark: #134a73;
  --accent: #10b981;
  --accent-dark: #059669;
  --danger: #ef4444;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(25,91,139,0.35);
  --radius: 14px;
  --shadow: 0 2px 16px rgba(15,23,42,0.08);
  --shadow-lg: 0 8px 32px rgba(15,23,42,0.14);
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── LAYOUT ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
  z-index: 100;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 16px;
}

.sidebar-brand img { height: 32px; width: auto; border-radius: 8px; }
.sidebar-brand span { font-size: 15px; font-weight: 700; color: #fff; }

.btn-new-nb {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(25,91,139,0.3);
}

.btn-new-nb:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(25,91,139,0.4);
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--sidebar-text);
  transition: var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  color: var(--sidebar-muted);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 22px;
  text-align: center;
}

.nav-item.active .nav-badge { background: rgba(255,255,255,0.2); color: #fff; }

.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--sidebar-text);
  transition: var(--transition);
  margin-bottom: 1px;
}

.folder-item:hover { background: var(--sidebar-hover); }
.folder-item.active { background: var(--sidebar-active); color: #fff; }
.folder-item-icon { font-size: 15px; }
.folder-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-new-folder {
  background: none;
  border: 1px dashed rgba(255,255,255,0.15);
  color: var(--sidebar-muted);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  margin-top: 4px;
}

.btn-new-folder:hover { border-color: rgba(255,255,255,0.3); color: var(--sidebar-text); }

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.15);
}

.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-muted); }

.btn-logout {
  background: none;
  border: none;
  color: var(--sidebar-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
}

.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.search-bar {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-bar input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.search-bar input:focus { border-color: var(--primary); background: #fff; }
.search-bar input::placeholder { color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.view-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border);
}

.view-btn {
  background: none;
  border: none;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: var(--transition);
  display: flex;
}

.view-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ── NOTEBOOK GRID ── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.nb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.nb-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 32px; }

/* ── NOTEBOOK CARD ── */
.nb-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.nb-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.nb-card-color-bar {
  height: 4px;
  width: 100%;
}

.nb-card-body { padding: 14px 16px; flex: 1; }
.nb-card-icon { font-size: 22px; margin-bottom: 8px; }
.nb-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nb-card-preview {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.nb-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(240,244,248,0.5);
}

.nb-card-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.nb-card-date {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
}

.nb-badges { display: flex; gap: 4px; flex-wrap: wrap; }

.badge-shared {
  background: rgba(16,185,129,0.1);
  color: #059669;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid rgba(16,185,129,0.25);
}

.badge-collab {
  background: rgba(99,102,241,0.1);
  color: #6366f1;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid rgba(99,102,241,0.25);
}

.badge-view-only {
  background: rgba(245,158,11,0.1);
  color: #d97706;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid rgba(245,158,11,0.25);
}

.nb-card-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  transition: var(--transition);
}

.nb-card:hover .nb-card-menu { opacity: 1; }

.btn-card-menu {
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  box-shadow: var(--shadow);
  transition: var(--transition);
  backdrop-filter: blur(4px);
}

.btn-card-menu:hover { color: var(--text); background: #fff; }

.card-menu-popup {
  position: absolute;
  top: 36px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
  display: none;
}

.card-menu-popup.open { display: block; }

.card-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.card-menu-item:hover { background: var(--bg); }
.card-menu-item.danger { color: var(--danger); }
.card-menu-item.danger:hover { background: rgba(239,68,68,0.06); }

/* List view card */
.nb-list-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.nb-list-card:hover { border-color: var(--primary); background: rgba(25,91,139,0.02); }

.nb-list-icon { font-size: 20px; flex-shrink: 0; }
.nb-list-info { flex: 1; overflow: hidden; }
.nb-list-title { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-list-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nb-list-badges { display: flex; gap: 4px; margin-right: 8px; }
.nb-list-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon { font-size: 60px; margin-bottom: 16px; opacity: 0.6; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-desc { font-size: 14px; color: var(--muted); max-width: 340px; line-height: 1.6; margin-bottom: 24px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(25,91,139,0.25);
  font-family: inherit;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(25,91,139,0.35); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ── SKELETON LOADER ── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #e8edf2 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.skeleton-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 180px;
}

/* ── SHARE MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: 18px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s ease;
}

@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.share-link-box {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.share-link-url {
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: monospace;
}

.btn-copy {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
}

.btn-copy:hover { background: var(--primary-dark); }
.btn-copy.copied { background: var(--accent); }

.permission-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.perm-option {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.perm-option.selected { border-color: var(--primary); background: rgba(25,91,139,0.05); }
.perm-option-icon { font-size: 20px; margin-bottom: 4px; }
.perm-option-label { font-size: 13px; font-weight: 600; color: var(--text); }
.perm-option-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

.modal-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px; display: block; }

.collab-list { display: flex; flex-direction: column; gap: 8px; max-height: 160px; overflow-y: auto; margin-bottom: 16px; }

.collab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
}

.collab-item img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.collab-item-name { flex: 1; font-size: 13px; font-weight: 500; }
.collab-item-role { font-size: 11px; color: var(--muted); }

/* ── SHARED NOTEBOOK BANNER ── */
.shared-banner {
  background: linear-gradient(135deg, rgba(25,91,139,0.08), rgba(16,185,129,0.08));
  border: 1px solid rgba(25,91,139,0.2);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.shared-banner-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.shared-banner-info { flex: 1; }
.shared-banner-title { font-size: 14px; font-weight: 700; color: var(--text); }
.shared-banner-sub { font-size: 12px; color: var(--muted); }

/* ── LOGIN PROMPT ── */
.login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 60px 24px;
  text-align: center;
}

.login-prompt-icon { font-size: 56px; margin-bottom: 16px; }
.login-prompt-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.login-prompt-desc { font-size: 14px; color: var(--muted); max-width: 380px; line-height: 1.6; margin-bottom: 28px; }

.btn-google-login {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 13px 28px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
  box-shadow: var(--shadow);
  font-family: inherit;
}

.btn-google-login:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.btn-google-login img { width: 22px; height: 22px; }

/* ── FOLDER MODAL ── */
.folder-modal-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: var(--transition);
  margin-bottom: 16px;
}

.folder-modal-input:focus { border-color: var(--primary); background: #fff; }

/* ── MIGRATE BANNER ── */
.migrate-banner {
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(25,91,139,0.08));
  border: 1.5px solid rgba(16,185,129,0.25);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.migrate-banner-icon { font-size: 28px; }
.migrate-banner-info { flex: 1; }
.migrate-banner-title { font-size: 14px; font-weight: 700; color: var(--text); }
.migrate-banner-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.migrate-banner-actions { display: flex; gap: 8px; }

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-accent:hover { background: var(--accent-dark); }
.btn-dismiss { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--muted); font-family: inherit; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { width: 220px; min-width: 220px; }
  .topbar { padding: 12px 16px; }
  .content-area { padding: 16px; }
  .nb-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
}

@media (max-width: 600px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; height: auto; flex-direction: row; overflow-x: auto; }
  .sidebar-header { padding: 12px; border-bottom: none; border-right: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
  .sidebar-nav { display: flex; flex-direction: row; padding: 8px; gap: 4px; }
  .nav-section-title { display: none; }
  .sidebar-user { flex-shrink: 0; padding: 8px 12px; border-top: none; border-left: 1px solid rgba(255,255,255,0.07); }
  .sidebar-user-info { display: none; }
  .nb-grid { grid-template-columns: 1fr 1fr; }
}
