/* ============================================================
   Garcha Music Institute Portal - Custom Styles
   Mobile-first, fully responsive
   ============================================================ */

:root {
  --primary:       #8B1A1A;
  --primary-dark:  #5c0f0f;
  --primary-light: rgba(139,26,26,0.12);
  --accent:        #D4AF37;
  --accent-light:  #f5e48a;
  --bg:            #f5f6fa;
  --sidebar-bg:    #1a0a0a;
  --sidebar-text:  #f0d9d9;
  --sidebar-hover: rgba(212,175,55,0.15);
  --card-shadow:   0 2px 16px rgba(139,26,26,0.10);
  --border-radius: 14px;
  --font-main:     'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-width: 260px;
  --topbar-h:      60px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-main);
  background: var(--bg);
  color: #2d2d2d;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, #2d0a0a 50%, #1a0505 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '♪ ♫ ♩ ♬ ♭ ♮ ♯';
  position: absolute;
  top: 8%;
  left: 2%;
  font-size: 2rem;
  color: rgba(212,175,55,0.07);
  letter-spacing: 1.5rem;
  white-space: nowrap;
  transform: rotate(-15deg);
  user-select: none;
  pointer-events: none;
}
.login-page::after {
  content: '♪ ♫ ♩ ♬ ♭ ♮ ♯';
  position: absolute;
  bottom: 8%;
  right: 2%;
  font-size: 2rem;
  color: rgba(212,175,55,0.07);
  letter-spacing: 1.5rem;
  white-space: nowrap;
  transform: rotate(15deg);
  user-select: none;
  pointer-events: none;
}
.login-card {
  background: rgba(255,255,255,0.97);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 440px;
  animation: slideUp 0.5s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-logo {
  width: 80px; height: 80px;
  object-fit: contain; border-radius: 50%;
  border: 3px solid var(--accent);
  padding: 4px; background: #fff;
}
.login-title { color: var(--primary); font-weight: 700; font-size: 1.4rem; margin-bottom: 0.2rem; }
.login-subtitle { color: #888; font-size: 0.83rem; }
.role-tabs .nav-link {
  color: var(--primary); border: 2px solid var(--primary);
  border-radius: 8px; font-weight: 600;
  padding: 0.45rem 1.2rem; margin: 0 3px;
  transition: all 0.2s; font-size: 0.88rem;
}
.role-tabs .nav-link.active,
.role-tabs .nav-link:hover { background: var(--primary); color: #fff; }
.btn-login {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; border: none; border-radius: 10px;
  padding: 0.75rem; font-weight: 600; font-size: 1rem;
  width: 100%; transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(139,26,26,0.4);
  touch-action: manipulation;
}
.btn-login:hover,
.btn-login:focus { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(139,26,26,0.5); color: #fff; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 0.2rem rgba(139,26,26,0.2); }
.login-footer { font-size: 0.78rem; color: #aaa; }
.login-footer a { color: var(--accent); }

/* ============================================================
   App Shell Layout
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform 0.3s ease;
  overflow: hidden;
}
.sidebar-brand {
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(212,175,55,0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand img {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid var(--accent);
  object-fit: contain; background: #fff; padding: 2px;
}
.sidebar-brand-text .name { font-weight: 700; font-size: 0.88rem; color: #fff; }
.sidebar-brand-text .role { font-size: 0.7rem; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-user {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-user-avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%; object-fit: cover; border: 2px solid var(--accent);
}
.sidebar-avatar-initials {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid var(--accent);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.sidebar-user-info .uname { font-size: 0.83rem; color: #fff; font-weight: 600; line-height: 1.2; }
.sidebar-user-info .uid { font-size: 0.7rem; color: #999; }
.sidebar-nav {
  flex: 1;
  padding: 0.4rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* JS in scripts.php sets explicit height as fallback for all browsers */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.3); border-radius: 3px; }
.sidebar-section-label {
  font-size: 0.62rem; color: rgba(212,175,55,0.6);
  text-transform: uppercase; letter-spacing: 1.5px;
  padding: 0.75rem 1rem 0.25rem; font-weight: 600;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 1rem;
  color: var(--sidebar-text);
  font-size: 0.86rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-link:hover, .sidebar-link.active {
  background: var(--sidebar-hover);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar-link i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto; background: var(--accent); color: #1a0a0a;
  font-size: 0.62rem; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}
.sidebar-footer { padding: 0.85rem 1rem; border-top: 1px solid rgba(212,175,55,0.15); flex-shrink: 0; }
.btn-logout {
  width: 100%; background: rgba(220,53,69,0.15);
  color: #ff6b6b; border: 1px solid rgba(220,53,69,0.3);
  border-radius: 8px; padding: 0.5rem; font-size: 0.83rem;
  font-weight: 600; transition: all 0.2s; display: block;
  text-align: center; cursor: pointer;
}
.btn-logout:hover, .btn-logout:focus { background: rgba(220,53,69,0.3); color: #fff; }

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1040;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Topbar */
.topbar {
  background: #fff;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 900;
  gap: 8px;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--primary); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-date { font-size: 0.75rem; color: #888; white-space: nowrap; }
.btn-sidebar-toggle {
  display: none;
  background: none; border: none;
  color: var(--primary); font-size: 1.4rem;
  padding: 4px; line-height: 1;
  cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.content-area { padding: 1.25rem; flex: 1; }

/* ============================================================
   Page Header
   ============================================================ */
.page-header { margin-bottom: 1.25rem; }
.page-header h2 { font-weight: 700; color: var(--primary); font-size: 1.25rem; margin: 0; }
.page-header p  { color: #888; font-size: 0.82rem; margin: 0.2rem 0 0; }

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 1.1rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid rgba(139,26,26,0.07);
  height: 100%;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 30px rgba(139,26,26,0.15); }
.stat-card .icon {
  width: 50px; height: 50px; flex-shrink: 0;
  border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 1.4rem;
}
.stat-card .icon.maroon { background: rgba(139,26,26,0.12); color: var(--primary); }
.stat-card .icon.gold    { background: rgba(212,175,55,0.15); color: #b8860b; }
.stat-card .icon.green   { background: rgba(40,167,69,0.12);  color: #28a745; }
.stat-card .icon.blue    { background: rgba(0,123,255,0.12);  color: #007bff; }
.stat-card .icon.orange  { background: rgba(255,152,0,0.15);  color: #ff9800; }
.stat-card .icon.red     { background: rgba(220,53,69,0.12);  color: #dc3545; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: #1a1a1a; line-height: 1; }
.stat-card .label { font-size: 0.75rem; color: #888; font-weight: 500; }
.stat-card .change { font-size: 0.7rem; color: #28a745; font-weight: 600; }

/* ============================================================
   Content Cards
   ============================================================ */
.content-card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(139,26,26,0.06);
  overflow: hidden;
}
.content-card .card-header-custom {
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid rgba(139,26,26,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: rgba(139,26,26,0.02);
}
.content-card .card-header-custom h5 { font-weight: 700; color: var(--primary); margin: 0; font-size: 0.95rem; }
.content-card .card-body-custom { padding: 1rem 1.2rem; }

/* ============================================================
   Tables (responsive wrapper)
   ============================================================ */
.table-responsive-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-custom { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 500px; }
.table-custom thead th {
  background: var(--primary); color: #fff;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.65rem 0.9rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
.table-custom thead th:first-child { border-radius: 8px 0 0 0; }
.table-custom thead th:last-child  { border-radius: 0 8px 0 0; }
.table-custom tbody tr { transition: background 0.15s; }
.table-custom tbody tr:hover { background: rgba(139,26,26,0.04); }
.table-custom tbody td {
  padding: 0.65rem 0.9rem; font-size: 0.84rem;
  border-bottom: 1px solid #f0f0f0; vertical-align: middle;
}

/* ============================================================
   Badges & Status
   ============================================================ */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.status-active    { background: rgba(40,167,69,0.12);  color: #1a7a3a; }
.status-inactive  { background: rgba(220,53,69,0.12);  color: #c82333; }
.status-present   { background: rgba(40,167,69,0.12);  color: #1a7a3a; }
.status-absent    { background: rgba(220,53,69,0.12);  color: #c82333; }
.status-late      { background: rgba(255,152,0,0.15);  color: #cc7a00; }
.status-leave     { background: rgba(13,110,253,0.12); color: #0854c1; }
.status-paid      { background: rgba(40,167,69,0.12);  color: #1a7a3a; }
.status-unpaid    { background: rgba(220,53,69,0.12);  color: #c82333; }
.status-overdue   { background: rgba(139,26,26,0.15);  color: #8b1a1a; font-weight: 600; }
.status-partial   { background: rgba(255,152,0,0.15);  color: #cc7a00; }
.status-pending   { background: rgba(108,117,125,0.12);color: #495057; }
.status-approved  { background: rgba(40,167,69,0.12);  color: #1a7a3a; }
.status-rejected  { background: rgba(220,53,69,0.12);  color: #c82333; }

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none; border-radius: 8px;
  padding: 0.45rem 1rem; font-size: 0.85rem; font-weight: 600;
  transition: all 0.2s; box-shadow: 0 3px 10px rgba(139,26,26,0.3);
  cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.btn-primary-custom:hover,
.btn-primary-custom:focus { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(139,26,26,0.4); color: #fff; }
.btn-accent-custom {
  background: linear-gradient(135deg, var(--accent), #b8860b);
  color: #1a0a0a; border: none; border-radius: 8px;
  padding: 0.45rem 1rem; font-size: 0.85rem; font-weight: 700;
  transition: all 0.2s; cursor: pointer; touch-action: manipulation;
}
.btn-accent-custom:hover,
.btn-accent-custom:focus { transform: translateY(-1px); color: #1a0a0a; }

/* ============================================================
   Forms
   ============================================================ */
.form-label-custom { font-size: 0.8rem; font-weight: 600; color: #555; margin-bottom: 0.3rem; display: block; }
.form-control, .form-select {
  border: 1.5px solid #e0e0e0; border-radius: 8px;
  padding: 0.55rem 0.9rem; font-size: 0.88rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139,26,26,0.12);
  outline: none;
}
.input-group-text { background: rgba(139,26,26,0.07); border-color: #e0e0e0; color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ============================================================
   Attendance Grid
   ============================================================ */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 5px;
}
.att-day {
  width: 36px; height: 36px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; cursor: default;
}
.att-present { background: rgba(40,167,69,0.15); color: #1a7a3a; }
.att-absent  { background: rgba(220,53,69,0.15); color: #c82333; }
.att-late    { background: rgba(255,152,0,0.15); color: #cc7a00; }
.att-leave   { background: rgba(13,110,253,0.12); color: #0854c1; font-weight: 600; }
.att-none    { background: #f5f5f5; color: #ccc; }

/* ============================================================
   Progress Ring
   ============================================================ */
.progress-ring-wrap { position: relative; width: 84px; height: 84px; }
.progress-ring-wrap svg { transform: rotate(-90deg); }
.progress-ring-wrap .percent-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem; color: var(--primary);
}

/* ============================================================
   Message Inbox
   ============================================================ */
.message-item {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
  cursor: pointer;
}
.message-item:hover { background: rgba(139,26,26,0.04); }
.message-item.unread { border-left: 3px solid var(--accent); background: rgba(212,175,55,0.05); }
.message-item .msg-subject { font-weight: 600; font-size: 0.88rem; color: #1a1a1a; }
.message-item .msg-preview {
  font-size: 0.78rem; color: #888;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.message-item .msg-time { font-size: 0.7rem; color: #bbb; }

/* ============================================================
   Leave Cards
   ============================================================ */
.leave-card {
  border-left: 4px solid var(--accent); padding: 1rem;
  border-radius: 8px; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07); margin-bottom: 1rem;
}
.leave-card.approved { border-left-color: #28a745; }
.leave-card.rejected { border-left-color: #dc3545; }

/* ============================================================
   Animations
   ============================================================ */
.fade-in { animation: fadeIn 0.4s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Misc utilities
   ============================================================ */
.divider { border-top: 1px solid rgba(139,26,26,0.1); margin: 1rem 0; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-md { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); flex-shrink: 0; }
.avatar-lg { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); }
.text-primary-custom { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.bg-primary-custom { background: var(--primary) !important; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #aaa; }
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; color: #ddd; display: block; }
.search-box { position: relative; }
.search-box input { padding-left: 2.2rem; }
.search-box i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: #aaa; pointer-events: none; }
.gap-2 { gap: 0.5rem; }
.action-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Responsive — Tablet (≤991px)
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1050;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; width: 100%; }
  .btn-sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .topbar-date { display: none; }
}

/* ============================================================
   Responsive — Mobile (≤767px)
   ============================================================ */
@media (max-width: 767.98px) {
  :root { --topbar-h: 54px; }

  .content-area { padding: 0.85rem; }

  /* Login */
  .login-card { padding: 1.5rem 1.1rem; border-radius: 16px; }
  .login-page::before, .login-page::after { display: none; }
  .login-logo { width: 65px; height: 65px; }
  .login-title { font-size: 1.2rem; }

  /* Page header */
  .page-header h2 { font-size: 1.1rem; }

  /* Stat cards — 2 per row on mobile */
  .stat-card { padding: 0.9rem; gap: 10px; }
  .stat-card .icon { width: 42px; height: 42px; font-size: 1.2rem; border-radius: 10px; }
  .stat-card .value { font-size: 1.35rem; }
  .stat-card .label { font-size: 0.7rem; }

  /* Card headers stack */
  .content-card .card-header-custom { flex-direction: column; align-items: flex-start; }

  /* Tables always scroll horizontally */
  .table-custom { min-width: 460px; }
  .table-custom thead th,
  .table-custom tbody td { padding: 0.55rem 0.7rem; font-size: 0.78rem; }

  /* Attendance grid smaller cells */
  .attendance-grid { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 4px; }
  .att-day { width: 32px; height: 32px; font-size: 0.68rem; }

  /* Action buttons full-width groups */
  .action-btns { flex-direction: column; }
  .action-btns .btn-primary-custom,
  .action-btns .btn-accent-custom { width: 100%; text-align: center; }

  /* Avatar sizes */
  .avatar-lg { width: 70px; height: 70px; }

  /* Topbar */
  .topbar { padding: 0 0.85rem; }
  .topbar-title { font-size: 0.9rem; }
}

/* ============================================================
   Responsive — Small mobile (≤480px)
   ============================================================ */
@media (max-width: 480px) {
  .content-area { padding: 0.65rem; }
  .stat-card .value { font-size: 1.2rem; }
  .role-tabs .nav-link { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
  .content-card .card-body-custom { padding: 0.75rem 0.9rem; }
  .page-header h2 { font-size: 1rem; }
  .progress-ring-wrap { width: 70px; height: 70px; }
  .progress-ring-wrap .percent-text { font-size: 0.82rem; }
}

/* ============================================================
   Bootstrap override helpers
   ============================================================ */
.btn { touch-action: manipulation; }
.modal-content { border-radius: 14px; }
.modal-header { background: rgba(139,26,26,0.04); border-bottom: 1px solid rgba(139,26,26,0.1); }
.modal-title { color: var(--primary); font-weight: 700; font-size: 1rem; }
.badge { font-size: 0.7rem; }

/* Ensure Bootstrap table inside content card scrolls on mobile */
.content-card .table-responsive { border-radius: 0; }
.table thead th { white-space: nowrap; }

/* Fix: prevent horizontal overflow on all pages */
.row { margin-left: 0; margin-right: 0; }
.row > * { padding-left: 0.5rem; padding-right: 0.5rem; }
@media (max-width: 767.98px) {
  .row { margin-left: -0.4rem; margin-right: -0.4rem; }
  .row > * { padding-left: 0.4rem; padding-right: 0.4rem; }
}
