/* ==========================================================================
   מערכת ימי הולדת – ישיבת חורב ירושלים
   קובץ עיצוב ראשי (Styles & Print Engine)
   ========================================================================== */

:root {
  --primary: #136b94;
  --primary-dark: #0e4c6a;
  --primary-light: #eaf3f8;
  --gold: #b89535;
  --gold-hover: #9c7b24;
  --gold-light: #fbf7ee;
  --bg-page: #f4f7fb;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Assistant', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* App Header & Navbar */
.app-header {
  background: linear-gradient(135deg, #136b94 0%, #0d4a66 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 52px;
  width: auto;
  object-fit: contain;
  background: #ffffff;
  padding: 4px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.brand-slogan {
  font-size: 13px;
  color: #e2d3a3;
  display: block;
  font-weight: 600;
}

.header-status-box {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 16px;
  border-radius: 20px;
  text-align: center;
}

.today-hebrew-date {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

.today-greg-date {
  font-size: 12px;
  color: #d1e2eb;
}

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

.user-greeting {
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
}

/* Nav Tabs */
.nav-tabs-bar {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  padding: 0 24px;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-tab {
  background: transparent;
  border: none;
  color: #d1e2eb;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #ffffff;
  border-bottom-color: var(--gold);
  background: rgba(255, 255, 255, 0.08);
}

.badge-count {
  background: var(--gold);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.badge-count.secondary {
  background: rgba(255, 255, 255, 0.25);
}

/* Main Content */
.main-content {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

.btn-gold {
  background-color: var(--gold);
  color: #ffffff;
  font-weight: 700;
}

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

.btn-secondary {
  background-color: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

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

.btn-outline:hover {
  background: #f1f5f9;
}

.btn-outline-light {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-whatsapp {
  background-color: #25d366;
  color: #ffffff;
}

.btn-whatsapp:hover {
  background-color: #1eb857;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13.5px;
}

.btn-icon-only {
  background: transparent;
  color: #ffffff;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
}

.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-check-icon {
  background: #ffffff;
  color: var(--success);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
}

/* Hero Banner */
.dashboard-hero-banner {
  background: linear-gradient(135deg, #ffffff 0%, var(--gold-light) 100%);
  border: 1.5px solid #eedda6;
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.hero-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}

.hero-desc {
  font-size: 15px;
  color: var(--text-muted);
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* Notice Cards */
.notice-card {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.notice-card.warning {
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  color: #78350f;
}

.notice-icon {
  flex-shrink: 0;
  color: var(--warning);
}

.notice-content {
  flex-grow: 1;
}

.notice-content h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 3px;
}

.notice-content p {
  font-size: 14px;
}

/* Section Headers */
.section-header-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-dark);
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.stats-pill strong {
  color: var(--primary);
  font-size: 16px;
  margin-right: 4px;
}

/* Teacher Groups Grid */
.teacher-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}

.teacher-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, box-shadow 0.15s;
}

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

.teacher-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.teacher-name {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.teacher-phone {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.teacher-status-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

.teacher-status-badge.sent {
  background: var(--success-light);
  color: var(--success);
}

.teacher-status-badge.pending {
  background: #f1f5f9;
  color: var(--text-muted);
}

/* Student Items Inside Teacher Card */
.students-list-inside {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.student-row-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.student-info-main strong {
  font-size: 16px;
  color: #1e293b;
  display: block;
}

.student-meta-sub {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-top: 3px;
}

.student-shift-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
}

.student-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-check-badge {
  background: var(--success-light);
  color: var(--success);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

/* Grid for Upcoming / Missed */
.student-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.single-student-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Interactive Calendar */
.calendar-header {
  background: var(--bg-card);
  padding: 16px 20px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.calendar-month-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--primary);
  color: #ffffff;
  text-align: center;
  padding: 10px 0;
  font-weight: 700;
  font-size: 14px;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--border-color);
  gap: 1px;
  border: 1px solid var(--border-color);
}

.calendar-cell {
  background: #ffffff;
  min-height: 110px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background 0.15s;
}

.calendar-cell:hover {
  background: #fdfaf3;
}

.calendar-cell.other-month {
  background: #f8fafc;
  color: #94a3b8;
}

.calendar-cell.today {
  background: #f0fdf4;
  border: 2px solid var(--success);
}

.cell-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
}

.cell-hebrew-day {
  font-weight: 700;
  color: var(--primary);
}

.cell-greg-day {
  color: var(--text-muted);
  font-size: 11.5px;
}

.cell-events-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 80px;
}

.event-pill {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.event-pill:hover {
  background: #dbeafe;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}

.admin-modal-card {
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

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

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

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

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

.login-card {
  padding: 30px;
}

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

.login-logo {
  height: 60px;
  margin-bottom: 12px;
}

.login-header h2 {
  font-family: 'Frank Ruhl Libre', serif;
  color: var(--primary);
}

.login-error {
  background: #fee2e2;
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 14px;
  font-weight: 600;
}

/* Admin Tabs Inside Modal */
.admin-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #f8fafc;
}

.admin-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 4px;
}

.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #f1f5f9;
  overflow-x: auto;
}

.admin-tab-btn {
  background: transparent;
  border: none;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.admin-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.admin-tab-content {
  display: none;
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 160px);
}

.admin-tab-content.active {
  display: block;
}

.form-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.form-section-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 14px;
}

/* Drag & Layout Editor */
.layout-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.layout-preview-box {
  background: #1e293b;
  border-radius: var(--radius-md);
  padding: 12px;
  color: #ffffff;
}

.card-canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.card-canvas-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.draggable-text {
  position: absolute;
  cursor: move;
  user-select: none;
  padding: 2px 6px;
  border: 1px dashed rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

/* Notice Board Month Preview */
.month-wall-preview {
  background: #ffffff;
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.wall-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid #eedda6;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.wall-logo {
  height: 64px;
}

.wall-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
}

.wall-subtitle {
  font-size: 18px;
  color: var(--gold);
  font-weight: 700;
}

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

.wall-student-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px;
  border-right: 4px solid var(--primary);
}

.wall-student-item strong {
  font-size: 16px;
  display: block;
}

.wall-student-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ==========================================================================
   PRINT ENGINE (A4 LANDSCAPE BLESSING CARDS)
   ========================================================================== */
.print-container {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 297mm;
  height: 210mm;
  opacity: 0;
  pointer-events: none;
  z-index: -9999;
}

/* Modal Live Preview Card */
.blessing-preview-wrap {
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f8fafc;
}
.blessing-preview-header {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--horev-blue);
  background: #f1f5f9;
  border-bottom: 1px solid var(--border-color);
}
.blessing-preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1.414; /* A4 Landscape ratio */
  background: #ffffff;
  overflow: hidden;
}
.blessing-preview-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.blessing-preview-field {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-weight: bold;
  pointer-events: none;
}

@media print {
  @page {
    size: landscape;
    margin: 0mm !important;
  }

  html, body {
    width: 297mm !important;
    height: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide entire UI elements */
  .app-header,
  .dashboard-hero-banner,
  .section-header-wrap,
  .teacher-groups-grid,
  .notice-card,
  .calendar-header,
  .calendar-weekdays,
  .calendar-days-grid,
  .modal-overlay,
  .login-screen-wrapper,
  .btn,
  .nav-tabs-bar {
    display: none !important;
  }

  /* Show only print container */
  .print-container {
    display: block !important;
    position: static !important;
    left: 0 !important;
    top: 0 !important;
    width: 297mm !important;
    height: 210mm !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .print-page-landscape {
    width: 297mm !important;
    height: 210mm !important;
    position: relative !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    overflow: hidden !important;
    background-color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  .print-background-img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 297mm !important;
    height: 210mm !important;
    object-fit: fill !important;
    display: block !important;
    z-index: 1 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .print-field {
    position: absolute !important;
    transform: translate(-50%, -50%) !important;
    white-space: nowrap !important;
    z-index: 10 !important;
    line-height: 1.2 !important;
  }
}

/* Full-Screen Isolated Login Screen - 100% Opaque & Secure */
.login-screen-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #0b2536 0%, #136b94 50%, #081d2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999999;
}

.login-screen-wrapper .login-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
