:root {
  --primary: #1e3a8a;
  --primary-dark: #1e293b;
  --secondary: #f59e0b;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
}

.app-container {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #1e3a8a 0%, #1e293b 100%);
  color: white;
  padding: 0;
  box-shadow: var(--shadow-xl);
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  font-family: "Playfair Display", serif;
  font-size: 1.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--secondary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.sidebar-user {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.875rem;
}

.sidebar-nav {
  padding: 1.5rem 0;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}

.nav-item {
  padding: 0.875rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: var(--secondary);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: var(--secondary);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.25rem;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 2rem;
  background: var(--bg-main);
  min-height: 100vh;
}

.top-bar {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-title {
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.breadcrumb {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Dashboard Cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent);
}

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

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Content Cards */
.content-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-dark);
}

/* Buttons */
.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-family: "Poppins", sans-serif;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

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

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

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

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Table */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  width: 100%;
  position: relative;
}

.table-container::after {
  content: "← Scroll →";
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(30, 58, 138, 0.9);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  min-width: 600px;
}

thead {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  color: white;
}

th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: #f1f5f9;
}

/* Form */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: "Poppins", sans-serif;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

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

/* Batch Structure */
.batch-tree {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.batch-item {
  background: white;
  border-radius: 12px;
  border: 2px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
}

.batch-header {
  padding: 1.25rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--primary-dark);
}

.batch-header:hover {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

.batch-content {
  padding: 1.25rem;
  display: none;
  border-top: 2px solid var(--border);
}

.batch-content.active {
  display: block;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.course-card {
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.course-card:hover {
  border-color: var(--primary);
  background: #f0f9ff;
  transform: translateY(-2px);
}

.course-name {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* Search Bar */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

/* Action Buttons in Table */
.action-btns {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
}

.action-btn-edit {
  background: #dbeafe;
  color: #1e40af;
}

.action-btn-delete {
  background: #fee2e2;
  color: #991b1b;
}

/* Attendance Grid */
.attendance-grid {
  display: grid;
  gap: 0.75rem;
}

.attendance-row {
  display: flex;
  align-items: center;
  padding: 1rem;
  background: white;
  border: 2px solid var(--border);
  border-radius: 8px;
  gap: 1rem;
}

.attendance-student {
  flex: 1;
}

.attendance-actions {
  display: flex;
  gap: 0.5rem;
}

.attendance-btn {
  padding: 0.5rem 1.25rem;
  border: 2px solid;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.attendance-btn.present {
  background: white;
  border-color: var(--success);
  color: var(--success);
}

.attendance-btn.present.active {
  background: var(--success);
  color: white;
}

.attendance-btn.absent {
  background: white;
  border-color: var(--danger);
  color: var(--danger);
}

.attendance-btn.absent.active {
  background: var(--danger);
  color: white;
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Alert */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid var(--success);
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--danger);
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border-left: 4px solid var(--warning);
}

/* File Upload */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-upload:hover {
  border-color: var(--primary);
  background: #f0f9ff;
}

.file-upload input[type="file"] {
  display: none;
}

/* Mobile Menu Toggle */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 2001;
  background: var(--primary);
  color: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s;
}

.mobile-menu-btn:active {
  transform: scale(0.95);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  display: block;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
  .sidebar {
    width: 260px;
  }

  .main-content {
    margin-left: 260px;
  }

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

/* Responsive - Mobile */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    transform: translateX(-100%);
    z-index: 1001;
    width: 280px;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 5rem;
    overflow-x: hidden;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

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

  .top-bar {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .breadcrumb {
    font-size: 0.8rem;
  }

  .btn-group {
    width: 100%;
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
    justify-content: center;
  }

  .stat-card {
    padding: 1.25rem;
  }

  .stat-value {
    font-size: 1.75rem;
  }

  .table-container {
    font-size: 0.8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  .table-container::after {
    opacity: 1;
  }

  table {
    min-width: 650px;
  }

  th,
  td {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .action-btns {
    flex-direction: row;
    gap: 0.25rem;
    flex-wrap: nowrap;
  }

  .action-btn {
    font-size: 0.7rem;
    padding: 0.375rem 0.5rem;
    white-space: nowrap;
  }

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

  .course-card {
    padding: 1.25rem;
  }

  .attendance-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .attendance-student {
    font-size: 0.875rem;
  }

  .attendance-actions {
    width: 100%;
    gap: 0.5rem;
  }

  .attendance-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }

  .modal-content {
    width: 95%;
    padding: 1.25rem;
    max-height: 85vh;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .card-title {
    font-size: 1.1rem;
  }

  .search-bar {
    margin-bottom: 1rem;
  }

  .search-input {
    font-size: 14px;
  }

  .content-card {
    padding: 1rem;
    overflow-x: hidden;
  }

  .batch-header {
    padding: 1rem;
    font-size: 0.95rem;
  }

  .batch-content {
    padding: 1rem;
  }

  .batch-tree {
    overflow-x: hidden;
  }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    width: 85%;
    max-width: 300px;
  }

  .mobile-menu-btn {
    width: 44px;
    height: 44px;
    top: 0.75rem;
    left: 0.75rem;
  }

  .main-content {
    padding: 0.75rem;
    padding-top: 4.5rem;
    overflow-x: hidden;
  }

  .top-bar {
    padding: 0.75rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.625rem;
  }

  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }

  .modal-content {
    width: 96%;
    padding: 1rem;
    border-radius: 12px;
  }

  .nav-item {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .nav-icon {
    font-size: 1.1rem;
  }

  .sidebar-header {
    padding: 1.5rem 1rem;
  }

  .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
  }

  .table-container {
    border-radius: 6px;
    margin-bottom: 1rem;
  }

  table {
    min-width: 600px;
  }

  th,
  td {
    padding: 0.5rem 0.4rem;
    font-size: 0.7rem;
  }

  .action-btns {
    flex-direction: row;
    gap: 0.2rem;
  }

  .action-btn {
    padding: 0.3rem 0.4rem;
    font-size: 0.65rem;
  }

  .attendance-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .course-card {
    padding: 1rem;
  }

  .course-name {
    font-size: 0.95rem;
  }

  .content-card {
    padding: 0.75rem;
    overflow-x: hidden;
  }

  .card-title {
    font-size: 1rem;
  }
}

/* Landscape Mobile Fix */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    overflow-y: auto;
    height: 100vh;
  }

  .modal-content {
    max-height: 95vh;
  }
}

.hidden {
  display: none !important;
}
