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

:root {
  --primary: #6C63FF;
  --primary-light: #8B85FF;
  --primary-dark: #4A42D4;
  --secondary: #FF6584;
  --success: #2ED573;
  --warning: #FFA502;
  --danger: #FF4757;
  --bg: #F5F6FA;
  --bg-card: #FFFFFF;
  --text: #2F3542;
  --text-light: #747D8C;
  --border: #E8EAED;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #2F3542 0%, #1E2229 100%);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 100;
}

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

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon { font-size: 32px; }

.logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #6C63FF, #FF6584);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  -webkit-text-fill-color: rgba(255,255,255,0.6);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(108,99,255,0.3);
}

.nav-item i { width: 20px; text-align: center; font-size: 16px; }

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

.sidebar-footer p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.top-bar h2 {
  font-size: 22px;
  font-weight: 700;
}

.greeting {
  font-size: 15px;
  color: var(--text-light);
  font-weight: 500;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: default;
}

.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-info h3 { font-size: 26px; font-weight: 800; line-height: 1.2; }

.stat-info p { font-size: 14px; color: var(--text-light); margin: 0; }

/* Dashboard bottom section */
.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .dashboard-bottom { grid-template-columns: 1fr; }
}

.dashboard-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.dashboard-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-item, .recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.review-item:last-child, .recent-item:last-child { border-bottom: none; }

.review-item .title, .recent-item .title {
  font-weight: 600;
  font-size: 14px;
}

.review-item .meta, .recent-item .meta {
  font-size: 12px;
  color: var(--text-light);
}

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-light);
}

.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(108,99,255,0.3); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #26C46B; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #E8413F; }

.btn-warning { background: var(--warning); color: white; }

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}

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

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h3 { font-size: 18px; font-weight: 700; }

.card-body { padding: 24px; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  transition: var(--transition);
  background: var(--bg);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}

select.form-control { cursor: pointer; }

textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalSlideUp 0.3s ease;
}

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

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

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px;
  transition: var(--transition);
}

.modal-close:hover { color: var(--danger); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Subjects */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.subject-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border-top: 4px solid var(--primary);
  position: relative;
}

.subject-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }

.subject-icon { font-size: 36px; margin-bottom: 12px; }

.subject-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }

.subject-stats {
  font-size: 13px;
  color: var(--text-light);
}

.subject-actions {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
}

.subject-card:hover .subject-actions { opacity: 1; }

.subject-actions button {
  background: rgba(255,255,255,0.9);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}

.subject-actions button:hover { color: var(--primary); }

.add-subject-card {
  border: 2px dashed var(--border);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-light);
}

.add-subject-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(108,99,255,0.03);
}

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

.plans-filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 6px 16px;
  border: 2px solid var(--border);
  background: white;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.filter-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.plans-list { display: flex; flex-direction: column; gap: 12px; }

.plan-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: pointer;
}

.plan-item:hover { box-shadow: var(--shadow-hover); transform: translateX(-3px); }

.plan-color {
  width: 4px;
  height: 48px;
  border-radius: 4px;
  flex-shrink: 0;
}

.plan-info { flex: 1; }

.plan-title { font-size: 16px; font-weight: 700; }

.plan-meta {
  font-size: 13px;
  color: var(--text-light);
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.plan-progress {
  width: 120px;
  flex-shrink: 0;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: var(--transition);
}

.progress-text {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  text-align: center;
}

.plan-priority {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.priority-high { background: #FFE0E3; color: var(--danger); }
.priority-medium { background: #FFF3D6; color: var(--warning); }
.priority-low { background: #D6F5E0; color: var(--success); }

.plan-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: var(--transition);
}

.plan-item:hover .plan-actions { opacity: 1; }

.plan-actions button {
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
}

.plan-actions button:hover { background: var(--primary); color: white; }

/* Progress / Topics */
.topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.topic-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  background: white;
}

.topic-check:hover { border-color: var(--success); }

.topic-check.completed {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.topic-check.in-progress {
  border-color: var(--warning);
  background: var(--warning);
  color: white;
}

.topic-title {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
}

.topic-title.completed { text-decoration: line-through; color: var(--text-light); }

.topic-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
  transition: var(--transition);
  font-size: 13px;
}

.topic-actions button:hover { color: var(--danger); }

/* Review */
.review-list { display: flex; flex-direction: column; gap: 12px; }

.review-section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-section-title .count {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}

/* Summaries */
.summaries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.summary-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.summary-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.summary-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }

.summary-subject {
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 8px;
  font-weight: 500;
}

.summary-meta {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  gap: 12px;
}

.summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(108,99,255,0.03);
}

.upload-zone i { font-size: 40px; color: var(--text-light); margin-bottom: 12px; }

.upload-zone p { color: var(--text-light); font-size: 14px; }

/* Scrollbar */
.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-track { background: transparent; }
.page-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.page-content::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    right: -260px;
    top: 0;
    height: 100%;
  }

  .sidebar.open { right: 0; }

  .menu-toggle { display: block; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .form-row { grid-template-columns: 1fr; }

  .subjects-grid { grid-template-columns: repeat(2, 1fr); }

  .summaries-grid { grid-template-columns: 1fr; }

  .page-content { padding: 16px; }

  .top-bar { padding: 12px 16px; }

  .plans-filters { flex-wrap: wrap; }
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.badge-danger { background: var(--danger); color: white; }
.badge-warning { background: var(--warning); color: white; }
.badge-success { background: var(--success); color: white; }

/* Detail section for plan view */
.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-header .back-btn {
  background: var(--bg);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}

.detail-header .back-btn:hover { background: var(--primary); color: white; }

.detail-title { font-size: 24px; font-weight: 700; flex: 1; }

.add-topic-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.add-topic-row input { flex: 1; }

/* Subject filter in summaries */
.subject-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.subject-filter .filter-chip {
  padding: 6px 16px;
  border: 2px solid var(--border);
  background: white;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.subject-filter .filter-chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Study Sessions */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.session-item:last-child { border-bottom: none; }

.session-date { font-size: 13px; color: var(--text-light); }
.session-duration { font-weight: 700; color: var(--primary); }

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.loading i { font-size: 32px; margin-bottom: 12px; animation: spin 1s linear infinite; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
