/* Palette */
:root {
  --burgundy: #b22218;
  --burgundy-dark: #851912;
  --burgundy-soft: #fae9e8;
  --ink: #29232a;
  --muted: #7b7079;
  --line: #eae3e7;
  --canvas: #faf8f9;
  --white: #fff;
}

body, .main-header .logo {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body { color: var(--ink); font-size: 14px; }
a { color: var(--burgundy); }
a:hover, a:focus { color: var(--burgundy-dark); }
.content-wrapper, .right-side { background: var(--canvas); }
.content { max-width: none; padding: 14px; margin: 0; }

/* Navigazione */
.main-header .logo { display: none !important; }
.skin-blue .main-header .navbar { margin-left: 0; }
.app-title { padding: 0 24px; line-height: 50px; color: var(--burgundy); font-size: 24px; font-weight: 600; }
.sidebar-logo { padding: 22px 22px 18px; text-align: center; }
.sidebar-logo img { display: block; width: 100%; max-width: 188px; height: 138px; object-fit: contain; margin: 0 auto; }
.sidebar-logo img[hidden] { display: none; }
.sidebar-logo-fallback { display: none; font-weight: 700; color: var(--burgundy); }
.logo-unavailable .sidebar-logo-fallback { display: block; }
.sidebar-mini.sidebar-collapse .sidebar-logo { display: none; }
.skin-blue .main-header .navbar { background: white; border-bottom: 1px solid var(--line); }
.skin-blue .main-header .navbar .sidebar-toggle,
.skin-blue .main-header .navbar .nav > li > a { color: var(--burgundy); }
.skin-blue .main-header .navbar .sidebar-toggle:hover { background: var(--burgundy-soft); color: var(--burgundy); }
.skin-blue .main-sidebar { background: white; border-right: 1px solid var(--line); }
.sidebar-menu { padding: 0 12px; }
.skin-blue .sidebar-menu > li > a {
  color: #655a63; border: 0; border-radius: 8px; padding: 13px 14px;
  margin-bottom: 5px; font-weight: 550; font-size: 15px;
}
.skin-blue .sidebar-menu > li.active > a,
.skin-blue .sidebar-menu > li:hover > a {
  color: var(--burgundy); background: var(--burgundy-soft); border: 0;
}
.sidebar-menu > li > a > .fa { width: 24px; }
.sidebar-mini.sidebar-collapse .sidebar-menu { padding: 0; }
/* Pagine e pannelli */
.page-heading { margin-bottom: 16px; }
.page-heading h1 { margin: 0 0 10px; font-size: 30px; font-weight: 650; letter-spacing: -0.8px; }
.page-heading p, .muted { color: var(--muted); line-height: 1.65; }
.hub-panel {
  background: white; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 14px; box-shadow: 0 3px 14px #38152304; min-width: 0;
}
.panel-heading {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.panel-heading h2 { font-size: 17px; font-weight: 650; margin: 0; }
.panel-heading p { margin: 7px 0 0; font-size: 12px; }
.panel-content { padding: 18px; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
.links-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.links-grid a { display: inline-block; margin-top: 12px; font-weight: 600; }

/* Schede e form */
.nav-tabs { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.nav-tabs > li > a { color: var(--muted); border: 0; border-bottom: 3px solid transparent; padding: 12px 22px; font-weight: 600; }
.nav-tabs > li > a:hover { background: var(--burgundy-soft); border-color: transparent; }
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus { color: var(--burgundy); background: transparent; border: 0; border-bottom: 3px solid var(--burgundy); }
.shiny-input-container:not(.shiny-input-container-inline) { width: 100%; }
.control-label, .selection label { font-size: 12px; color: #554a52; font-weight: 600; margin-bottom: 9px; }
.form-control { border: 1px solid #ded3d9; border-radius: 7px; box-shadow: none; height: 42px; }
.form-control:focus { border-color: var(--burgundy); box-shadow: 0 0 0 3px #b2221812; }
input[type=radio], input[type=checkbox] { accent-color: var(--burgundy); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.btn { border-radius: 7px; font-size: 13px; font-weight: 600; padding: 10px 16px; box-shadow: none; transition: background 120ms; }
.btn-primary, .btn-primary:focus, .btn-primary:active { color: white; background: var(--burgundy); border-color: var(--burgundy); }
.btn-primary:hover { color: white; background: var(--burgundy-dark); border-color: var(--burgundy-dark); }
.btn-default { color: #594b55; border-color: #dfd4da; background: white; }
.btn-default:hover { background: var(--burgundy-soft); border-color: #db9c97; color: var(--burgundy); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #cd6c65; outline-offset: 3px; }
.selection { margin-top: 22px; }
details { margin-top: 24px; color: var(--muted); font-size: 12px; }
summary { cursor: pointer; margin-bottom: 10px; }

/* Tabelle e risultati */
table.dataTable { border-collapse: collapse !important; width: 100% !important; }
table.dataTable thead th { color: var(--muted); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; background: var(--canvas); border-bottom: 1px solid var(--line) !important; padding: 14px 12px; }
table.dataTable tbody td { border-top: 1px solid #f0ebee !important; padding: 17px 12px; vertical-align: middle; font-size: 13px; }
table.dataTable tbody tr { background: white; }
table.dataTable tbody tr:hover { background: #fdf9fb; }
table.dataTable td:last-child, table.dataTable th:last-child { text-align: right; white-space: nowrap; }
.dataTables_wrapper .dataTables_info { color: var(--muted); font-size: 12px; padding-top: 18px; }
.pagination > .active > a, .pagination > .active > a:hover { background: var(--burgundy); border-color: var(--burgundy); }
.pagination > li > a { color: var(--burgundy); border-color: var(--line); }
.project-status { display: inline-block; padding: 5px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #f1eef0; color: #655762; }
.status-complete { background: #e6f4ea; color: #137333; }
.status-running { background: #e8f0fe; color: #1a73e8; }
.status-failed { background: #fce8e6; color: #c5221f; }
.result-preview { max-height: 220px; overflow: auto; padding-left: 20px; overflow-wrap: anywhere; font-size: 12px; color: var(--muted); }

/* Log, finestre e login */
pre.shiny-text-output { color: #584750; background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; padding: 16px; font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-panel pre { margin-top: 18px; min-height: 100px; max-height: 560px; overflow: auto; }
#logs_log_out { min-height: 420px; }
.modal-content { border-radius: 12px; border: 0; }
.modal-header, .modal-footer { border-color: var(--line); padding: 20px 24px; }
.modal-body { padding: 24px; }
.modal-title { font-weight: 650; }
.shiny-notification { border-radius: 8px; }

@media (max-width: 1000px) {
  .content { padding: 12px; }
  .tool-layout { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 767px) {
  .content { padding: 10px; }
  .links-grid { grid-template-columns: 1fr; gap: 0; }
  .panel-heading, .panel-content { padding: 14px; }
  .app-title { font-size: 19px; padding: 0 14px; }
  .main-sidebar { padding-top: 50px; }
  .main-header .navbar-custom-menu { float: right; }
  .panel-heading { flex-wrap: wrap; }
  .form-actions { flex-wrap: wrap; }
  .page-heading h1 { font-size: 26px; }
}

/* Spiegazioni e selezione risultati */
.explanation { color: #655a63; line-height: 1.65; margin-bottom: 14px; }
.explanation ul { padding-left: 20px; margin-top: 10px; }
.explanation li { margin-bottom: 5px; }
.documentation { margin-top: 18px; font-size: 12px; color: var(--muted); }
.result-file-picker { max-height: 300px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.result-file-picker label { overflow-wrap: anywhere; }
.result-selection-actions { display: flex; gap: 8px; margin-bottom: 12px; }
#project_download_action { display: inline-block; }

/* Navigazione fissa e sempre aperta */
:root { --sidebar-width: 232px; --header-height: 54px; }
.main-header {
  position: fixed; inset: 0 0 auto; width: 100%; height: var(--header-height);
  z-index: 1030; border-bottom: 4px solid var(--burgundy); background: white;
}
.skin-blue .main-header .navbar {
  margin-left: 0 !important; min-height: 50px; border-bottom: 0;
}
.main-header .sidebar-toggle { display: none !important; }
.skin-blue .main-sidebar {
  position: fixed !important; top: var(--header-height); bottom: 0; left: 0;
  width: var(--sidebar-width) !important; padding-top: 0 !important;
  height: calc(100vh - var(--header-height)); min-height: 0;
  transform: none !important; overflow-y: auto; overflow-x: hidden; z-index: 1020;
}
.content-wrapper, .main-footer {
  margin-left: var(--sidebar-width) !important; transform: none !important;
}
.content-wrapper { padding-top: var(--header-height); min-height: 100vh; }
.skin-blue .main-sidebar .sidebar-logo { display: block !important; }
.skin-blue .sidebar-menu > li > a > span {
  display: inline !important; position: static !important;
}
@media (max-width: 767px) {
  :root { --sidebar-width: 180px; }
  .sidebar-logo { padding: 16px 14px; }
  .sidebar-logo img { height: 110px; }
  .sidebar-menu { padding: 0 6px; }
  .skin-blue .sidebar-menu > li > a { padding: 12px 8px; font-size: 14px; }
  .content { padding: 10px; }
}

/* Experiments */

.runs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.runs-status {
  margin: 0 0 14px;
  color: #6b7280;
  font-size: 13px;
}

#runs_table table.dataTable tbody td {
  vertical-align: top;
}

#runs_table table.dataTable tbody td:nth-child(8) {
  min-width: 220px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#runs_table .edit-run {
  white-space: nowrap;
}

#runs_table .dataTables_filter input {
  padding: 6px 10px;
  border: 1px solid #dedede;
  border-radius: 7px;
}

#runs_edit_notes {
  height: auto;
  min-height: 130px;
}

.runs-loading {
  padding: 56px 20px;
  text-align: center;
  color: #b22218;
}

.runs-loading .fa {
  display: block;
  margin-bottom: 16px;
  font-size: 32px;
}

.runs-loading strong {
  display: block;
  font-size: 20px;
}

.runs-loading p {
  margin-top: 8px;
  color: #6b7280;
}
