/* ═══════════════════════════════════════════════════════
   REDMED – Public App Shell
   Sistema de Coleta de Dados Hospitalares
   Dr. Ruddy Baracho Klein | Engenheiro Clínico
═══════════════════════════════════════════════════════ */

:root {
  --rm-primary:    #0e6b8c;
  --rm-primary-dk: #094f69;
  --rm-secondary:  #14a0c0;
  --rm-accent:     #f0a500;
  --rm-accent-lt:  #fff4d6;
  --rm-dark:       #1a2530;
  --rm-sidebar-w:  240px;
  --rm-light:      #f4f9fc;
  --rm-border:     #dde6ed;
  --rm-success:    #2e9e5b;
  --rm-danger:     #d93025;
  --rm-warn:       #f59e0b;
  --rm-info:       #0ea5e9;
  --rm-radius:     8px;
  --rm-shadow:     0 2px 12px rgba(14,107,140,.10);
}

/* ── Reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin:0; padding:0; }
.rm-app { font-family: 'Segoe UI', system-ui, Arial, sans-serif; font-size: 14px;
  color: #2d3748; background: #eef3f7; min-height: 500px; position: relative; }
.rm-app a { color: var(--rm-primary); text-decoration: none; }
.rm-app button, .rm-app input, .rm-app select, .rm-app textarea {
  font-family: inherit; font-size: inherit; }

/* ═══════════════════════════════════════════════════
   LAYOUT: sidebar + main
═══════════════════════════════════════════════════ */
.rm-shell   { display: flex; min-height: 600px; }
.rm-sidebar { width: var(--rm-sidebar-w); flex-shrink: 0; background: var(--rm-dark);
  display: flex; flex-direction: column; border-radius: var(--rm-radius) 0 0 var(--rm-radius);
  position: relative; z-index: 10; }
.rm-main    { flex: 1; min-width: 0; background: var(--rm-light);
  border-radius: 0 var(--rm-radius) var(--rm-radius) 0; overflow: hidden; }

/* ── Sidebar header ── */
.rm-sb-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.rm-sb-logo { font-size: 1.25rem; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.rm-sb-logo span { color: var(--rm-accent); }
.rm-sb-sub  { font-size: .68rem; color: rgba(255,255,255,.45); margin-top: 2px; text-transform: uppercase; letter-spacing: .06em; }

/* ── Nav sections ── */
.rm-sb-section-lbl {
  padding: 10px 16px 4px;
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.3);
}
.rm-sb-nav { list-style: none; padding: 0 8px; }
.rm-sb-nav li + li { margin-top: 1px; }
.rm-sb-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px;
  font-size: .82rem; font-weight: 500; color: rgba(255,255,255,.65);
  transition: .15s; cursor: pointer;
}
.rm-sb-nav a:hover   { background: rgba(255,255,255,.07); color: #fff; }
.rm-sb-nav a.active  { background: var(--rm-primary); color: #fff; }
.rm-sb-nav a .rm-sb-icon { width: 16px; text-align: center; font-size: .85rem; flex-shrink: 0; }
.rm-sb-nav a .rm-sb-badge {
  margin-left: auto; background: var(--rm-accent); color: #1a2530;
  font-size: .6rem; font-weight: 800; padding: 1px 5px; border-radius: 20px;
}

/* ── Sidebar footer ── */
.rm-sb-footer {
  margin-top: auto; padding: 14px 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .67rem; color: rgba(255,255,255,.35); line-height: 1.5;
}
.rm-sb-footer strong { color: rgba(255,255,255,.6); display: block; font-size: .7rem; }

/* ── Mobile sidebar toggle ── */
.rm-sb-toggle {
  display: none; position: absolute; top: 10px; left: 10px; z-index: 20;
  background: var(--rm-dark); color: #fff; border: none; border-radius: 6px;
  width: 36px; height: 36px; font-size: 1.1rem; cursor: pointer; align-items: center; justify-content: center;
}

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════ */
.rm-page { display: none; padding: 24px 28px; }
.rm-page.active { display: block; }
.rm-page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 20px;
  padding-bottom: 14px; border-bottom: 2px solid var(--rm-border);
}
.rm-page-title { font-size: 1.15rem; font-weight: 700; color: var(--rm-primary); display: flex; align-items: center; gap: 8px; }
.rm-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════
   DASHBOARD CARDS
═══════════════════════════════════════════════════ */
.rm-dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.rm-dash-card {
  background: #fff; border: 1px solid var(--rm-border);
  border-radius: var(--rm-radius); padding: 16px; text-align: center;
  box-shadow: var(--rm-shadow); cursor: pointer; transition: .15s;
  border-top: 3px solid var(--rm-primary);
}
.rm-dash-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(14,107,140,.15); }
.rm-dash-card-num { font-size: 2rem; font-weight: 800; color: var(--rm-primary); line-height: 1; }
.rm-dash-card-lbl { font-size: .75rem; color: #718096; margin-top: 4px; font-weight: 500; }

.rm-dash-recent { background: #fff; border: 1px solid var(--rm-border); border-radius: var(--rm-radius); overflow: hidden; box-shadow: var(--rm-shadow); }
.rm-dash-recent-hdr { background: var(--rm-primary); color: #fff; padding: 10px 16px; font-size: .8rem; font-weight: 700; }

/* ═══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.rm-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px; border-radius: 6px; font-size: .8rem;
  font-weight: 600; cursor: pointer; border: none; text-decoration: none;
  transition: .15s; white-space: nowrap;
}
.rm-btn-primary   { background: var(--rm-primary);   color: #fff; }
.rm-btn-primary:hover { background: var(--rm-primary-dk); color: #fff; }
.rm-btn-secondary { background: var(--rm-secondary); color: #fff; }
.rm-btn-secondary:hover { background: #0e8fac; color: #fff; }
.rm-btn-accent    { background: var(--rm-accent);    color: #1a2530; }
.rm-btn-accent:hover { background: #d48e00; color: #1a2530; }
.rm-btn-success   { background: var(--rm-success);   color: #fff; }
.rm-btn-danger    { background: var(--rm-danger);     color: #fff; padding: 6px 10px; }
.rm-btn-ghost     { background: transparent; border: 1.5px solid var(--rm-border); color: #4a5568; }
.rm-btn-ghost:hover { background: var(--rm-border); }
.rm-btn-sm { padding: 5px 10px; font-size: .74rem; }
/* individual action buttons */
.rm-act-edit   { background: #14a0c0; color: #fff; }
.rm-act-edit:hover   { background: #0e6b8c; color: #fff; }
.rm-act-copy   { background: var(--rm-accent); color: #1a2530; }
.rm-act-copy:hover   { background: #d48e00; color: #1a2530; }
.rm-act-csv    { background: var(--rm-success); color: #fff; }
.rm-act-csv:hover    { background: #25804a; color: #fff; }
.rm-act-hist   { background: #6c757d; color: #fff; }
.rm-act-hist:hover   { background: #495057; color: #fff; }
.rm-act-print  { background: #17a2b8; color: #fff; }
.rm-act-print:hover  { background: #117a8b; color: #fff; }

/* ═══════════════════════════════════════════════════
   NOTICES
═══════════════════════════════════════════════════ */
.rm-notice {
  padding: 10px 16px; border-radius: var(--rm-radius);
  font-size: .82rem; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px;
}
.rm-notice-ok   { background: #d4edda; border-left: 4px solid var(--rm-success); color: #1a5c33; }
.rm-notice-warn { background: #fff3cd; border-left: 4px solid var(--rm-warn);    color: #7c5800; }
.rm-notice-info { background: #d1ecf1; border-left: 4px solid var(--rm-info);    color: #0c5460; }

/* ═══════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════ */
.rm-table-wrap { overflow-x: auto; border-radius: var(--rm-radius); box-shadow: var(--rm-shadow); }
.rm-table { width: 100%; border-collapse: collapse; background: #fff; font-size: .82rem; }
.rm-table thead th {
  background: var(--rm-primary); color: #fff; padding: 10px 12px;
  text-align: left; font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.rm-table tbody td { padding: 9px 12px; border-bottom: 1px solid #f0f4f8; vertical-align: middle; }
.rm-table tbody tr:last-child td { border-bottom: none; }
.rm-table tbody tr:hover td { background: #f8fbfd; }
.rm-table .rm-actions { display: flex; flex-wrap: wrap; gap: 4px; min-width: 230px; }

/* ═══════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════ */
.rm-form-panel { background: #fff; border: 1px solid var(--rm-border); border-radius: var(--rm-radius); box-shadow: var(--rm-shadow); }
.rm-fieldset   { border: none; border-top: 1px solid var(--rm-border); padding: 0; }
.rm-fieldset:first-child { border-top: none; }
.rm-legend {
  display: block; padding: 10px 20px 0; margin: 0;
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--rm-secondary);
}
.rm-fields { padding: 12px 20px 16px; }
.rm-row    { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.rm-row:last-child { margin-bottom: 0; }
.rm-field  { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }
.rm-field.full { flex: 1 1 100%; }
.rm-field label { font-size: .72rem; font-weight: 700; color: #4a5568; }
.rm-field input, .rm-field select, .rm-field textarea {
  padding: 7px 10px; border: 1.5px solid var(--rm-border); border-radius: 6px;
  font-size: .82rem; width: 100%; background: #fff; color: #2d3748; transition: .15s;
}
.rm-field input:focus, .rm-field select:focus, .rm-field textarea:focus {
  outline: none; border-color: var(--rm-secondary); box-shadow: 0 0 0 3px rgba(20,160,192,.12);
}
.rm-field textarea { min-height: 68px; resize: vertical; }
.rm-form-footer { padding: 16px 20px; border-top: 1px solid var(--rm-border); display: flex; gap: 10px; flex-wrap: wrap; background: #f8fbfd; border-radius: 0 0 var(--rm-radius) var(--rm-radius); }

/* ═══════════════════════════════════════════════════
   ORCAMENTO ITEMS TABLE
═══════════════════════════════════════════════════ */
.rm-orc-table { width: 100%; border-collapse: collapse; font-size: .78rem; min-width: 750px; }
.rm-orc-table th { background: #f1f5f9; color: #4a5568; font-size: .7rem; padding: 6px 8px; border: 1px solid var(--rm-border); text-align: left; }
.rm-orc-table td { border: 1px solid #eef1f4; padding: 3px 5px; }
.rm-orc-table input, .rm-orc-table select { width: 100%; border: none; background: transparent; font-size: .78rem; padding: 2px 4px; }
.rm-orc-table input:focus { outline: 1px solid var(--rm-secondary); border-radius: 2px; }
.rm-orc-table input[readonly] { background: #f4f9fc; color: var(--rm-primary); font-weight: 700; }
.rm-orc-total-row td { background: #e8f4f8; font-weight: 700; border-top: 2px solid var(--rm-primary); }

/* ═══════════════════════════════════════════════════
   INLINE EDIT / HISTORY PANEL
═══════════════════════════════════════════════════ */
.rm-edit-panel { border: 2px solid var(--rm-primary); border-radius: var(--rm-radius); overflow: hidden; margin-bottom: 20px; box-shadow: 0 4px 20px rgba(14,107,140,.18); animation: rm-slide .22s ease; }
@keyframes rm-slide { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: translateY(0); } }
.rm-edit-header { background: var(--rm-primary); color: #fff; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .84rem; font-weight: 700; }
.rm-edit-close { background: rgba(255,255,255,.18); color: #fff; padding: 4px 12px; border-radius: 4px; font-size: .78rem; cursor: pointer; border: none; transition: .15s; }
.rm-edit-close:hover { background: rgba(255,255,255,.32); }
.rm-edit-body { background: #fff; }

/* ═══════════════════════════════════════════════════
   HISTORY TABLE
═══════════════════════════════════════════════════ */
.rm-hist-filter { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; padding: 14px 16px; background: #fff; border: 1px solid var(--rm-border); border-radius: var(--rm-radius); }
.rm-hist-filter select, .rm-hist-filter input { padding: 7px 10px; border: 1.5px solid var(--rm-border); border-radius: 6px; font-size: .8rem; }
.rm-icon-criar   { color: var(--rm-success); }
.rm-icon-editar  { color: var(--rm-info); }
.rm-icon-copiar  { color: var(--rm-accent); }
.rm-icon-excluir { color: var(--rm-danger); }

/* ═══════════════════════════════════════════════════
   PDF / PRINT FULL DOC
═══════════════════════════════════════════════════ */
.rm-doc-preview {
  background: #fff; border: 1px solid var(--rm-border); border-radius: var(--rm-radius);
  padding: 30px; font-size: .84rem; line-height: 1.6; box-shadow: var(--rm-shadow);
}
.rm-doc-header-bar { background: var(--rm-dark); color: #fff; padding: 14px 20px; border-radius: var(--rm-radius); display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 8px; }
.rm-doc-brand { font-size: 1.2rem; font-weight: 800; color: #fff; }
.rm-doc-brand span { color: var(--rm-accent); }
.rm-doc-info { font-size: .72rem; opacity: .8; text-align: right; }
.rm-doc-title { font-size: 1.1rem; font-weight: 700; color: var(--rm-primary); border-bottom: 2px solid var(--rm-primary); padding-bottom: 8px; margin-bottom: 18px; }
.rm-doc-section { margin-bottom: 16px; }
.rm-doc-section-title { background: var(--rm-primary); color: #fff; padding: 6px 12px; font-size: .78rem; font-weight: 700; border-radius: 4px 4px 0 0; }
.rm-doc-section-body { border: 1px solid var(--rm-border); border-top: none; border-radius: 0 0 4px 4px; padding: 12px; }
.rm-doc-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 0; }
.rm-doc-label { font-size: .74rem; font-weight: 700; color: #718096; padding: 4px 8px; border-bottom: 1px solid #f0f4f8; }
.rm-doc-value { font-size: .82rem; padding: 4px 8px; border-bottom: 1px solid #f0f4f8; }
.rm-doc-grid .rm-doc-label:last-of-type, .rm-doc-grid .rm-doc-value:last-of-type { border-bottom: none; }
.rm-doc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px,1fr)); gap: 8px; }
.rm-doc-stat { background: var(--rm-light); border: 1px solid var(--rm-border); border-radius: 4px; padding: 8px; text-align: center; }
.rm-doc-stat strong { display: block; font-size: 1.1rem; color: var(--rm-primary); }
.rm-doc-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.rm-doc-table th { background: var(--rm-primary); color: #fff; padding: 6px 8px; text-align: left; font-size: .72rem; }
.rm-doc-table td { padding: 5px 8px; border-bottom: 1px solid #f0f4f8; }
.rm-doc-table .cat-row td { background: #e8f4f8; font-weight: 700; color: var(--rm-primary); font-size: .74rem; }
.rm-doc-table tfoot td { background: var(--rm-primary-dk); color: #fff; font-weight: 700; }
.rm-total-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.rm-total-box { padding: 14px; border-radius: var(--rm-radius); text-align: center; }
.rm-total-box-m { background: var(--rm-light); border: 1px solid var(--rm-primary); }
.rm-total-box-a { background: var(--rm-dark); color: #fff; }
.rm-total-box small { display: block; font-size: .7rem; opacity: .7; }
.rm-total-box strong { display: block; font-size: 1.3rem; font-weight: 800; color: var(--rm-accent); }
.rm-total-box-m strong { color: var(--rm-primary); }

/* ═══════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .rm-shell { flex-direction: column; }
  .rm-sidebar { width: 100%; border-radius: var(--rm-radius) var(--rm-radius) 0 0; max-height: 54px; overflow: hidden; transition: max-height .3s ease; }
  .rm-sidebar.open { max-height: 600px; }
  .rm-sb-toggle { display: flex; position: static; margin: 9px 12px 9px auto; }
  .rm-sb-brand { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
  .rm-main { border-radius: 0 0 var(--rm-radius) var(--rm-radius); }
  .rm-page { padding: 16px; }
  .rm-row { flex-direction: column; }
  .rm-field { flex: 1 1 100%; }
  .rm-table .rm-actions { flex-direction: column; }
  .rm-doc-grid { grid-template-columns: 1fr; }
  .rm-total-boxes { grid-template-columns: 1fr; }
}

@media print {
  .rm-sidebar, .rm-page-actions, .rm-form-footer, .rm-actions,
  .rm-notice, .rm-hist-filter, .rm-btn, button { display: none !important; }
  .rm-main { border-radius: 0; }
  .rm-page { padding: 0; }
  .rm-page.active { display: block !important; }
  @page { margin: 15mm; }
}
