@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Jost:wght@300;400;500;600&display=swap');

/* ============================================================
   GLOBAL DESIGN TOKENS — "The Archivist"
   ============================================================ */
:root {
  --ink:              #0f0c08;
  --surface:          #1a1611;
  --surface-2:        #231f19;
  --surface-3:        #2d2820;
  --gold:             #c9912a;
  --gold-light:       #e8c97e;
  --gold-dim:         rgba(201,145,42,.13);
  --cream:            #f5f0e8;
  --cream-dark:       #ede8df;
  --text-on-dark:     #e8e0d0;
  --muted-on-dark:    #6e6252;
  --text:             #1a1209;
  --text-muted:       #6b5f52;
  --border-dark:      rgba(255,255,255,.07);
  --border:           #ddd6cc;
  --danger:           #be3b2e;
  --danger-dim:       #fce9e7;
  --radius:           8px;
  --radius-lg:        13px;
  --shadow:           0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:        0 4px 14px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg:        0 20px 60px rgba(0,0,0,.18), 0 8px 24px rgba(0,0,0,.1);
}

body {
  font-family: 'Jost', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Form controls ---- */
.form-control {
  font-family: 'Jost', sans-serif;
  font-size: .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .17s, box-shadow .17s;
}
.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,145,42,.11);
  outline: none;
}
.form-control::placeholder { color: #c0b8ae; font-weight: 300; }

.custom-select {
  font-family: 'Jost', sans-serif;
  font-size: .875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.custom-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,145,42,.11);
  outline: none;
}

textarea.form-control { padding: .65rem .875rem; }

/* ---- Buttons ---- */
.btn {
  font-family: 'Jost', sans-serif;
  font-weight: 500;
  font-size: .875rem;
  letter-spacing: .25px;
  border-radius: var(--radius);
  transition: all .17s;
}
.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: #b07d22;
  border-color: #b07d22;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201,145,42,.28);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--cream);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--cream-dark);
  border-color: var(--border);
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #a5322a;
  border-color: #a5322a;
  color: #fff;
}
.btn-warning {
  background: #c97c1a;
  border-color: #c97c1a;
  color: #fff;
}
.btn-warning:hover {
  background: #b06a13;
  border-color: #b06a13;
  color: #fff;
}

/* ---- Modal chrome ---- */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-dark);
  padding: 1.25rem 1.5rem;
  align-items: center;
}
.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text-on-dark);
  letter-spacing: .3px;
}
.modal-header .close {
  color: var(--muted-on-dark);
  opacity: 1;
  font-size: 1.5rem;
  font-weight: 300;
  text-shadow: none;
  transition: color .15s;
  padding: .25rem .5rem;
}
.modal-header .close:hover { color: var(--text-on-dark); }
.modal-body {
  padding: 1.75rem 1.5rem;
  background: #fff;
}
.modal-footer {
  background: var(--cream);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  gap: .5rem;
}
.modal-body label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.modal-body .form-group { margin-bottom: 1.25rem; }

/* ---- Alert in delete modals ---- */
.alert-danger {
  background: var(--danger-dim);
  border: 1px solid rgba(190,59,46,.18);
  color: var(--danger);
  border-radius: var(--radius);
  font-size: .875rem;
}

/* ---- DataTables ---- */
table.dataTable { border-collapse: collapse !important; }
table.dataTable thead th {
  font-family: 'Jost', sans-serif;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border) !important;
  background: #faf8f3 !important;
  padding: .875rem 1rem;
  white-space: nowrap;
}
table.dataTable tbody td {
  padding: .875rem 1rem;
  border-top: 1px solid var(--border) !important;
  color: var(--text);
  font-size: .875rem;
  vertical-align: middle;
}
table.dataTable tbody tr:hover td { background: #faf8f3; }
div.dataTables_wrapper .dataTables_filter input {
  font-family: 'Jost', sans-serif;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: .38rem .875rem !important;
  font-size: .8rem !important;
  margin-left: .4rem;
  transition: border-color .17s;
  outline: none;
}
div.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(201,145,42,.11) !important;
}
div.dataTables_wrapper .dataTables_length select {
  font-family: 'Jost', sans-serif;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .5rem;
  font-size: .8rem;
}
div.dataTables_wrapper .dataTables_info,
div.dataTables_wrapper .dataTables_length label {
  font-size: .78rem;
  color: var(--text-muted);
}
.paginate_button.page-item .page-link {
  font-size: .78rem;
  border-color: var(--border);
  color: var(--text);
}
.paginate_button.page-item.active .page-link {
  background: var(--gold) !important;
  border-color: var(--gold) !important;
}

/* ---- DataTables responsive (collapsed child rows) ---- */
/* Expand/collapse control dot — gold instead of the plugin default */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child:before {
  background-color: var(--gold) !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.25) !important;
  top: 50% !important;
  margin-top: -7px;
}
table.dataTable > tbody > tr.child:hover td { background: transparent !important; }
table.dataTable > tbody > tr.child ul.dtr-details {
  width: 100%;
  padding: .25rem 0;
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border) !important;
}
table.dataTable > tbody > tr.child ul.dtr-details > li:last-child { border-bottom: none !important; }
table.dataTable > tbody > tr.child span.dtr-title {
  font-family: 'Jost', sans-serif;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 92px;
  flex-shrink: 0;
}
table.dataTable > tbody > tr.child span.dtr-data {
  font-size: .875rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* ---- DataTables ajax loading indicator ---- */
div.dataTables_processing {
  background: var(--surface) !important;
  color: var(--text-on-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-family: 'Jost', sans-serif;
  font-size: .8rem;
  letter-spacing: .5px;
  padding: .65rem 1.1rem !important;
  height: auto !important;
  width: auto !important;
  margin-left: 0 !important;
  transform: translateX(-50%);
}
.lbr-dt-loading {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--gold-light);
}

/* ---- Frozen form while a request is in flight ---- */
.form-control:disabled,
.custom-select:disabled,
textarea.form-control:disabled {
  background: #f0ece3;
  color: var(--text-muted);
  opacity: .75;
  cursor: not-allowed;
}
.lbr-field:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.btn:disabled,
.lbr-btn-submit:disabled {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.lbr-form-loading label,
.lbr-form-loading .custom-control-label {
  opacity: .55;
}
.modal-header .close:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* ============================================================
   SPINNER
   ============================================================ */
.lbr-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.125em;
  animation: lbr-spin .6s linear infinite;
}
@keyframes lbr-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   TOASTS
   ============================================================ */
#lbr-toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  width: min(360px, calc(100vw - 2.5rem));
  pointer-events: none;
}

.lbr-toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .9rem 1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(calc(100% + 1.5rem));
  transition: opacity .3s ease, transform .3s cubic-bezier(.21, 1.02, .73, 1);
}
.lbr-toast--visible {
  opacity: 1;
  transform: translateX(0);
}
.lbr-toast--leaving {
  opacity: 0;
  transform: translateX(calc(100% + 1.5rem));
}

.lbr-toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: .9rem;
  margin-top: .1rem;
}
.lbr-toast-body { flex: 1; min-width: 0; }
.lbr-toast-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--text-on-dark);
  margin: 0 0 .1rem;
}
.lbr-toast-message {
  font-family: 'Jost', sans-serif;
  font-size: .82rem;
  font-weight: 300;
  line-height: 1.45;
  color: var(--text-on-dark);
  opacity: .8;
  margin: 0;
  overflow-wrap: break-word;
}
.lbr-toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0 .15rem;
  font-size: 1.15rem;
  font-weight: 300;
  line-height: 1;
  color: var(--muted-on-dark);
  cursor: pointer;
  transition: color .15s;
}
.lbr-toast-close:hover { color: var(--text-on-dark); }

.lbr-toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left;
  animation: lbr-toast-progress linear forwards;
}
@keyframes lbr-toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.lbr-toast:hover .lbr-toast-progress {
  animation-play-state: paused;
}

.lbr-toast--success .lbr-toast-icon { color: #7dc98f; background: rgba(125, 201, 143, .12); }
.lbr-toast--success .lbr-toast-progress { background: #5d9e6e; }
.lbr-toast--error .lbr-toast-icon { color: #e8867b; background: rgba(232, 134, 123, .12); }
.lbr-toast--error .lbr-toast-progress { background: var(--danger); }
.lbr-toast--warning .lbr-toast-icon,
.lbr-toast--warn .lbr-toast-icon { color: #e8b567; background: rgba(232, 181, 103, .12); }
.lbr-toast--warning .lbr-toast-progress,
.lbr-toast--warn .lbr-toast-progress { background: #c97c1a; }
.lbr-toast--info .lbr-toast-icon { color: var(--gold-light); background: var(--gold-dim); }
.lbr-toast--info .lbr-toast-progress { background: var(--gold); }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 767.98px) {
  /* 16px inputs prevent iOS Safari from auto-zooming on focus */
  .form-control,
  .custom-select {
    font-size: 16px;
  }
}

@media (max-width: 575.98px) {
  /* Modal chrome: tighter, full-width friendly */
  .modal-header { padding: 1rem 1.1rem; }
  .modal-body { padding: 1.35rem 1.1rem; }
  .modal-footer { padding: .875rem 1.1rem; }

  /* DataTables controls stack; give the search box the full row */
  div.dataTables_wrapper .dataTables_filter { text-align: left; }
  div.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: .5rem;
  }
  div.dataTables_wrapper .dataTables_filter input {
    flex: 1;
    width: auto;
    min-width: 0;
    font-size: 16px !important;
  }
  div.dataTables_wrapper .dataTables_length { margin-bottom: .25rem; }
  div.dataTables_wrapper .dataTables_paginate .pagination {
    flex-wrap: wrap;
    justify-content: center;
    margin-top: .5rem;
  }
  div.dataTables_wrapper .dataTables_info {
    text-align: center;
    padding-top: .5rem;
  }
}
