/* Student Attendance System - Main Stylesheet */

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

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-secondary: #64748b;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;

  --sidebar-width: 250px;
  --header-height: 64px;
}

body {
  font-family: -apple-system, BlinkMacMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--color-text-muted);
  font-size: 14px;
}

.login-form {
  margin-bottom: 24px;
}

.login-footer {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* Header */
.header {
  background: #080808; /* Updated header background to #080808 for both parent and admin */
  border-bottom: 1px solid #333; /* Changed border color */
  height: var(--header-height);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 24px;
  gap: 16px;
}

/* Added header-left for mobile menu button and logo grouping */
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Added mobile menu toggle button styling */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: #ffffff; /* Changed color to white for black header */
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

.mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1); /* Darker hover for black header */
}

.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-primary);
}

/* Added logo styling for Al Quran Qirat Academy branding */
.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  /* Added max-width to prevent logo from taking too much space on mobile */
  max-width: 100%;
}

.logo-image {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
  /* Added flex-shrink to allow text to compress */
  flex-shrink: 1;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  color: #c19a5b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-subtitle {
  font-size: 11px;
  color: #999; /* Lighter color for black header */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  /* Ensure header-right doesn't shrink */
  flex-shrink: 0;
}

.user-name {
  color: #ffffff; /* Changed color to white for black header */
  font-weight: 500;
  font-size: 14px;
}

/* Main Container */
.main-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 24px 0;
  position: fixed;
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-primary);
  color: white;
}

.nav-item svg {
  flex-shrink: 0;
}

/* Content */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
}

.page-header {
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.stat-blue {
  background: #dbeafe;
  color: #2563eb;
}

.stat-icon.stat-green {
  background: #d1fae5;
  color: #10b981;
}

.stat-icon.stat-purple {
  background: #e9d5ff;
  color: #9333ea;
}

.stat-icon.stat-orange {
  background: #fed7aa;
  color: #f59e0b;
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
}

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  margin-bottom: 24px;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: 24px;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead tr {
  border-bottom: 1px solid var(--color-border);
}

.table th {
  text-align: left;
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.table tbody tr:hover {
  background: var(--color-bg);
}

.table .actions {
  display: flex;
  gap: 8px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.filter-form {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.attendance-select {
  width: 100%;
  max-width: 150px;
}

/* Added phone input group styling */
.phone-input-group {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  background: var(--color-bg);
  margin-bottom: 24px;
}

.phone-input-group h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 16px;
}

.phone-preferences {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
  font-weight: 400;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  gap: 8px;
}

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

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

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

.btn-secondary:hover {
  background: #475569;
}

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

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-block {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-active,
.badge-present {
  background: #d1fae5;
  color: #065f46;
}

.badge-inactive,
.badge-absent {
  background: #fee2e2;
  color: #991b1b;
}

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

.badge-late {
  background: #fed7aa;
  color: #92400e;
}

.badge-excused {
  background: #e0e7ff;
  color: #3730a3;
}

/* Alerts */
.alert {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 14px;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Utilities */
.text-muted {
  color: var(--color-text-muted);
}

.text-center {
  text-align: center;
}

.text-success {
  color: var(--color-success);
}

.text-danger {
  color: var(--color-danger);
}

.text-warning {
  color: var(--color-warning);
}

.text-info {
  color: var(--color-info);
}

/* Responsive */
@media (max-width: 768px) {
  /* Show mobile menu toggle and ensure proper layout */
  .mobile-menu-toggle {
    display: flex;
  }

  .header-content {
    padding: 0 12px;
    gap: 8px;
    /* Use flex-wrap to prevent overlap */
    flex-wrap: nowrap;
  }

  /* Reduce logo size significantly on mobile */
  .logo-image {
    width: 36px;
    height: 36px;
  }

  .logo-title {
    font-size: 13px;
  }

  .logo-subtitle {
    font-size: 9px;
  }

  /* Control logo container width more strictly on mobile */
  .logo-container {
    flex: 1 1 auto;
    max-width: calc(100% - 100px);
    min-width: 120px;
  }

  /* Hide user name text on very small screens */
  .user-name {
    display: none;
  }

  /* Added responsive styles for Switch Student button text */
  /* Hide button text on mobile, keep icon */
  .btn-text {
    display: none;
  }

  /* Adjust Switch Student button for mobile */
  .header-right .btn svg {
    margin: 0;
  }

  /* Ensure logout button doesn't wrap */
  .header-right {
    gap: 8px;
  }

  .header-right .btn {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* Make sidebar fixed and hidden by default on mobile */
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 99;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

  /* Show sidebar when open class is added */
  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
  }

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

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

  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 8px;
  }

  .comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .comment-item {
    padding: 16px;
  }

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

  audio {
    max-width: 100%;
  }

  /* Fix photo alignment in parent dashboard for mobile */
  .card-body > div[style*="display: flex"] {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .card-body > div[style*="display: flex"] > div[style*="width: 120px"] {
    align-self: flex-start;
  }
}

/* Extra small devices - more aggressive space saving */
@media (max-width: 480px) {
  .logo-container {
    max-width: calc(100% - 80px);
    min-width: 100px;
  }

  .logo-image {
    width: 32px;
    height: 32px;
  }

  .logo-title {
    font-size: 12px;
  }

  .logo-subtitle {
    display: none;
  }

  .header-right .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Added photo upload and display styles */

/* Photo Upload Section */
.photo-upload-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--color-border);
}

.photo-upload-container {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.photo-preview {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  border: 2px dashed var(--color-border);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text-muted);
}

.photo-placeholder svg {
  opacity: 0.5;
}

.photo-placeholder p {
  font-size: 14px;
  margin: 0;
}

.photo-upload-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.photo-upload-controls label {
  cursor: pointer;
  margin: 0;
}

.upload-hint {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Student Photo in Attendance Table */
.student-photo-small {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.student-photo-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder-small {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  background: var(--color-bg);
}

.photo-placeholder-small svg {
  opacity: 0.4;
}

/* Attendance Table Adjustments */
.attendance-table td:first-child {
  width: 80px;
  padding: 12px;
}

/* Added teacher comments styling */

/* Comments Section */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comment-item {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  background: var(--color-bg);
  transition: box-shadow 0.2s;
}

.comment-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.comment-student-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.comment-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

.comment-content {
  padding-top: 8px;
}

.comment-content p {
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

/* Student Avatar for Comments */
.student-avatar-small {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.student-avatar-placeholder-small {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  border: 2px solid var(--color-border);
}

/* Audio Player Styling */
audio {
  border-radius: 8px;
  background: var(--color-surface);
  margin-top: 8px;
}

/* Form Grid for Comment Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* File Input Styling */
input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
}

.form-text {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Badge Colors for Comments */
.badge-text {
  background: #d1fae5;
  color: #065f46;
}

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

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

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

/* Radio Button Styling */
input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* Enhanced Table for Parent Dashboard */
.table tbody tr:last-child td {
  border-bottom: none;
}

/* Responsive Adjustments for Comments */
@media (max-width: 768px) {
  .comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .comment-item {
    padding: 16px;
  }

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

  audio {
    max-width: 100%;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  /* Prevent actions from shrinking */
  flex-shrink: 0;
}
