/* ============================================================
   Arcana – Soulful Dashboard
   Dark parchment, gold foil, crimson accents.
   Fully responsive: mobile (≤480px) & tablet (≤768px)
   ============================================================ */

/* ---------- Core Palette ---------- */
:root {
  --color-bg: #f8f6f2;
  --color-bg-texture: #fefaf5;
  --color-surface: #ffffff;
  --color-surface-hover: #fefaf5;
  --color-surface-elevated: #fffdf9;
  --color-border: #e5dfd7;
  --color-border-light: #eee9e2;
  --color-text: #2c2824;
  --color-text-secondary: #5c554b;
  --color-text-muted: #958e84;
  --color-primary: #b45309;
  --color-primary-soft: #e7bc8e;
  --color-primary-glow: rgba(180,83,9,0.12);
  --color-accent: #9b2c2c;
  --color-accent-glow: rgba(155,44,44,0.2);
  --color-danger: #c2410c;
  --color-success: #2b6e4f;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.05);
  --shadow-md: 0 12px 24px -12px rgba(0,0,0,0.12);
  --shadow-lg: 0 20px 32px -12px rgba(0,0,0,0.18);
  --shadow-gold: 0 0 0 2px rgba(180,83,9,0.2);
  --transition: 0.2s ease;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 25% 40%, rgba(0,0,0,0.01) 2%, transparent 2.5%);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: #f0ede8;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: #cbbfae;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ---------- Top Navigation ---------- */
.top-nav {
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  flex-shrink: 0;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #a4511f, #7e3a12);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-link {
  background: transparent;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 40px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover {
  background: #f3efe9;
  color: var(--color-primary);
}
.nav-link.active {
  background: #fff2e6;
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
  overflow-x: auto;
}

.view {
  display: none;
}
.view.active {
  display: block;
  animation: fadeSlide 0.25s ease-out;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px);}
  to { opacity: 1; transform: translateY(0);}
}

/* ---------- Cards & Widgets ---------- */
.widget, .card, .stat-card, .panel-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.widget:hover, .card:hover, .stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-primary-soft);
  box-shadow: var(--shadow-md);
}
.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px dashed var(--color-border-light);
  padding-bottom: 0.5rem;
}
.widget-title {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

/* ---------- Dashboard Grid ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}

/* ---------- Buttons ---------- */
.back-btn, .btn, .add-btn, .explore-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 40px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.back-btn:hover, .btn:hover, .add-btn:hover {
  background: var(--color-accent);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}
.btn-outline:hover {
  background: rgba(180,83,9,0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ---------- Forms & Filters ---------- */
.filters {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: center;
}
.filters select, .filters input {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 40px;
  background: white;
  font-size: 0.85rem;
}
.filters select:focus, .filters input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ---------- Tables ---------- */
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
}
th, td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--color-border-light);
  text-align: left;
  font-size: 0.85rem;
}
th {
  background: #faf8f4;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}
.done {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* ---------- Task Items ---------- */
.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border-light);
}
.task-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid #cfc5b8;
  background: white;
  appearance: none;
  cursor: pointer;
}
.task-checkbox:checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.priority-high, .priority-medium, .priority-low {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 30px;
  font-weight: 600;
}
.priority-high { background: #fee2e2; color: #b91c1c; }
.priority-medium { background: #fff0db; color: #b45309; }
.priority-low { background: #e6f3ec; color: #2b6e4f; }

/* ---------- Progress Bar ---------- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: #eae3da;
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #cc7b3a);
  border-radius: 6px;
}

/* ---------- Calendar Overrides (FullCalendar) ---------- */
.fc .fc-daygrid-day-frame {
  min-height: 110px !important;
  padding: 4px !important;
  cursor: pointer;
}
.fc .fc-daygrid-day-frame:hover {
  background: rgba(180,83,9,0.05);
}
.fc-event {
  border-radius: 6px !important;
  font-size: 0.7rem !important;
  padding: 2px 4px !important;
  font-weight: 500;
}
.fc .fc-daygrid-more-link {
  background: var(--color-primary-soft);
  color: #5c3a1e;
  border-radius: 20px;
  padding: 2px 6px;
  font-size: 0.65rem;
}

/* ---------- Learning Specific ---------- */
.skill-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.skill-card-horizontal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  cursor: pointer;
  border: 1px solid var(--color-border);
}
.large-card-grid, .subchapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.subchapter-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  overflow: hidden;
  cursor: pointer;
}
.card-cover {
  height: 100px;
  background: linear-gradient(135deg, #f3ede6, #e8dfd5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.admin-icons {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.admin-icons button {
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 0.7rem;
}

/* ---------- Library ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.book-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  overflow: hidden;
  cursor: pointer;
}
.book-cover {
  height: 140px;
  background: #f6f2ec;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--color-primary);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.status-reading { background: var(--color-accent); }
.status-read { background: var(--color-success); }
.status-want { background: #c2410c; }

/* ---------- Projects Page (ClickUp style) ---------- */
.pm-container {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}
.project-sidebar {
  flex: 1.2;
  min-width: 220px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1rem;
  align-self: start;
}
.project-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}
.project-list li {
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}
.project-list li.active {
  background: rgba(180,83,9,0.1);
  border-left: 3px solid var(--color-primary);
}
.main-area {
  flex: 3;
  min-width: 300px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1rem;
}
.profile-card {
  background: var(--color-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
}
.profile-cover {
  width: 80px;
  height: 80px;
  background: #e8dfd5;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.edit-project-icon {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}
.tab-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}
.tab-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.8rem;
  border-radius: 30px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--color-primary);
  color: white;
}
.task-table {
  width: 100%;
  border-collapse: collapse;
}
.task-table th, .task-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border-light);
}

/* ---------- Modal ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.show {
  display: flex;
}
.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.form-group {
  margin-bottom: 0.8rem;
}
.form-group label {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.modal-buttons {
  display: flex;
  gap: 0.8rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE NAVBAR & LAYOUT (fixes overflow on mobile)
   ============================================================ */
@media (max-width: 768px) {
  .top-nav {
    flex-direction: column;
    height: auto;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .logo {
    text-align: center;
    width: 100%;
  }
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
  }
  .nav-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }
  .main-content {
    padding: 1rem;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .pm-container {
    flex-direction: column;
  }
  .project-sidebar {
    width: 100%;
  }
  .fc .fc-daygrid-day-frame {
    min-height: 90px !important;
  }
  .large-card-grid, .subchapter-grid, .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 480px) {
  .nav-link {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
  .fc .fc-daygrid-day-frame {
    min-height: 65px !important;
  }
  .fc-event {
    font-size: 0.6rem !important;
  }
  .profile-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .profile-cover {
    width: 60px;
    height: 60px;
  }
  .large-card-grid, .subchapter-grid, .book-grid {
    grid-template-columns: 1fr;
  }
  .task-table th, .task-table td {
    padding: 0.3rem;
    font-size: 0.7rem;
  }
  .modal-content {
    width: 95%;
    padding: 1rem;
  }
}