/**
 * Django admin — Nilfish master brand (same palette as master-site frontend).
 * Black + lime green. Default on every install (static CSS, not tenant theme).
 */

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

:root {
  /* data-nilfish-theme="master" */
  --nilfish-primary: #0d1117;
  --nilfish-primary-soft: #1a1a1a;
  --nilfish-primary-hover: #000000;
  --nilfish-accent: #a2c609;
  --nilfish-accent-hover: #7a9607;
  --nilfish-body: #334155;
  --nilfish-muted: #64748b;
  --nilfish-border: #e2e8f0;
  --nilfish-font-sans: "Inter", system-ui, sans-serif;
  --nilfish-navbar-height: 46px;
  --nilfish-hero-slim-height: 24px;
  --nilfish-erp-logo-size: 58px;
  --nilfish-erp-logo-overhang: 5px;

  /* Action buttons (same roles as client/Odoo toolbar) */
  --nilfish-btn-new: #4a7ec7;
  --nilfish-btn-new-hover: #3a6bb0;
  /* Primary/default actions use master lime accent (not a second green) */
  --nilfish-btn-save: #a2c609;
  --nilfish-btn-save-hover: #7a9607;
  --nilfish-btn-save-fg: #0d1117;
  --nilfish-btn-delete: #e74c3c;
  --nilfish-btn-delete-hover: #c0392b;
  --nilfish-btn-edit: #6c757d;
  --nilfish-btn-edit-hover: #5a6268;
  --nilfish-btn-other: #6b4c9a;
  --nilfish-btn-other-hover: #5a3d82;
  --nilfish-btn-other-alt: #3eb7c8;
  --nilfish-btn-other-alt-hover: #2f9aa9;

  --nilfish-icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Crect x='1.5' y='1.5' width='13' height='13' rx='1.5' stroke='%23fff' stroke-width='1.4'/%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' d='M8 5v6M5 8h6'/%3E%3C/svg%3E");
  --nilfish-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%230d1117' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5 6.5 11.5 12.5 4.5'/%3E%3C/svg%3E");
  --nilfish-icon-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' d='M3 4.5h10M6 4.5V3.2a.7.7 0 0 1 .7-.7h2.6a.7.7 0 0 1 .7.7v1.3M5.2 4.5l.5 8.2a.7.7 0 0 0 .7.6h3.2a.7.7 0 0 0 .7-.6l.5-8.2'/%3E%3C/svg%3E");
  --nilfish-icon-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' d='m3.5 12.5 2.1-.4 7-7a1.2 1.2 0 0 0 0-1.7L11.6 2.4a1.2 1.2 0 0 0-1.7 0l-7 7-.4 2.1z'/%3E%3C/svg%3E");
  --nilfish-icon-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' d='M8 2.5v7M5.5 7 8 9.5 10.5 7M3.5 12.5h9'/%3E%3C/svg%3E");
  --nilfish-icon-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' d='M8 9.5v-7M5.5 5 8 2.5 10.5 5M3.5 12.5h9'/%3E%3C/svg%3E");
  --nilfish-icon-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='5.5' stroke='%23fff' stroke-width='1.4'/%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' d='M8 5v3.2l2 1.3'/%3E%3C/svg%3E");
  --nilfish-icon-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' d='M10 3.5 5.5 8 10 12.5M5.5 8h7'/%3E%3C/svg%3E");
}

/* Button role tokens — not on Dashboard (keep Django Add/Change links there). */
body:not(.dashboard) {
  --button-fg: #fff;
  --button-bg: #6b4c9a;
  --button-hover-bg: #5a3d82;
  --default-button-bg: var(--nilfish-btn-save);
  --default-button-hover-bg: var(--nilfish-btn-save-hover);
  --delete-button-bg: #e74c3c;
  --delete-button-hover-bg: #c0392b;
  --close-button-bg: #6c757d;
  --close-button-hover-bg: #5a6268;
  --object-tools-fg: #fff;
  --object-tools-bg: #4a7ec7;
  --object-tools-hover-bg: #3a6bb0;
}

body {
  font-family: var(--nilfish-font-sans);
  color: var(--nilfish-body);
}

/* Chrome: black top + green slim (as Odoo master / screenshot) + centered logo. */
.nilfish-admin-top {
  position: relative;
  z-index: 3;
}

#header {
  background: var(--nilfish-primary);
  color: #fff;
  min-height: var(--nilfish-navbar-height);
  box-sizing: border-box;
}

#header a:link,
#header a:visited {
  color: #fff;
}

#branding h1,
#branding #site-name {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.nilfish-admin-hero {
  display: block;
  height: var(--nilfish-hero-slim-height);
  background: var(--nilfish-accent);
  overflow: hidden;
}

div.breadcrumbs {
  background: transparent;
  color: var(--nilfish-primary);
  padding: 0 40px;
  margin: 0;
  min-height: var(--nilfish-hero-slim-height);
  height: var(--nilfish-hero-slim-height);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  font-size: 0.8125rem;
  line-height: 1;
}

div.breadcrumbs a {
  color: var(--nilfish-primary);
}

div.breadcrumbs a:focus,
div.breadcrumbs a:hover {
  color: var(--nilfish-accent-hover);
}

.nilfish-admin-logo {
  position: absolute;
  left: 50%;
  bottom: calc(-1 * var(--nilfish-erp-logo-overhang));
  transform: translateX(-50%);
  z-index: 4;
  display: flex !important;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: var(--nilfish-erp-logo-size);
  height: var(--nilfish-erp-logo-size);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  background: var(--nilfish-primary);
  overflow: hidden;
}

.nilfish-admin-logo img,
.nilfish-admin-logo__img {
  display: block !important;
  width: var(--nilfish-erp-logo-size) !important;
  height: var(--nilfish-erp-logo-size) !important;
  max-width: var(--nilfish-erp-logo-size) !important;
  max-height: var(--nilfish-erp-logo-size) !important;
  object-fit: contain !important;
  border-radius: 6px;
  margin: 0 !important;
}

.login .nilfish-admin-logo {
  display: none !important;
}

.module h2,
.module caption,
.inline-group h2,
fieldset.module > h2,
#nav-sidebar .module caption,
#nav-sidebar .module h2 {
  background: var(--nilfish-accent) !important;
  color: var(--nilfish-primary) !important;
}

#content-related .module h2 {
  background: var(--nilfish-accent) !important;
  color: var(--nilfish-primary) !important;
  border-bottom-color: var(--nilfish-accent-hover);
}

a:link,
a:visited {
  color: var(--nilfish-primary-soft);
}

a:focus,
a:hover {
  color: var(--nilfish-accent-hover);
}

/* —— Action buttons on forms / changelists only (not Dashboard, not left nav) ——
   Use the `background` shorthand + !important so Django’s forms.css
   (`background: var(--button-bg)`) cannot wipe icons or colors on change forms.
   Do NOT style bare a.addlink/a.changelink — those are used in #nav-sidebar
   and app lists and must stay as Django’s compact links. */

body:not(.dashboard) .button,
body:not(.dashboard) input[type="submit"],
body:not(.dashboard) input[type="button"],
body:not(.dashboard) .submit-row input,
body:not(.dashboard) .submit-row a,
body:not(.dashboard) button[type="submit"],
body:not(.dashboard) .object-tools a,
body:not(.dashboard) .add-row a,
body:not(.dashboard) .inline-deletelink,
body:not(.dashboard) a.related-widget-wrapper-link {
  font-family: var(--nilfish-font-sans) !important;
  font-weight: 600 !important;
  border-radius: 4px !important;
  border: none !important;
  color: #fff !important;
  box-shadow: none !important;
  padding: 0.5em 1em 0.5em 2.25em !important;
  line-height: 1.25 !important;
  text-decoration: none !important;
  cursor: pointer;
  display: inline-block;
  box-sizing: border-box;
  transition: filter 0.12s ease, background-color 0.12s ease;
}

/* Save / Search / Log in — master lime accent + dark text (same as slim bar) */
body:not(.dashboard) input[type="submit"],
body:not(.dashboard) button[type="submit"],
body:not(.dashboard) .submit-row input[type="submit"],
body:not(.dashboard) input[name="_save"],
body:not(.dashboard) input[name="_addanother"],
body:not(.dashboard) input[name="_continue"],
body:not(.dashboard) .button.default,
body:not(.dashboard) input[type="submit"].default,
body:not(.dashboard) .submit-row input.default,
body.login .submit-row input,
/* .delete-confirmation is on <body>, not a wrapper — do not use a descendant gap. */
body.delete-confirmation:not(.dashboard) form input[type="submit"] {
  background: var(--nilfish-btn-save) var(--nilfish-icon-check) 0.7em center / 0.95em 0.95em no-repeat !important;
  color: var(--nilfish-btn-save-fg) !important;
}

body:not(.dashboard) input[type="submit"]:hover,
body:not(.dashboard) input[type="submit"]:focus,
body:not(.dashboard) button[type="submit"]:hover,
body:not(.dashboard) button[type="submit"]:focus,
body:not(.dashboard) .submit-row input[type="submit"]:hover,
body:not(.dashboard) .button.default:hover,
body.login .submit-row input:hover,
body.delete-confirmation:not(.dashboard) form input[type="submit"]:hover {
  background-color: var(--nilfish-btn-save-hover) !important;
  filter: brightness(1.02);
  color: var(--nilfish-btn-save-fg) !important;
}

/* New / Add (blue) — object-tools + inline “add another”, never #nav-sidebar */
body:not(.dashboard) .object-tools a,
body:not(.dashboard) .object-tools a.addlink,
body:not(.dashboard) .add-row a,
body:not(.dashboard) a.related-widget-wrapper-link.add-related {
  background: var(--nilfish-btn-new) var(--nilfish-icon-plus) 0.7em center / 0.95em 0.95em no-repeat !important;
}

body:not(.dashboard) .object-tools a:hover,
body:not(.dashboard) .object-tools a:focus,
body:not(.dashboard) .add-row a:hover {
  background-color: var(--nilfish-btn-new-hover) !important;
  color: #fff !important;
}

/* Delete (red) */
body:not(.dashboard) .submit-row a.deletelink,
body:not(.dashboard) .inline-deletelink,
body:not(.dashboard) a.delete-related {
  background: var(--nilfish-btn-delete) var(--nilfish-icon-trash) 0.7em center / 0.95em 0.95em no-repeat !important;
  height: auto !important;
}

body:not(.dashboard) .submit-row a.deletelink:hover,
body:not(.dashboard) .submit-row a.deletelink:focus,
body:not(.dashboard) .inline-deletelink:hover,
body:not(.dashboard) a.delete-related:hover {
  background-color: var(--nilfish-btn-delete-hover) !important;
  color: #fff !important;
}

/* Edit (gray + pencil) */
body:not(.dashboard) a.related-widget-wrapper-link.change-related,
body:not(.dashboard) .submit-row a.closelink {
  background: var(--nilfish-btn-edit) var(--nilfish-icon-pencil) 0.7em center / 0.95em 0.95em no-repeat !important;
  height: auto !important;
}

body:not(.dashboard) a.related-widget-wrapper-link.change-related:hover,
body:not(.dashboard) .submit-row a.closelink:hover {
  background-color: var(--nilfish-btn-edit-hover) !important;
  color: #fff !important;
}

/*
 * Delete confirm “No, take me back”.
 * Django puts class delete-confirmation on <body> and sets height/line-height
 * 0.9375rem (content-box era). Our border-box + padding then clips the label.
 * Selector must be body.delete-confirmation… (not a descendant .delete-confirmation).
 */
body.delete-confirmation:not(.dashboard) form .cancel-link {
  background: var(--nilfish-btn-edit) var(--nilfish-icon-back) 0.7em center / 0.95em 0.95em no-repeat !important;
  height: auto !important;
  min-height: 0 !important;
  line-height: 1.25 !important;
  padding: 0.5em 1em 0.5em 2.25em !important;
  margin: 0 0 0 10px !important;
  vertical-align: middle !important;
  display: inline-flex !important;
  align-items: center !important;
  box-sizing: border-box !important;
}

body.delete-confirmation:not(.dashboard) form .cancel-link:hover,
body.delete-confirmation:not(.dashboard) form .cancel-link:focus {
  background-color: var(--nilfish-btn-edit-hover) !important;
  color: #fff !important;
}

/* History (gray + clock) */
body:not(.dashboard) .object-tools a.historylink {
  background: var(--nilfish-btn-edit) var(--nilfish-icon-clock) 0.7em center / 0.95em 0.95em no-repeat !important;
}

body:not(.dashboard) .object-tools a.historylink:hover,
body:not(.dashboard) .object-tools a.historylink:focus {
  background-color: var(--nilfish-btn-edit-hover) !important;
}

/* Other (purple) — Download example, generic .button, Go, view site.
   Exclude cancel/close links (they share class "button" in Django templates). */
body:not(.dashboard) .button:not(.default):not(.cancel-link):not(.closelink),
body:not(.dashboard) a.button:not(.cancel-link):not(.closelink),
body:not(.dashboard) .object-tools a.viewsitelink,
body:not(.dashboard) a.nilfish-btn--download,
body:not(.dashboard) a.nilfish-btn--other,
body:not(.dashboard) #changelist .actions button,
body:not(.dashboard) #changelist .actions .button {
  background: var(--nilfish-btn-other) var(--nilfish-icon-download) 0.7em center / 0.95em 0.95em no-repeat !important;
  color: #fff !important;
}

body:not(.dashboard) .button:not(.default):not(.cancel-link):not(.closelink):hover,
body:not(.dashboard) .button:not(.default):not(.cancel-link):not(.closelink):focus,
body:not(.dashboard) a.button:not(.cancel-link):not(.closelink):hover,
body:not(.dashboard) a.nilfish-btn--download:hover,
body:not(.dashboard) #changelist .actions button:hover {
  background-color: var(--nilfish-btn-other-hover) !important;
  color: #fff !important;
}

body:not(.dashboard) .object-tools a.viewsitelink {
  background-image: var(--nilfish-icon-pencil) !important;
}

/* Left nav: keep Django’s compact Add links (undo any role styling) */
#nav-sidebar a.addlink,
#nav-sidebar a.changelink,
#nav-sidebar a.deletelink {
  background: transparent !important;
  background-image: none !important;
  color: var(--link-fg) !important;
  font-weight: 400 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  display: inline !important;
}

#nav-sidebar a.addlink {
  padding-left: 16px !important;
  background: url("../img/icon-addlink.svg") 0 1px no-repeat !important;
}

#nav-sidebar a.addlink:hover,
#nav-sidebar a.changelink:hover {
  color: var(--link-hover-color) !important;
  background-color: transparent !important;
}

/* Upload / choose file (cyan) */
body:not(.dashboard) input[type="file"]::file-selector-button,
body:not(.dashboard) input[type="file"]::-webkit-file-upload-button {
  font-family: var(--nilfish-font-sans) !important;
  font-weight: 600 !important;
  border-radius: 4px !important;
  border: none !important;
  color: #fff !important;
  cursor: pointer;
  padding: 0.45em 0.95em 0.45em 2.15em !important;
  margin-right: 0.75em;
  background: var(--nilfish-btn-other-alt) var(--nilfish-icon-upload) 0.7em center / 0.95em 0.95em no-repeat !important;
}

body:not(.dashboard) input[type="file"]::file-selector-button:hover,
body:not(.dashboard) input[type="file"]::-webkit-file-upload-button:hover {
  background-color: var(--nilfish-btn-other-alt-hover) !important;
}

/* Logout in header stays compact text, not a big action button */
#logout-form button[type="submit"] {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-weight: 400 !important;
  border: none !important;
}

#changelist-filter h2 {
  background: var(--nilfish-accent) !important;
  color: var(--nilfish-primary) !important;
}

#changelist-filter li.selected a {
  color: var(--nilfish-accent-hover);
}

.selector-chosen h2 {
  background: var(--nilfish-accent) !important;
  color: var(--nilfish-primary) !important;
}

#user-tools a:focus,
#user-tools a:hover {
  border-bottom-color: var(--nilfish-accent);
  color: var(--nilfish-accent);
}

#content h1 {
  color: var(--nilfish-primary);
  font-weight: 700;
}

thead th {
  color: var(--nilfish-primary);
}

.row1 {
  background: #fff;
}

.row2 {
  background: #f8fafc;
}

#result_list tbody tr:hover {
  background: rgba(162, 198, 9, 0.12);
}

fieldset.module {
  border-color: var(--nilfish-border);
  border-radius: 6px;
}

.login #header {
  background: var(--nilfish-primary);
}

.login #container {
  border-radius: 8px;
  border: 1px solid var(--nilfish-border);
}

.login .submit-row input {
  width: 100%;
}
