/* ============================================================
   app.css — Bolsas de Horas IT
   Estilo: Microsoft Fluent / Windows 11
   ============================================================ */

:root {
  --accent:       #1B2A4A;
  --accent-dk:    #111D33;
  --accent-light: #EFF6FC;
  --accent-mid:   #C7E0F4;
  --btn-accent:   #0078D4;   /* azul para botones/links */

  --bg:           #F3F2F1;
  --surface:      #FFFFFF;
  --surface2:     #FAF9F8;
  --border:       #EDEBE9;
  --border-dk:    #D2D0CE;

  --text:         #323130;
  --text-sub:     #605E5C;
  --text-dis:     #A19F9D;

  --ok:           #107C10;
  --ok-light:     #DFF6DD;
  --warn:         #D83B01;
  --warn-light:   #FED9CC;
  --danger:       #A4262C;
  --danger-light: #FDE7E9;
  --info-light:   #EFF6FC;

  --nav-h:        48px;
  --sidebar-w:    220px;

  --radius:       4px;
  --radius-lg:    6px;
  --shadow-card:  0 1.6px 3.6px rgba(0,0,0,.132), 0 .3px .9px rgba(0,0,0,.108);
  --shadow-depth: 0 6.4px 14.4px rgba(0,0,0,.132), 0 1.2px 3.6px rgba(0,0,0,.108);
  --shadow-fly:   0 25.6px 57.6px rgba(0,0,0,.22), 0 4.8px 14.4px rgba(0,0,0,.18);

  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════
   TOP NAV (estilo Microsoft 365)
══════════════════════════════ */
.ms-nav {
  height: var(--nav-h);
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

.ms-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  padding: 0 12px 0 0;
  margin-right: 4px;
  border-right: 1px solid rgba(255,255,255,.25);
}
.ms-nav-brand .app-icon {
  font-size: 1.2rem;
  background: rgba(255,255,255,.2);
  width: 30px; height: 30px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.ms-nav-brand span {
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.ms-nav-items {
  display: flex;
  align-items: center;
  flex: 1;
  padding-left: 8px;
  gap: 2px;
}
.ms-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--nav-h);
  padding: 0 14px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 400;
  border-bottom: 2px solid transparent;
  transition: color .1s, background .1s, border-color .1s;
  white-space: nowrap;
}
.ms-nav-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.ms-nav-item.active {
  color: #fff;
  border-bottom-color: #fff;
  font-weight: 600;
}

.ms-nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.ms-nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: default;
}
.ms-nav-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.4);
}
.ms-nav-username {
  font-size: .8125rem;
  color: rgba(255,255,255,.9);
  font-weight: 500;
}
.ms-nav-logout {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .8125rem;
  transition: background .1s;
}
.ms-nav-logout:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ══════════════════════════════
   PAGE HEADER (breadcrumb style)
══════════════════════════════ */
.page-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head-left { display: flex; flex-direction: column; gap: 1px; }
.page-head h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}
.page-head-sub {
  font-size: .8125rem;
  color: var(--text-sub);
}
.page-head-actions { display: flex; gap: 8px; align-items: center; }

/* ══════════════════════════════
   LAYOUT
══════════════════════════════ */
.main-wrap {
  flex: 1;
  padding: 20px 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ══════════════════════════════
   COMMAND BAR (acción secundaria)
══════════════════════════════ */
.cmd-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cmd-bar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-dk);
  margin: 0 4px;
}

/* ══════════════════════════════
   CARDS / PANELS
══════════════════════════════ */
.ms-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}

.ms-card-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  gap: 12px;
  flex-wrap: wrap;
}
.ms-card-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
}
.ms-card-body { padding: 20px; }

/* ══════════════════════════════
   STAT TILES
══════════════════════════════ */
.ms-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.ms-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  border-top: 3px solid var(--accent);
  transition: box-shadow .15s;
}
.ms-tile:hover { box-shadow: var(--shadow-depth); }
.ms-tile.ok     { border-top-color: var(--ok); }
.ms-tile.warn   { border-top-color: #FFB900; }
.ms-tile.danger { border-top-color: var(--danger); }

.ms-tile-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.1;
  display: block;
  margin-bottom: 4px;
}
.ms-tile-label {
  font-size: .75rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ══════════════════════════════
   TABLA (DetailsList style)
══════════════════════════════ */
.ms-list { width: 100%; border-collapse: collapse; font-size: .875rem; }

.ms-list thead th {
  text-align: left;
  padding: 8px 14px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1.5px solid var(--border-dk);
  white-space: nowrap;
  background: var(--surface2);
  user-select: none;
}
.ms-list thead th:hover { color: var(--text); cursor: pointer; }

.ms-list tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.ms-list tbody tr:last-child td { border-bottom: none; }
.ms-list tbody tr:hover td { background: #F3F9FD; }
.ms-list tbody tr.selected td { background: var(--accent-light); }

/* ══════════════════════════════
   PROGRESS BAR
══════════════════════════════ */
.ms-progress { margin: 6px 0 2px; }
.ms-progress-track {
  height: 4px;
  background: var(--border-dk);
  border-radius: 2px;
  overflow: hidden;
}
.ms-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .5s ease;
}
.ms-progress-fill.ok     { background: var(--ok); }
.ms-progress-fill.warn   { background: #FFB900; }
.ms-progress-fill.danger { background: var(--danger); }
.ms-progress-label {
  font-size: .7rem;
  color: var(--text-sub);
  text-align: right;
  margin-top: 2px;
}

/* ══════════════════════════════
   BOTONES (Fluent)
══════════════════════════════ */
.ms-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 32px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .1s, border-color .1s, box-shadow .1s;
  white-space: nowrap;
}
.ms-btn:active { opacity: .85; transform: scale(.99); }

.ms-btn-primary {
  background: var(--btn-accent);
  color: #fff;
  border-color: var(--btn-accent);
}
.ms-btn-primary:hover { background: #005A9E; border-color: #005A9E; }

.ms-btn-default {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-dk);
}
.ms-btn-default:hover { background: var(--surface2); border-color: #C8C6C4; }

.ms-btn-subtle {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.ms-btn-subtle:hover { background: var(--border); }

.ms-btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(164,38,44,.3);
}
.ms-btn-danger:hover { background: var(--danger); color: #fff; }

.ms-btn-sm { height: 26px; padding: 0 10px; font-size: .8125rem; }
.ms-btn-icon { padding: 0 8px; }

/* ══════════════════════════════
   FORMULARIOS (TextField style)
══════════════════════════════ */
.ms-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.ms-form-grid.cols-1 { grid-template-columns: 1fr; }
@media (max-width: 640px) { .ms-form-grid { grid-template-columns: 1fr; } }

.ms-field { display: flex; flex-direction: column; gap: 4px; }
.ms-field.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .ms-field.span-2 { grid-column: span 1; } }

.ms-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
}
.ms-label .optional {
  font-weight: 400;
  color: var(--text-sub);
  font-size: .8125rem;
}

.ms-input,
.ms-select,
.ms-textarea {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .1s, box-shadow .1s;
  width: 100%;
}
.ms-input:hover, .ms-select:hover { border-color: #8A8886; }
.ms-input:focus, .ms-select:focus, .ms-textarea:focus {
  border-color: var(--btn-accent);
  box-shadow: 0 0 0 1px var(--btn-accent);
}
.ms-textarea {
  height: auto;
  min-height: 72px;
  padding: 6px 8px;
  resize: vertical;
}

/* ══════════════════════════════
   BADGES / PILLS
══════════════════════════════ */
.ms-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: .75rem;
  font-weight: 600;
}
.ms-badge-ok     { background: var(--ok-light);     color: #0B6A0B; }
.ms-badge-warn   { background: #FFF4CE;              color: #7A4100; }
.ms-badge-danger { background: var(--danger-light);  color: var(--danger); }
.ms-badge-neutral{ background: var(--border);        color: var(--text-sub); }
.ms-badge-blue   { background: var(--accent-light);  color: var(--accent-dk); }

/* ══════════════════════════════
   MODAL (Panel style)
══════════════════════════════ */
.ms-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ms-overlay.open { display: flex; }

.ms-dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-fly);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  animation: ms-dialog-in .15s ease;
}
@keyframes ms-dialog-in {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
.ms-dialog-lg { max-width: 640px; }

.ms-dialog-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.ms-dialog-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
}
.ms-dialog-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-sub);
  padding: 2px 6px;
  border-radius: var(--radius);
  line-height: 1;
  flex-shrink: 0;
}
.ms-dialog-close:hover { background: var(--border); color: var(--text); }

.ms-dialog-body { padding: 20px 24px; }
.ms-dialog-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface2);
}

/* ══════════════════════════════
   MENSAJES
══════════════════════════════ */
.ms-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .875rem;
  border-left: 4px solid transparent;
  animation: slideDown .2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ms-msg-ok      { background: var(--ok-light);     border-color: var(--ok);     color: #0B6A0B; }
.ms-msg-error   { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.ms-msg-info    { background: var(--info-light);   border-color: var(--accent); color: var(--accent-dk); }
.ms-msg-icon    { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ══════════════════════════════
   LOGIN
══════════════════════════════ */
.ms-login-wrap {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-depth);
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
}
.ms-login-logo {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.ms-login-logo .app-icon-lg {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 12px;
}
.ms-login-logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}
.ms-login-logo p { font-size: .875rem; color: var(--text-sub); margin-top: 2px; }
.ms-login-box .ms-field + .ms-field { margin-top: 14px; }
.ms-login-box .ms-btn { width: 100%; justify-content: center; margin-top: 20px; height: 36px; font-size: .9375rem; }

/* ══════════════════════════════
   MISC
══════════════════════════════ */
.text-sub   { color: var(--text-sub); }
.text-sm    { font-size: .8125rem; }
.text-xs    { font-size: .75rem; }
.text-right { text-align: right; }
.flex       { display: flex; }
.items-center { align-items: center; }
.gap-2      { gap: 8px; }
.gap-1      { gap: 4px; }
.mt-4       { margin-top: 4px; }
.font-600   { font-weight: 600; }

.ms-footer {
  padding: 12px 24px;
  font-size: .75rem;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Checkbox estilo Fluent */
.ms-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .875rem;
}
.ms-check input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Mobile first breakpoints
   480px  = small phones
   768px  = tablets / large phones landscape
══════════════════════════════════════════════════════ */

/* ── Hamburger button (hidden on desktop) ── */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: #fff;
  flex-direction: column;
  gap: 4px;
  margin-left: auto;
}
.nav-hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .2s;
}

/* ── Mobile nav drawer ── */
.ms-nav-drawer {
  display: none;
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  background: var(--accent);
  z-index: 190;
  border-top: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  padding: 8px 0 12px;
}
.ms-nav-drawer.open { display: block; }
.ms-nav-drawer .ms-nav-item {
  height: 44px;
  padding: 0 20px;
  display: flex;
  width: 100%;
  border-bottom: none;
  font-size: 1rem;
}
.ms-nav-drawer .ms-nav-item.active {
  background: rgba(255,255,255,.12);
  border-left: 3px solid #fff;
  padding-left: 17px;
}
.ms-nav-drawer .ms-nav-item:hover { background: rgba(255,255,255,.1); }

@media (max-width: 768px) {

  /* Nav */
  .ms-nav-items   { display: none; }   /* desktop tabs hidden */
  .nav-hamburger  { display: flex; }
  .ms-nav-username { display: none; }  /* save space */
  .ms-nav-brand span { font-size: .85rem; }

  /* Page header */
  .page-head {
    padding: 10px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .page-head-actions { width: 100%; }
  .page-head-actions .ms-btn { width: 100%; justify-content: center; }

  /* Main content */
  .main-wrap { padding: 12px 12px; }

  /* Tiles: 2 columns on tablet, 1 on phone */
  .ms-tiles { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Cards */
  .ms-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Tables → card-list on mobile */
  .ms-table-responsive thead { display: none; }
  .ms-table-responsive tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    padding: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }
  .ms-table-responsive tbody tr:hover { background: var(--surface); }
  .ms-table-responsive tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0;
    border-bottom: none;
    gap: 8px;
    font-size: .875rem;
  }
  .ms-table-responsive tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .75rem;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: .06em;
    flex-shrink: 0;
    min-width: 90px;
  }
  .ms-table-responsive tbody td:empty { display: none; }
  .ms-table-responsive tfoot { display: none; }

  /* Forms */
  .ms-form-grid { grid-template-columns: 1fr; }
  .ms-field.span-2 { grid-column: span 1; }

  /* Dialogs: full screen on mobile */
  .ms-overlay { padding: 0; align-items: flex-end; }
  .ms-dialog {
    max-width: 100% !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .ms-dialog-body {
    overflow-y: auto;
    flex: 1;
    max-height: none !important;
  }

  /* Command bar */
  .cmd-bar { flex-wrap: wrap; gap: 8px; }
  .cmd-bar select { width: 100%; }

  /* Login */
  .ms-login-box { padding: 28px 20px; }

  /* Bolsas: client group header */
  .bolsa-group-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  .bolsa-saldo-box { width: 100%; text-align: left !important; }
  .bolsa-saldo-box .ms-progress { width: 100% !important; margin-left: 0 !important; }
}

@media (max-width: 480px) {
  /* Single column tiles on small phones */
  .ms-tiles { grid-template-columns: 1fr; }

  /* Smaller tile values */
  .ms-tile-val { font-size: 1.4rem; }

  /* Nav brand shorter */
  .ms-nav-brand span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

  /* Buttons in action groups stack */
  .flex.gap-1 { flex-wrap: wrap; }

  /* Stats in bolsa detail: single column */
  .bolsa-stats-grid { grid-template-columns: 1fr !important; }
}
