/* ============================================================
   HCD Rivadavia · Sistema de Expediente Electrónico
   Design System — Global Styles
   ============================================================ */

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

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --navy: #0d1b36;
  --navy-light: #162444;
  --navy-hover: #1e3260;
  --gold: #c9a227;
  --gold-light: #e0b93a;
  --gold-muted: rgba(201, 162, 39, 0.15);
  --surface: #f0f4f8;
  --card-bg: #ffffff;
  --text-main: #1a2340;
  --text-muted: #6b7a99;
  --border: #e2e8f0;
  --accent-blue: #1a56db;
  --sidebar-w: 230px;
  --shadow-sm: 0 1px 4px rgba(13, 27, 54, .08);
  --shadow-md: 0 4px 20px rgba(13, 27, 54, .12);
  --shadow-lg: 0 8px 40px rgba(13, 27, 54, .18);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ───────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout wrapper ─────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  /* children stretch to full height */
}

/* Main content: the area right of sidebar */
#app>.container,
#app>.container-fluid {
  flex: 1;
  padding: 28px 32px;
  max-width: 100%;
  background: var(--surface);
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebarColors {
  width: var(--sidebar-w) !important;
  background: var(--navy) !important;
  color: #fff !important;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
  z-index: 100;
  transition: width var(--transition);

  /* Barra fija: el menú y "Cerrar sesión" quedan siempre a la vista,
     sin importar cuánto scroll tenga el contenido (ej. el Digesto).
     align-self anula el align-items:stretch de #app, que estiraba la
     barra a la altura de todo el documento y empujaba el pie al final. */
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
}

/* Sidebar gold top stripe */
.sidebarColors::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

/* Sidebar brand */
.sidebar-brand {
  padding: 24px 16px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand img {
  width: 80px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .3));
  margin-bottom: 8px;
}

.sidebar-brand .brand-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1.4;
  margin: 0;
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, .5);
  margin: 2px 0 0;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  list-style: none;
  margin: 0;
}

.sidebar-nav li {
  margin-bottom: 2px;
}

.sidebar-nav a,
.sidebar-nav .nav-link-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .75) !important;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none !important;
  transition: all var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent !important;
}

.sidebar-nav a:hover,
.sidebar-nav .nav-link-custom:hover {
  background: var(--gold-muted) !important;
  color: var(--gold) !important;
  border-color: rgba(201, 162, 39, .2);
}

.sidebar-nav a.active,
.sidebar-nav .nav-link-custom.active {
  background: var(--gold-muted) !important;
  color: var(--gold) !important;
  border-color: rgba(201, 162, 39, .3);
}

.sidebar-nav a i,
.sidebar-nav .nav-link-custom i {
  font-size: 15px;
  width: 18px;
  flex-shrink: 0;
}

/* Badge de notificaciones */
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  margin-left: auto;
}

/* Sidebar divider */
.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin: 8px 10px;
}

/* Sidebar user footer */
.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-user .dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .8) !important;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user .dropdown-menu {
  background: var(--navy-light);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.sidebar-user .dropdown-item {
  color: rgba(255, 255, 255, .8);
  font-size: 13px;
  padding: 8px 16px;
}

.sidebar-user .dropdown-item:hover {
  background: var(--gold-muted);
  color: var(--gold);
}

/* ── Main content area (right of sidebar) ───────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.page-wrapper {
  flex: 1;
  padding: 24px 28px;
}

/* page-centered: fills available width AND height in the sidebar layout */
.page-centered {
  flex: 1 !important;
  align-self: stretch !important;
  /* stretch to full #app height */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 32px 24px;
}

/* ── Page title (also .page-title for custom pages) ─────────── */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card-pro {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 20px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 7px 14px !important;
  transition: all var(--transition) !important;
  margin: 0 3px 0 0;
  letter-spacing: .01em;
}

.btn-primary {
  background: var(--navy) !important;
  border-color: var(--navy) !important;
  color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--navy-hover) !important;
  border-color: var(--navy-hover) !important;
  box-shadow: 0 4px 12px rgba(13, 27, 54, .3) !important;
  transform: translateY(-1px);
}

.btn-success {
  background: #0f7a45 !important;
  border-color: #0f7a45 !important;
}

.btn-gold {
  background: var(--gold) !important;
  border-color: var(--gold) !important;
  color: var(--navy) !important;
  font-weight: 600 !important;
}

.btn-gold:hover {
  background: var(--gold-light) !important;
  border-color: var(--gold-light) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(201, 162, 39, .3) !important;
}

.btn-sm {
  padding: 4px 10px !important;
  font-size: 12px !important;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table {
  font-size: 13.5px;
  table-layout: auto;
  width: 100%;
}

.table thead th {
  background: var(--navy) !important;
  color: rgba(255, 255, 255, .9) !important;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 11px 12px;
  border: none !important;
  white-space: nowrap;
}

.table thead th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.table thead th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.table tbody tr {
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background: rgba(13, 27, 54, .04) !important;
}

.table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  color: var(--text-main);
  border-color: var(--border);
  line-height: 1.4;
}

/* First column (IDs / expediente numbers) — never wrap */
.table tbody td:first-child {
  white-space: nowrap;
  font-weight: 500;
  font-size: 13px;
}

/* Last column (action buttons) — never wrap */
.table tbody td:last-child {
  white-space: nowrap;
  text-align: right;
  width: 1%;
}

/* Tipo / text columns — allow wrapping but limit width */
.table tbody td:not(:first-child):not(:last-child) {
  max-width: 280px;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
  background-color: rgba(240, 244, 248, .5) !important;
}

/* table-responsive overflow smooth */
.table-responsive {
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Page title — from header-tool <h2> */
.relElement>h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--gold);
  display: inline-block;
}

/* Empty table body */
.table tbody:empty::after {
  content: 'Sin registros';
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ── Forms ──────────────────────────────────────────────────── */

/* Base inputs and selects */
.form-control,
.form-select {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 13.5px !important;
  transition: all var(--transition) !important;
  color: var(--text-main) !important;
  background: #fff !important;
  font-family: 'Inter', sans-serif !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--navy) !important;
  box-shadow: 0 0 0 3px rgba(13, 27, 54, .1) !important;
  outline: none !important;
}

/* ── form-floating overrides ─────────────────────────────────── */
/* Bootstrap form-floating label */
.form-floating>label {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: .04em !important;
  padding: 10px 12px !important;
  pointer-events: none;
}

/* Input inside form-floating */
.form-floating>.form-control {
  height: 52px !important;
  padding: 22px 12px 8px !important;
  line-height: 1.4 !important;
}

/* Select inside form-floating — CRITICAL: must have explicit height to not expand */
.form-floating>.form-select {
  height: 52px !important;
  padding: 20px 36px 6px 12px !important;
  line-height: 1.4 !important;
  appearance: auto !important;
  -webkit-appearance: auto !important;
  /* Shrink the internal listbox to 1 row */
  size: 1;
}

/* Label moves up when select/input is focused or has value */
.form-floating>.form-select~label,
.form-floating>.form-control:not(:placeholder-shown)~label,
.form-floating>.form-control:focus~label {
  opacity: .7 !important;
  transform: scale(.8) translateY(-0.75rem) translateX(0.15rem) !important;
}

/* ── Textarea ────────────────────────────────────────────────── */
textarea.form-control {
  height: auto !important;
  min-height: 90px !important;
  padding: 10px 12px !important;
  resize: vertical;
}

/* For form-floating textareas */
.form-floating>textarea.form-control {
  padding-top: 22px !important;
  padding-bottom: 8px !important;
  height: 90px !important;
}

/* ── File uploader ───────────────────────────────────────────── */
.form-floating>input[type="file"].form-control,
input.fileItem {
  height: auto !important;
  padding: 10px 12px !important;
  cursor: pointer;
}

.form-floating>input[type="file"]~label {
  transform: scale(.8) translateY(-0.5rem) translateX(0.15rem) !important;
  opacity: .7 !important;
}

/* Progress bar for uploader */
.form-floating.mb-2 .progress {
  height: 6px;
  border-radius: 3px;
  margin-top: 4px;
  background: var(--border);
}

.form-floating.mb-2 .progress-bar {
  background: linear-gradient(90deg, var(--navy), var(--gold));
  border-radius: 3px;
  transition: width .3s ease;
}

/* ── Checkbox list (check-tool) ──────────────────────────────── */
.form-floating.mb-2>span {
  display: block;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: .04em !important;
  margin-bottom: 6px;
}

.form-floating.mb-2>div input[type="checkbox"] {
  accent-color: var(--navy);
  width: 15px;
  height: 15px;
  cursor: pointer;
  margin-right: 6px;
  vertical-align: middle;
}

.form-floating.mb-2>div label {
  font-size: 13px !important;
  color: var(--text-main) !important;
  cursor: pointer;
  vertical-align: middle;
}

/* Checkbox rows spacing */
.form-floating.mb-2>div {
  padding: 3px 0;
  border-bottom: 1px solid rgba(0, 0, 0, .04);
}

/* ── Search tool results list ────────────────────────────────── */
.list-group-item {
  font-size: 13px;
  padding: 8px 12px;
  border-color: var(--border);
  color: var(--text-main);
  cursor: pointer;
}

.list-group-item:hover,
.list-group-item-action:hover {
  background: rgba(13, 27, 54, .05) !important;
  color: var(--navy) !important;
}

/* ── Form label (standalone .form-label) ─────────────────────── */
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}

/* ── mb-2 spacing inside modals ─────────────────────────────── */
.modal-body .form-floating.mb-2 {
  margin-bottom: 12px !important;
}


/* ── Modals ─────────────────────────────────────────────────── */
.modal-header {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 20px;
  border: none;
}

.modal-title {
  font-weight: 600;
  font-size: 15px;
}

.modal-header .btn-close {
  filter: invert(1);
  opacity: .7;
}

.modal-header .btn-close:hover {
  opacity: 1;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

.modal-content {
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow-lg);
}

/* Modal size fix — make modals wider and scrollable */
.modal-dialog {
  max-width: 680px !important;
  margin: 1.75rem auto;
}

.modal-body {
  padding: 20px 24px;
  max-height: 72vh;
  overflow-y: auto;
}

/* Scrollbar inside modal */
.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(13, 27, 54, .15);
  border-radius: 3px;
}

/* Grid layout for modal form fields */
.modal-body .row {
  margin-bottom: 8px;
}

/* ── Table alignment fixes ──────────────────────────────────── */
.table tbody td {
  padding: 11px 14px;
  vertical-align: top !important;
  color: var(--text-main);
  border-color: var(--border);
}

/* Break long permission strings gracefully */
.table tbody td:not(:first-child):not(:last-child) {
  word-break: break-word;
  min-width: 80px;
}

/* Column with many badge-like permissions */
.table td .permissions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.perm-badge {
  display: inline-block;
  background: rgba(13, 27, 54, .07);
  color: var(--navy);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}


/* ── Profile page utilities ──────────────────────────────────── */

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

.profile-card-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-hover) 100%);
  padding: 36px 32px 28px;
  text-align: center;
  position: relative;
}

.profile-card-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

.profile-card-header h2 {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.profile-card-header p {
  color: var(--gold);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 0;
}

.profile-card-body {
  padding: 28px 32px;
}

.profile-form-group {
  margin-bottom: 18px;
}

.profile-form-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.profile-form-group input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  background: #fafbfc;
  transition: all .2s ease;
  outline: none;
}

.profile-form-group input:focus {
  border-color: var(--navy);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13, 27, 54, .1);
}

.profile-submit {
  width: 100%;
  padding: 12px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all .22s ease;
  margin-top: 4px;
}

.profile-submit:hover {
  background: var(--navy-hover);
  box-shadow: 0 4px 16px rgba(13, 27, 54, .3);
  transform: translateY(-1px);
}

.profile-tip {
  margin-top: 16px;
  background: rgba(201, 162, 39, .1);
  border: 1px solid rgba(201, 162, 39, .25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: #7a6010;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Header toolbar (search + actions row) ──────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Notifications dropdown ─────────────────────────────────── */
.contenedor-notificaciones a {
  background: transparent;
  border: 1px solid transparent !important;
  padding: 8px 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, .75);
  transition: color var(--transition);
}

.contenedor-notificaciones a:hover {
  color: var(--gold);
}

/* ── Misc utilities ─────────────────────────────────────────── */
.bbja {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.changeSearchBtn {
  position: absolute;
  top: 3px;
  right: 3px;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  text-align: center;
  border: solid 1px var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--transition);
}

.changeSearchBtn:hover {
  background: var(--border);
}

/* ── Edit tool overlay ──────────────────────────────────────── */
.editTool {
  position: absolute;
  width: 100%;
  height: 100%;
  border: solid 1.5px var(--gold);
  border-style: dashed;
  display: none;
}

.etTitle {
  background: var(--gold);
  color: var(--navy);
  position: absolute;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0px 10px 0px 5px;
  font-size: 11px;
  font-weight: 600;
  top: -20px;
  z-index: 2000;
}

.relElement {
  position: relative;
}

/* ── Scrollbar styling ──────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(13, 27, 54, .2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(13, 27, 54, .35);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 64px;
  }

  .sidebar-brand .brand-name,
  .sidebar-brand .brand-sub,
  .sidebar-nav a span {
    display: none;
  }

  .sidebar-nav a {
    justify-content: center;
    padding: 12px;
  }

  .sidebar-nav a i {
    font-size: 18px;
  }

  .sidebar-badge {
    position: absolute;
    top: 6px;
    right: 6px;
  }

  .page-wrapper {
    padding: 16px;
  }
}