:root {
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --secondary: #475569;
  --accent: #d97706;
  --success: #16a34a;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #ca8a04;
  --info: #0284c7;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, system-ui;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP NAVBAR */
.top-navbar {
  background: #ffffff;
  border-bottom: 2px solid #e2e8f0;
  padding: 0.6rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 4px rgba(30, 58, 138, 0.3);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.05rem;
  color: #0f172a;
  font-weight: 700;
  white-space: nowrap;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  gap: 6px;
  list-style: none;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.nav-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.nav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.user-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 5px 12px;
  border-radius: 30px;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #1e293b;
  font-size: 0.85rem;
}

.user-info-text {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
}

.role-pill {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-block;
  width: fit-content;
}

.role-admin {
  background: #fee2e2;
  color: #991b1b;
}

.role-officer {
  background: #e0f2fe;
  color: #0369a1;
}

.role-viewer {
  background: #fef3c7;
  color: #92400e;
}

.btn-logout {
  background: transparent;
  border: 1px solid #e2e8f0;
  color: var(--danger);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* MAIN CONTENT */
.main-container {
  max-width: 1300px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

/* STATS ROW */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-info h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-info .stat-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* TABS / VIEWS */
.tab-view {
  display: none;
}

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

/* FORM STYLING */
.form-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  padding: 2rem;
  margin-bottom: 2rem;
}

.form-header {
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-header h2 {
  font-size: 1.25rem;
  color: #0f172a;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.3rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 0.95rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 6px;
  border-bottom: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.req-star {
  color: var(--danger);
  margin-right: 2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 0.88rem;
  color: #1e293b;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

/* PHOTO UPLOAD BOX */
.photo-upload-wrapper {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 1.2rem;
}

.photo-preview-box {
  width: 120px;
  height: 140px;
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: all 0.2s;
}

.photo-preview-box:hover {
  border-color: var(--primary);
  background: #e2e8f0;
}

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

.photo-placeholder-icon {
  font-size: 32px;
  color: #64748b;
  font-weight: 300;
}

.photo-preview-box span {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* BUTTONS */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(30, 58, 138, 0.25);
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid #e2e8f0;
}

/* DATA TABLE */
.table-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.table-toolbar {
  padding: 1.2rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.search-box {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 450px;
}

.filters-box {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.88rem;
}

.custom-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
}

.custom-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
  vertical-align: middle;
}

.custom-table tr:hover {
  background-color: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-remand {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-sentenced {
  background: #fef3c7;
  color: #b45309;
}

.badge-egyptian {
  background: #dcfce7;
  color: #15803d;
}

.badge-foreign {
  background: #f3e8ff;
  color: #7e22ce;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  background: transparent;
  border: 1px solid #cbd5e1;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s;
}

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

.action-btn.view {
  color: var(--primary);
  border-color: var(--primary);
}

.action-btn.edit {
  color: var(--accent);
  border-color: var(--accent);
}

.action-btn.delete {
  color: var(--danger);
  border-color: var(--danger);
}

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 850px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid #e2e8f0;
}

.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  color: #0f172a;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #64748b;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* OFFICIAL PRINTABLE CARD */
.official-card {
  border: 2px solid #0f172a;
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  background: #fff;
}

.official-header {
  text-align: center;
  border-bottom: 2px double #0f172a;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.official-header h2 {
  font-size: 1.2rem;
  color: #0f172a;
}

.official-header p {
  font-size: 0.85rem;
  color: #475569;
}

.official-grid {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 15px;
}

.official-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 0.88rem;
}

.field-box {
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.field-box strong {
  color: #475569;
  font-size: 0.78rem;
  display: block;
}

.field-box span {
  font-weight: 700;
  color: #0f172a;
}

.official-photo {
  width: 140px;
  height: 160px;
  border: 1px solid #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  overflow: hidden;
}

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

.footer-copy {
  text-align: center;
  padding: 1rem;
  color: #64748b;
  font-size: 0.78rem;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  margin-top: auto;
}

/* TOAST NOTIFICATION */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 999;
}

/* LOGIN VIEW OVERLAY */
.login-view-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.login-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid #e2e8f0;
  padding: 2.2rem;
  width: 100%;
  max-width: 440px;
}

.login-header {
  text-align: center;
  margin-bottom: 1.8rem;
}

.demo-pills {
  margin-top: 1.5rem;
  background: #f8fafc;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
  font-size: 0.78rem;
}

.demo-pill-btn {
  background: #fff;
  border: 1px solid #cbd5e1;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  margin: 3px;
}

/* PRINT MEDIA */
@media print {
  body {
    background: #fff;
  }
  .top-navbar, .nav-links, .table-toolbar, .stats-grid, .btn-primary, .btn-secondary, .footer-copy, .form-card, .table-card {
    display: none !important;
  }
  .modal-overlay {
    position: static;
    background: transparent;
    padding: 0;
  }
  .modal-card {
    max-width: 100%;
    box-shadow: none;
    border: none;
  }
  .modal-header, .modal-footer {
    display: none;
  }
  .official-card {
    border: 2px solid #000;
    page-break-inside: avoid;
  }
}

