:root {
  --bg-color: #0a0a0a;
  --card-bg: #121212;
  --border-color: #222222;
  --text-main: #ededed;
  --text-muted: #888888;
  --accent: #0070f3;
  --accent-hover: #0056b3;
  --danger: #ff453a;
  --success: #32d74b;
  --warning: #eab308;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.view { min-height: 100vh; }
.center-content { display: flex; align-items: center; justify-content: center; }

h1, h2, h3 { font-weight: 600; margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.w-full { width: 100%; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-8 { margin-top: 2rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.container { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem; }

/* Navbar */
.navbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: #0d0d0d;
  gap: 1rem;
}
.nav-brand { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }
.nav-tabs { display: flex; gap: 0.4rem; }
.nav-link {
  background: transparent; border: none; color: var(--text-muted);
  padding: 0.45rem 0.8rem; font-size: 0.85rem; cursor: pointer; border-radius: 6px;
  transition: 0.2s; white-space: nowrap; font-weight: 500;
}
.nav-link:hover { color: var(--text-main); }
.nav-link.active { color: var(--text-main); background: #222; }
.nav-user { display: flex; align-items: center; gap: 0.75rem; }

/* Buttons & Inputs */
.btn {
  padding: 0.5rem 1rem; border-radius: 6px; font-weight: 500;
  cursor: pointer; border: none; font-size: 0.9rem; transition: 0.2s;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--border-color); }
.btn-action { background: transparent; border: none; cursor: pointer; padding: 0.2rem 0.5rem; font-size: 0.85rem; }
.btn-action-edit { color: var(--accent); margin-right: 0.5rem; }
.btn-action-edit:hover { text-decoration: underline; }
.btn-action-delete { color: var(--danger); }
.btn-action-delete:hover { text-decoration: underline; }

.input-group { margin-bottom: 1rem; }
.input-group label { display: block; margin-bottom: 0.4rem; font-size: 0.9rem; color: var(--text-muted); }
input, select {
  width: 100%; padding: 0.6rem; border-radius: 6px;
  background: var(--bg-color); border: 1px solid var(--border-color);
  color: var(--text-main); font-family: var(--font); outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

/* Datetime Fix */
input[type="datetime-local"],
input[type="date"] {
  color-scheme: dark;
  cursor: pointer;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.85;
  padding: 4px;
}

/* History Filters */
.filter-grid { display: grid; grid-template-columns: 2fr 1.5fr 1.5fr auto; gap: 1rem; align-items: flex-end; }
.filter-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.history-summary { display: flex; align-items: center; font-size: 0.95rem; }

/* Dashboard Grids */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; gap: 1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.stats-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stats-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }

.stat-value { font-size: 2rem; font-weight: bold; margin: 0.5rem 0; }
.progress-bar { width: 100%; height: 6px; background: var(--border-color); border-radius: 3px; overflow: hidden; margin-top: 0.5rem; }
.progress-fill { height: 100%; background: var(--success); width: 0%; transition: width 0.5s ease; }
.stat-subtext { margin-top: 0.5rem; font-size: 0.8rem; }

/* Table */
.table-container { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; text-align: left; min-width: 500px; }
th, td { padding: 1rem; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
tr:last-child td { border-bottom: none; }

/* Mini Charts */
.bar-chart-container { display: flex; align-items: flex-end; height: 160px; gap: 8px; padding-top: 20px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.3s ease; }
.bar-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }
.bar-value { font-size: 0.75rem; color: var(--text-main); margin-bottom: 4px; }

.dist-item { margin-bottom: 0.85rem; }
.dist-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.3rem; }
.dist-track { height: 6px; background: var(--border-color); border-radius: 3px; overflow: hidden; }
.dist-bar { height: 100%; background: #3b82f6; border-radius: 3px; }

/* Settings Subject Management */
.subject-add-form { display: flex; gap: 0.75rem; }
.subject-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.subject-chip {
  display: flex; align-items: center; gap: 0.5rem;
  background: #1a1a1a; border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem; border-radius: 20px; font-size: 0.85rem;
}
.btn-delete-chip {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.btn-delete-chip:hover { color: var(--danger); }

/* Calendar Styles */
.calendar-nav-controls { display: flex; align-items: center; gap: 0.75rem; }
.calendar-month-title { font-weight: 600; font-size: 1.05rem; min-width: 130px; text-align: center; }
.calendar-legend { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-muted); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.3rem; }

.marker { font-weight: bold; font-size: 0.95rem; line-height: 1; }
.marker-completed { color: var(--success); }
.marker-partial { color: var(--warning); }
.marker-none { color: #555555; }

.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; color: var(--text-muted); font-size: 0.8rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-cell {
  background: #161616; border: 1px solid var(--border-color);
  border-radius: 6px; min-height: 58px; padding: 4px;
  cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; justify-content: space-between;
}
.calendar-cell:hover { border-color: var(--accent); background: #1c1c1c; }
.calendar-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.calendar-cell.today { border-color: var(--accent); }

.cell-date { font-size: 0.75rem; color: var(--text-muted); }
.cell-status { text-align: right; }
.cell-time { font-size: 0.65rem; color: var(--text-muted); }

/* Day View Modal */
.day-sessions-container { max-height: 350px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem; }
.day-session-card {
  background: #1a1a1a; border: 1px solid var(--border-color);
  border-radius: 6px; padding: 0.75rem 1rem;
}
.day-session-card-header { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 500; margin-bottom: 0.25rem; }

/* Modal General */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 1rem;
}
.modal-content { width: 100%; max-width: 480px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 1.5rem; }

#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast { background: var(--card-bg); border: 1px solid var(--border-color); padding: 0.85rem 1rem; border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 0.85rem; animation: slideIn 0.2s ease-out; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.login-card, .setup-card { width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 2rem; }

/* ========================================================= */
/*              MOBILE SPECIFIC OPTIMIZATIONS (< 768px)      */
/* ========================================================= */

@media (max-width: 768px) {
  .container { padding: 1.25rem 0.85rem; }
  
  /* Navbar redesign for mobile */
  .navbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .nav-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  /* Horizontal Scrollable Tabs */
  .nav-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 0.3rem;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs { -ms-overflow-style: none; scrollbar-width: none; }

  .nav-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
    background: #161616;
    border: 1px solid var(--border-color);
    border-radius: 20px;
  }
  .nav-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
  }

  /* Typography scale-down */
  h1 { font-size: 1.5rem; line-height: 1.25; }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }
  .page-header .btn { width: 100%; }

  .card { padding: 1.15rem; }
  .stat-value { font-size: 1.7rem; }
  
  /* Forms */
  .grid-2 { grid-template-columns: 1fr; gap: 0.5rem; }
  .filter-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .filter-actions { width: 100%; justify-content: stretch; }
  .filter-actions .btn { flex: 1; }

  /* Calendar */
  .calendar-nav-controls { width: 100%; justify-content: space-between; margin-top: 0.5rem; }
  .calendar-cell { min-height: 50px; padding: 2px; }
  .cell-date { font-size: 0.7rem; }
  .cell-time { display: none; } /* মোবাইলে অতিরিক্ত টেক্সট হাইড করে ক্লিন রাখা */

  /* Table padding */
  th, td { padding: 0.75rem 0.6rem; font-size: 0.82rem; }
}