@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #0f6fb2;
  --primary-700: #0a4f80;
  --primary-50: #eaf6ff;
  --accent: #c9a959;
  --success: #148a5b;
  --danger: #c83e3e;
  --warning: #b7791f;
  --info: #2563eb;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --border: #dbe3ef;
  --shadow-sm: 0 4px 14px rgba(15, 35, 55, 0.08);
  --shadow-md: 0 16px 40px rgba(15, 35, 55, 0.12);
  --radius: 8px;
  --radius-lg: 10px;
  --focus-ring: 0 0 0 4px rgba(15, 111, 178, 0.16);
  --font-ui: "Inter", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --card-shadow: var(--shadow-md);
  --background: var(--bg);
  --secondary: var(--success);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 111, 178, 0.06), rgba(255, 255, 255, 0) 240px),
    var(--bg) !important;
  color: var(--text) !important;
  font-family: var(--font-ui) !important;
  line-height: 1.55;
}

a {
  color: var(--primary);
}

h1,
h2,
h3,
h4 {
  color: var(--text) !important;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0 0 1rem;
}

h2 {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding-bottom: .85rem !important;
  border-bottom: 1px solid var(--border) !important;
}

h2::after {
  display: none !important;
}

.main-content,
.container,
.card,
.form-section,
.box,
.panel,
.section {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
}

.main-content,
.container {
  width: min(1600px, calc(100% - 2rem));
  margin: 1.25rem auto !important;
  padding: 1.25rem !important;
}

.form-section,
.card,
.panel,
.section {
  padding: 1.1rem !important;
}

.muted,
.no-file,
small {
  color: var(--muted) !important;
}

.table-container,
.table-wrap,
.responsive-table,
div[style*="overflow-x:auto"],
div[style*="overflow-x: auto"] {
  width: 100%;
  overflow-x: auto !important;
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
  margin: 1rem 0 !important;
}

table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: var(--surface) !important;
  color: var(--text);
}

thead th,
table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--primary) !important;
  color: #fff !important;
  font-size: .82rem !important;
  font-weight: 800 !important;
  text-align: left;
  padding: .85rem .9rem !important;
  border: 0 !important;
  white-space: nowrap;
}

table td {
  padding: .8rem .9rem !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: .88rem !important;
  vertical-align: middle;
}

tbody tr:nth-child(even) {
  background: var(--surface-muted) !important;
}

tbody tr:hover {
  background: var(--primary-50) !important;
  transform: none !important;
  box-shadow: none !important;
}

tbody tr:last-child td {
  border-bottom: 0 !important;
}

.btn,
button,
input[type="submit"],
input[type="button"],
a.btn {
  min-height: 38px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .55rem .9rem !important;
  border: 1px solid transparent !important;
  border-radius: var(--radius) !important;
  background: #eef4fb !important;
  color: var(--text) !important;
  font-family: var(--font-ui) !important;
  font-size: .88rem !important;
  font-weight: 800 !important;
  line-height: 1;
  text-decoration: none !important;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
  white-space: nowrap;
}

.btn:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
a.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary,
.btn-view,
.btn-edit,
.edit-btn {
  background: var(--primary) !important;
  color: #fff !important;
}

.btn-success,
.btn-add {
  background: var(--success) !important;
  color: #fff !important;
}

.btn-danger,
.btn-delete,
.delete-btn {
  background: var(--danger) !important;
  color: #fff !important;
}

.btn-purple,
.btn-secondary {
  background: #5b5fc7 !important;
  color: #fff !important;
}

.btn-print,
.btn-light {
  background: var(--surface) !important;
  color: var(--primary) !important;
  border-color: var(--border) !important;
}

.actions,
.action-buttons,
.btn-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

label {
  display: inline-block;
  margin-bottom: .35rem;
  color: #334155 !important;
  font-size: .86rem;
  font-weight: 800 !important;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: .65rem .75rem !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  background: #fff !important;
  color: var(--text) !important;
  font-family: var(--font-ui) !important;
  font-size: .92rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: var(--focus-ring) !important;
}

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

.input-group,
.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.message,
.success,
.alert-success {
  border: 1px solid rgba(20, 138, 91, .25);
  border-radius: var(--radius);
  background: #eafaf3 !important;
  color: #0f6846 !important;
  padding: .85rem 1rem;
  font-weight: 800;
}

.error,
.alert-danger,
.danger {
  border: 1px solid rgba(200, 62, 62, .25);
  border-radius: var(--radius);
  background: #fff0f0 !important;
  color: #9f2f2f !important;
  padding: .85rem 1rem;
  font-weight: 800;
}

.pill,
.badge,
.payment-status {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 28px;
  padding: .3rem .65rem !important;
  border-radius: 999px !important;
  font-size: .78rem;
  font-weight: 800;
}

.paid {
  background: #eafaf3 !important;
  color: var(--success) !important;
}

.unpaid {
  background: #fff0f0 !important;
  color: var(--danger) !important;
}

.student-photo,
.avatar,
.photo {
  width: 42px !important;
  height: 42px !important;
  border: 1px solid var(--border);
  border-radius: 50% !important;
  object-fit: cover;
  background: var(--surface-muted);
}

.avatar-placeholder {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  border: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

.full-span {
  grid-column: 1 / -1;
}

.tranche-row,
.inline-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .65rem;
}

.student-id-chip,
.soft-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: var(--accent);
  color: #082338;
  font-weight: 900;
}

.card-meta {
  margin-top: 2.5rem;
}

.card-field-row {
  display: flex;
  gap: 3rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.card-label {
  color: var(--accent) !important;
  font-size: .72rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.card-value {
  margin: 0;
  font-weight: 700;
}

.barcode-text {
  position: absolute;
  right: 40px;
  bottom: 30px;
  font-family: "Libre Barcode 39", var(--font-ui);
  font-size: 50px;
}

.payment-note {
  margin-top: 25px;
  padding: .35rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .75);
  color: var(--primary-700);
  font-weight: 800;
}

.toolbar,
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  body {
    padding: .75rem !important;
  }

  .main-content,
  .container {
    width: 100%;
    margin: .75rem 0 !important;
    padding: 1rem !important;
  }

  table th,
  table td {
    padding: .7rem !important;
    font-size: .82rem !important;
  }

  .btn,
  button,
  input[type="submit"],
  input[type="button"] {
    min-height: 36px;
    padding: .5rem .7rem !important;
  }
}

body.app-shell {
  height: 100vh;
  padding: 0 !important;
  overflow: hidden;
}

body.app-shell .main-content {
  width: auto !important;
  min-height: 100vh;
  margin: 0 0 0 320px !important;
  padding: 1.25rem !important;
  display: flex;
  align-items: stretch;
  justify-content: center;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background:
    linear-gradient(180deg, rgba(15, 111, 178, 0.08), rgba(255, 255, 255, 0) 240px),
    var(--bg) !important;
}

body.app-shell[dir="rtl"] .main-content {
  margin: 0 320px 0 0 !important;
}

body.app-shell iframe {
  width: 100% !important;
  height: calc(100vh - 2.5rem) !important;
  max-width: none !important;
  margin: 0 !important;
  border: 0;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
}

body.app-shell .sidebar {
  width: 320px;
  flex-shrink: 0;
}

body.app-shell .sidebar input[type="search"] {
  min-height: 42px;
  border-radius: 999px !important;
}

@media (max-width: 1200px) {
  body.app-shell .main-content {
    margin-left: 250px !important;
  }

  body.app-shell[dir="rtl"] .main-content {
    margin-left: 0 !important;
    margin-right: 250px !important;
  }

  body.app-shell .sidebar {
    width: 250px;
  }
}

@media (max-width: 992px) {
  body.app-shell {
    height: auto;
    overflow: auto;
  }

  body.app-shell .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-radius: 0 !important;
  }

  body.app-shell .main-content,
  body.app-shell[dir="rtl"] .main-content {
    margin: 0 !important;
    min-height: auto;
    padding: 1rem !important;
  }

  body.app-shell iframe {
    height: 75vh !important;
  }
}
