/* ============================================================
   style.css — Design System de ApuntesHub (Discord-inspired)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Variables / Tokens ─────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep:       #0e0e12;
  --bg-primary:    #1a1b1e;
  --bg-secondary:  #2b2d31;
  --bg-tertiary:   #313338;
  --bg-elevated:   #383a40;
  --bg-hover:      #404249;
  --bg-modal:      rgba(14, 14, 18, 0.85);

  /* Brand — Discord Blurple + Purple gradient */
  --accent:        #5865f2;
  --accent-hover:  #4752c4;
  --accent-light:  #7289da;
  --accent-dim:    rgba(88, 101, 242, 0.15);
  --accent-glow:   rgba(88, 101, 242, 0.35);
  --purple-bright: #9b59b6;
  --purple-deep:   #6c3483;

  /* Semantic */
  --success:       #23a55a;
  --success-dim:   rgba(35, 165, 90, 0.15);
  --danger:        #f23f43;
  --danger-dim:    rgba(242, 63, 67, 0.15);
  --warning:       #f0b232;
  --warning-dim:   rgba(240, 178, 50, 0.15);
  --info:          #00a8fc;

  /* Text */
  --text-primary:   #f2f3f5;
  --text-secondary: #b5bac1;
  --text-muted:     #80848e;
  --text-link:      #00a8fc;

  /* Typography */
  --font:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing scale */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.7);
  --shadow-accent: 0 8px 32px var(--accent-glow);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s ease;
  --t-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index scale */
  --z-base:    1;
  --z-dropdown: 100;
  --z-sticky:  200;
  --z-modal:   300;
  --z-toast:   400;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  transition: background var(--t-fast);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── Selection ──────────────────────────────────────────── */
::selection {
  background: var(--accent-dim);
  color: var(--text-primary);
}

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { color: var(--text-secondary); }

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-light); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent-light);
}

/* ─── Utilities ──────────────────────────────────────────── */
.hidden         { display: none !important; }
.invisible      { visibility: hidden; }
.text-muted     { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-accent    { color: var(--accent) !important; }
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--danger) !important; }
.text-warning   { color: var(--warning) !important; }
.text-center    { text-align: center; }
.text-sm        { font-size: 0.875rem; }
.text-xs        { font-size: 0.75rem; }
.font-semibold  { font-weight: 600; }
.font-bold      { font-weight: 700; }

.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* ─── Layout ─────────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ─── Header ─────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(26, 27, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  height: 64px;
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: var(--space-4);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.header__logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--purple-bright));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-accent);
  transition: transform var(--t-spring);
}

.header__logo:hover .header__logo-icon {
  transform: scale(1.1) rotate(-5deg);
}

.header__logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header__search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
  transition: color var(--t-fast);
}

.header__search-input {
  width: 100%;
  height: 40px;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  padding: 0 var(--space-4) 0 42px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--t-fast);
}

.header__search-input::placeholder { color: var(--text-muted); }
.header__search-input:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.header__search-input:focus + .header__search-icon,
.header__search:focus-within .header__search-icon {
  color: var(--accent);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ─── User Avatar ─────────────────────────────────────────── */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--accent);
  cursor: pointer;
  transition: transform var(--t-normal), box-shadow var(--t-normal);
}
.user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.user-avatar--placeholder {
  background: linear-gradient(135deg, var(--accent), var(--purple-bright));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user-info__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Filter Bar ─────────────────────────────────────────── */
.filters {
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: var(--space-4) 0;
  position: relative;
  z-index: 1000;
}

.filter-item {
  position: relative;
  z-index: 1000;
}

.filters__inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.filter-chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  touch-action: pan-x;
}

.filter-chips::-webkit-scrollbar {
  height: 4px;
}
.filter-chips::-webkit-scrollbar-track {
  background: transparent;
}
.filter-chips::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-normal);
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0 !important;
}

.filter-chip:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-light);
}

.filter-select {
  background: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 7px 32px 7px 12px;
  cursor: pointer;
  outline: none;
  max-width: min(320px, 80vw);
  text-overflow: ellipsis;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2380848e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--t-fast);
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.filter-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Sort controls */
.sort-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── Main Content ───────────────────────────────────────── */
.main {
  padding: var(--space-8) 0 var(--space-16);
  min-height: calc(100vh - 64px);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Notes Grid ─────────────────────────────────────────── */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: var(--space-5);
}

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-16) var(--space-4);
}

.empty-state__icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.6;
}

.empty-state__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.empty-state__text {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: var(--space-6);
}

/* ─── FAB (Floating Action Button) ──────────────────────── */
.fab {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  z-index: var(--z-dropdown);
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--accent), var(--purple-bright));
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), var(--shadow-accent);
  transition: all var(--t-spring);
}

.fab:hover {
  transform: scale(1.12) rotate(90deg);
  box-shadow: var(--shadow-xl), 0 0 40px var(--accent-glow);
}

.fab:active {
  transform: scale(0.95);
}

/* ─── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: var(--space-4) 0;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 var(--space-4); }
  .header__search { max-width: none; }
  .notes-grid { grid-template-columns: 1fr; }
  .header__logo-text { display: none; }
  .fab { bottom: var(--space-5); right: var(--space-5); }
  .filters-row { gap: var(--space-2) !important; }
  .filter-item { flex: 1 1 calc(50% - var(--space-2)) !important; min-width: 130px !important; }
  .section-header { flex-direction: row; align-items: center; }
}

@media (max-width: 480px) {
  .header__inner { gap: var(--space-2); }
  .filter-item { flex: 1 1 100% !important; }
  .filter-label { font-size: 0.78rem; }
  .filter-select { font-size: 0.82rem; padding: 6px 28px 6px 10px; }
  .sort-controls { margin-left: 0; width: 100%; margin-top: 4px; }
}
