/*
 * Global App Theme — Aviation ERP (navy + gold)
 *
 * One brand across every app: CRM, HRMS, VERP, ERPNext and India Compliance
 * all render the same navy sidebar, gold active row and near-white canvas.
 * There are deliberately no per-app palettes.
 *
 * Applies wherever this file is loaded — no attribute or JS required:
 *   Desk  — app_include_css in hooks.py
 *   SPAs  — a <link> in crm.html / hrms.html / verp.html
 *
 * Descendant rules are prefixed with `:root ` purely for specificity. It
 * matches <html> and so always applies, while keeping these rules at the same
 * weight as the old `[data-app] ` prefix — without it they would tie with the
 * Tailwind utility they override and depend on load order alone.
 *
 * The `data-app` attributes still present in the SPA HTML are vestigial. They
 * are harmless, and are the hook if per-app accents are ever wanted again.
 */

/* ============================================
   BRAND TOKENS
   ============================================ */
:root {
	/* Core brand */
	--brand-navy:         #1B2A4A;
	--brand-navy-deep:    #16233D;
	--brand-navy-raised:  #24355A;
	--brand-gold:         #F0B429;
	--brand-gold-hover:   #D99D1E;

	/* Sidebar — dark surface, so its text runs light */
	--app-sidebar-bg:     var(--brand-navy);
	--app-sidebar-ink:    #A8B3C7;
	--app-sidebar-ink-hi: #E2E8F2;
	--app-sidebar-edge:   rgba(255, 255, 255, 0.08);
	--app-hover-bg:       rgba(255, 255, 255, 0.07);

	/* Active nav row — filled gold with navy text, as in the reference */
	--app-active-bg:      var(--brand-gold);
	--app-active-ink:     var(--brand-navy);

	/* Content canvas — grey enough that a white card reads as raised off it */
	--app-canvas-bg:      #F1F3F7;
	--app-row-hover:      rgba(27, 42, 74, 0.05);
	--app-card-radius:    8px;
	--app-dialog-radius:  12px;
	--app-overlay:        rgba(17, 26, 46, 0.45);
	--app-surface-raised: #FFFFFF;
	--app-border:         #E5E8EE;
	--app-text:           #1F2937;
	--app-text-muted:     #6B7280;
	--app-heading:        #111827;

	/* Primary action */
	--app-primary:        #1E3A5F;
	--app-primary-hover:  #16304F;
	--app-primary-fg:     #FFFFFF;
	--app-focus-ring:     rgba(240, 180, 41, 0.45);
}

/* Dark mode keeps the navy sidebar (already dark) and drops the canvas. */
[data-theme="dark"] {
	--app-canvas-bg:      #0F1623;
	--app-row-hover:      rgba(255, 255, 255, 0.05);
	--app-overlay:        rgba(5, 9, 18, 0.65);
	--app-surface-raised: #16213A;
	--app-border:         #27324C;
	--app-text:           #E5E8EE;
	--app-text-muted:     #94A3B8;
	--app-heading:        #FFFFFF;
	/* Lifted off the sidebar navy so a primary button stays visible on a dark
	   canvas, where #1E3A5F would nearly disappear. */
	--app-primary:        #2F5A8F;
	--app-primary-hover:  #3A6BA5;
}

/* ============================================
   DESK TOKEN BRIDGE
   saas_theme.css marks ~470 declarations `!important`, including the sidebar
   and active-row paint, so ordinary rules match but always lose. Rather than
   escalating, feed it the colours through the custom properties its own rules
   already read. It declares them on :root as well, so this is a specificity
   tie broken by source order — app_themes.css is listed second in
   app_include_css, so it wins. saas_theme keeps its layout, spacing and radii.
   ============================================ */
:root {
	--st-sidebar-bg:       var(--app-sidebar-bg);
	--st-sidebar-border:   var(--app-sidebar-edge);
	--st-item-hover:       var(--app-hover-bg);
	--st-item-active-bg:   var(--app-active-bg);
	--st-item-active-text: var(--app-active-ink);
	--st-text-primary:     var(--app-sidebar-ink-hi);
	--st-text-secondary:   var(--app-sidebar-ink);
	--st-text-muted:       var(--app-sidebar-ink);
	--st-section-color:    var(--app-sidebar-ink);
	--st-divider:          var(--app-sidebar-edge);
	--st-search-bg:        rgba(255, 255, 255, 0.06);
	--st-search-border:    var(--app-sidebar-edge);
}

/* ============================================
   SIDEBAR SURFACE
   Covers the frappe-ui Sidebar (SPAs), CRM's own sidebar column, and the
   desk's nav panel. Verified class names, not guesses: frappe-ui uses
   `bg-surface-sidebar`, CRM's AppSidebar wraps it in `bg-surface-gray-1`,
   and the desk (via saas_theme) uses `body-sidebar` / `sidebar-panel`.
   ============================================ */
:root .bg-surface-sidebar,
:root div.bg-surface-gray-1.flex.h-full,
:root .body-sidebar,
:root .sidebar-panel,
:root .app-sidebar-surface {
	background-color: var(--app-sidebar-bg);
	border-right-color: var(--app-sidebar-edge);
	color: var(--app-sidebar-ink);
}

/* The desk's icon rail sits left of the nav panel. saas_theme ships it near
   black (#0B1120), which reads as a third colour next to the navy. Pulling it
   to the deeper brand navy keeps the two as one unit while still stepping back
   from the panel. `.dock` is Frappe's own rail, covered for the case where
   saas_theme's is not the one on screen. */
:root .st-workspace-rail,
:root .dock {
	background-color: var(--brand-navy-deep);
	border-right-color: var(--app-sidebar-edge);
	color: var(--app-sidebar-ink);
}

:root .st-workspace-rail .st-rail-label,
:root .st-workspace-rail svg,
:root .dock .dock-item-label,
:root .dock svg {
	color: var(--app-sidebar-ink);
}

/* Active rail icon takes the gold, matching the active nav row. */
:root .st-rail-item.active,
:root .dock-item.active {
	background-color: var(--app-active-bg);
	color: var(--app-active-ink);
}

:root .st-rail-item.active svg,
:root .st-rail-item.active .st-rail-label,
:root .dock-item.active svg,
:root .dock-item.active .dock-item-label {
	color: var(--app-active-ink);
}

:root .st-rail-item:not(.active):hover,
:root .dock-item:not(.active):hover {
	background-color: var(--app-hover-bg);
}

/* The SPAs colour sidebar text with Tailwind ink tokens that assume a light
   surface. Inverting the surface means those have to be overridden, and they
   are utility classes so there is no single parent colour to change. The
   attribute match covers the whole `text-ink-*` family in one rule; it is
   scoped inside the sidebar, so it cannot reach page content. */
:root .bg-surface-sidebar [class*="text-ink-"],
:root div.bg-surface-gray-1.flex.h-full [class*="text-ink-"],
:root .body-sidebar [class*="text-ink-"],
:root .body-sidebar .sidebar-item-label {
	color: var(--app-sidebar-ink);
}

:root .bg-surface-sidebar svg,
:root div.bg-surface-gray-1.flex.h-full svg,
:root .body-sidebar svg {
	color: currentColor;
}

/* ============================================
   ACTIVE NAV ROW — gold fill, navy text
   Two markups to cover: frappe-ui marks the row with
   data-slot="sidebar-item" + data-state="active"; the desk uses
   .standard-sidebar-item.active-sidebar (which the bridge above already
   recolours, since saas_theme paints it with !important).
   ============================================ */
:root [data-slot="sidebar-item"][data-state="active"],
:root .standard-sidebar-item.active-sidebar {
	background-color: var(--app-active-bg);
	color: var(--app-active-ink);
}

:root [data-slot="sidebar-item"][data-state="active"] [class*="text-ink-"],
:root [data-slot="sidebar-item"][data-state="active"] span,
:root [data-slot="sidebar-item"][data-state="active"] svg,
:root .standard-sidebar-item.active-sidebar .item-anchor,
:root .standard-sidebar-item.active-sidebar .sidebar-item-label,
:root .standard-sidebar-item.active-sidebar .sidebar-item-icon svg {
	color: var(--app-active-ink);
	fill: currentColor;
}

:root [data-slot="sidebar-item"][data-state="active"] .truncate,
:root .standard-sidebar-item.active-sidebar .sidebar-item-label {
	font-weight: 560;
}

/* Hover on inactive rows: a faint lift against the navy, not a colour change. */
:root [data-slot="sidebar-item"][data-state="inactive"]:hover,
:root .standard-sidebar-item:not(.active-sidebar):hover {
	background-color: var(--app-hover-bg);
}

:root [data-slot="sidebar-item"][data-state="inactive"]:hover [class*="text-ink-"],
:root .standard-sidebar-item:not(.active-sidebar):hover .sidebar-item-label {
	color: var(--app-sidebar-ink-hi);
}

/* ============================================
   CONTENT CANVAS
   ============================================ */
:root .bg-surface-base,
:root .layout-main-section-wrapper,
:root .app-canvas-surface {
	background-color: var(--app-canvas-bg);
}

/* ============================================
   LIST AS A RAISED CARD
   The table sits flat on the page, so filters, column headers and rows all
   read as one surface. Lifting the table onto a white card over a grey canvas
   gives three legible layers: chrome, canvas, data.

   CAVEAT ON SELECTORS: frappe-ui's list parts carry no data-* hooks and the
   CRM pages pass no class of their own, so these match on the most
   distinctive class combinations each part has. `ListHeader` is a
   `grid rounded-4 bg-surface-gray-2`; the row scroller is frappe-ui's
   `ListRows` root, `h-full overflow-y-auto`. Everything is scoped inside
   `.bg-surface-base` so it cannot reach outside the content column, but a
   frappe-ui restyle of those parts would silently stop this matching.
   ============================================ */

/* Column header: top of the card, and pinned so it survives a long scroll. */
:root .bg-surface-base .grid.rounded-4.bg-surface-gray-2 {
	position: sticky;
	top: 0;
	z-index: 2;
	margin-bottom: 0;
	background-color: var(--app-surface-raised);
	border: 1px solid var(--app-border);
	border-radius: var(--app-card-radius) var(--app-card-radius) 0 0;
}

/* Row area: completes the card. The top border is dropped so it meets the
   header seamlessly rather than showing a double hairline. */
:root .bg-surface-base .h-full.overflow-y-auto {
	background-color: var(--app-surface-raised);
	border: 1px solid var(--app-border);
	border-top: 0;
	border-radius: 0 0 var(--app-card-radius) var(--app-card-radius);
}

/* Row hover: a faint navy wash, tying rows to the sidebar rather than the
   neutral grey frappe-ui ships. The class is `hover:bg-surface-sidebar`, which
   is a different class from `bg-surface-sidebar` above — the sidebar rules do
   not reach it. */
:root .hover\:bg-surface-sidebar:hover {
	background-color: var(--app-row-hover);
}

/* ============================================
   MODALS & DIALOGS
   Two systems: the SPAs use frappe-ui's Dialog, which exposes real hooks
   (`dialog-overlay`, `dialog-content`) rather than class soup; the desk uses
   Bootstrap modals (`modal-content`, `modal-header`, `modal-backdrop`).

   saas_theme only styles `.desktop-modal .modal-content`, so generic desk
   modals are unclaimed and these rules apply cleanly. That one specific modal
   keeps its own 16px radius — it sets `!important` — which is close enough to
   the 12px here not to read as inconsistent.
   ============================================ */

/* Backdrop: navy-tinted rather than neutral black, with a slight blur so the
   dialog sits forward of the page instead of on a grey sheet. */
:root .dialog-overlay,
:root .modal-backdrop {
	background-color: var(--app-overlay);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
	opacity: 1;
}

/* The dialog itself. */
:root .dialog-content,
:root .modal-content {
	border-radius: var(--app-dialog-radius);
	border: 1px solid var(--app-border);
	box-shadow: 0 20px 48px rgba(17, 26, 46, 0.22);
	overflow: hidden;
}

/* Desk modals get a tinted header band so the title separates from the body,
   matching how the list card separates its header from its rows. The SPA
   dialogs build their own header inside the content slot, so there is no
   equivalent element to target there. */
:root .modal-header {
	background-color: var(--app-canvas-bg);
	border-bottom: 1px solid var(--app-border);
}

:root .modal-footer {
	background-color: var(--app-canvas-bg);
	border-top: 1px solid var(--app-border);
}

/* ============================================
   PRIMARY BUTTONS
   `.btn-primary` is the desk's stable class. frappe-ui's Button exposes no
   variant attribute, so its primary ("gray-solid") style is only reachable via
   the Tailwind class it applies, `bg-surface-gray-10`. That class is not
   button-only — it also paints telephony panels and unread dots — so the
   selector is restricted to button and anchor elements.
   ============================================ */
:root .btn-primary,
:root button.bg-surface-gray-10,
:root a.bg-surface-gray-10 {
	background-color: var(--app-primary);
	border-color: var(--app-primary);
	color: var(--app-primary-fg);
}

:root .btn-primary:hover,
:root button.bg-surface-gray-10:hover,
:root a.bg-surface-gray-10:hover {
	background-color: var(--app-primary-hover);
	border-color: var(--app-primary-hover);
}

:root .btn-primary:disabled,
:root button.bg-surface-gray-10:disabled {
	background-color: var(--app-border);
	border-color: transparent;
	color: var(--app-text-muted);
}

/* ============================================
   LOGIN PAGE
   saas_theme already replaces Frappe's login page with its own split layout
   (saas_theme/www/login.html + login.css), so the structure is in place and
   only the colours need rebranding from its fintech blue.

   `!important` is used throughout here, which is deliberate and is the one
   place in this file it appears: login.css sets these same properties with
   `!important`, so equal specificity and later source order are not enough to
   win. This section is loaded after login.css via a second <link> in
   login.html, so importance ties break in our favour.
   ============================================ */

/* The reference puts the brand panel on the LEFT and the form on the right;
   saas_theme's template emits them the other way round. Flipping with flex
   `order` avoids reordering the markup, which keeps tab order and screen-reader
   order on the form first. */
.st-login-panel {
	order: 1 !important;
	/* Hangar photo under a navy scrim. The scrim is not decoration: the panel
	   copy is white and sits over the lower third of the photo, which is light
	   enough there (concrete floor) to lose the text without it. It also
	   softens the upscaling — see the note on image size below. */
	background:
		linear-gradient(180deg,
			rgba(22, 35, 61, 0.15) 0%,
			rgba(22, 35, 61, 0.35) 55%,
			rgba(22, 35, 61, 0.85) 100%),
		linear-gradient(160deg, #24355A 0%, #1B2A4A 45%, #16233D 100%) !important;
	background-blend-mode: normal !important;
	justify-content: flex-end !important;
	align-items: flex-start !important;
	padding: 60px 56px !important;
	position: relative !important;
}

/* The photo itself goes on a pseudo-element rather than a third background
   layer, so the scrim above can sit over it with its own stacking. */
/* login.css uses these same two pseudo-elements for small decorative bars, so
   its `width: 6px`, `border-radius` and `transform` have to be cleared —
   `width` would otherwise over-constrain `inset: 0` and win, leaving a 6px
   sliver of photo instead of a full panel. */
.st-login-panel::before,
.st-login-panel::after {
	width: auto !important;
	height: auto !important;
	inset: 0 !important;
	border-radius: 0 !important;
	transform: none !important;
	pointer-events: none !important;
}

.st-login-panel::before {
	content: "" !important;
	position: absolute !important;
	z-index: 0 !important;
	background: url('/assets/saas_theme/images/login-hangar.png?v=2') center center / cover no-repeat !important;
}

.st-login-panel::after {
	content: "" !important;
	position: absolute !important;
	z-index: 1 !important;
	background: linear-gradient(180deg,
		rgba(22, 35, 61, 0.10) 0%,
		rgba(22, 35, 61, 0.30) 50%,
		rgba(22, 35, 61, 0.88) 100%) !important;
}

.st-login-panel > * {
	position: relative !important;
	z-index: 3 !important;
}

/* Faint aircraft watermark in the form column, bottom right — the same jet and
   trail motif as the brand mark, at low contrast so it never competes with the
   form. The column needs a positioning context and clipping so the graphic
   cannot spill past the panel edge. */
.st-login-form-col {
	position: relative !important;
	overflow: hidden !important;
}

.st-form-watermark {
	position: absolute !important;
	right: -40px !important;
	bottom: -20px !important;
	width: 440px !important;
	height: 300px !important;
	z-index: 0 !important;
	pointer-events: none !important;
	opacity: 0.5 !important;
	background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 420 280'><g fill='%23C3D1E6'><path d='M296 46 L352 20 L332 70 L300 82 L286 124 L268 108 L276 76 L240 88 L228 112 L212 100 L220 70 L196 58 L220 48 Z'/><path d='M30 198 C140 178 252 150 332 102 L340 120 C258 170 146 198 40 218 Z'/><path d='M14 240 C128 218 250 186 324 140 L332 158 C256 206 132 238 24 258 Z'/></g></svg>") right bottom / contain no-repeat !important;
}

/* The form must sit above the watermark. */
.st-login-form-col > section {
	position: relative !important;
	z-index: 1 !important;
}

.st-login-form-col {
	order: 2 !important;
}

/* Brand swoosh band along the bottom of the photo panel — three stacked arcs
   in the logo's navy / gold / red, drawn as an inline SVG so it scales with
   the panel and needs no image asset. `preserveAspectRatio: none` lets it
   stretch to any panel width while keeping the band height fixed. */
.st-panel-swoosh {
	position: absolute !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	height: 150px !important;
	z-index: 2 !important;
	pointer-events: none !important;
	background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 170' preserveAspectRatio='none'><path d='M0,170 L0,118 C150,58 380,108 600,28 L600,170 Z' fill='%231B2A4A'/><path d='M0,170 L0,143 C170,93 400,138 600,68 L600,170 Z' fill='%23F0B429'/><path d='M0,170 L0,162 C180,122 420,158 600,106 L600,170 Z' fill='%23A4123F'/></svg>") center bottom / 100% 100% no-repeat !important;
}

/* Panel copy sits bottom-left over the artwork, under a short gold rule.
   z-index 3 keeps it above the swoosh. */
.st-panel-content {
	text-align: left !important;
	margin: 0 !important;
}

.st-panel-rule {
	display: block;
	width: 56px;
	height: 4px;
	margin-bottom: 20px;
	border-radius: 2px;
	background: var(--brand-gold);
}

.st-panel-content h2 {
	color: #FFFFFF !important;
	font-size: 34px !important;
	font-weight: 700 !important;
	margin-bottom: 10px !important;
}

.st-panel-content p {
	color: var(--app-sidebar-ink) !important;
	font-size: 15px !important;
	line-height: 1.6 !important;
	margin: 0 !important;
}

/* The decorative floating bars are tuned for the old pale panel and read as
   smudges on navy. */
.st-float-bar {
	display: none !important;
}

/* Form column: everything centred, as in the reference. */
.st-login-form-col .page-card-head {
	text-align: center !important;
}

.st-login-form-col .page-card-head img.app-logo {
	display: block !important;
	height: 72px !important;
	width: auto !important;
	max-width: 280px !important;
	margin: 0 auto 26px auto !important;
	object-fit: contain !important;
}

.st-login-form-col .page-card-head h4 {
	font-size: 25px !important;
	font-weight: 700 !important;
	color: var(--brand-navy) !important;
	margin-bottom: 8px !important;
	text-align: center !important;
}

.st-login-subtitle {
	font-size: 13.5px !important;
	line-height: 1.55 !important;
	color: var(--app-text-muted) !important;
	margin: 0 auto 28px auto !important;
	max-width: 330px !important;
	text-align: center !important;
}

/* Inputs. Frappe 16's login bundle fills these with a pale tint and no border;
   login.css tries to reset that but targets `.page-card-body input[type=...]`,
   which no longer matches the current markup, so its rules never land. These
   target `.form-control` directly, which the inputs still carry. */
.st-login-form-col .form-control,
.st-login-form-col input[type="text"],
.st-login-form-col input[type="email"],
.st-login-form-col input[type="password"] {
	background: #FFFFFF !important;
	border: 1px solid #D9DEE7 !important;
	border-radius: 8px !important;
	height: 46px !important;
	font-size: 14px !important;
	padding-left: 42px !important;
	margin-bottom: 0 !important;
	box-shadow: none !important;
}

.st-login-form-col .form-group {
	margin-bottom: 14px !important;
}

/* login.css sets `left` on the icon but never `position`, so on this markup it
   falls back to static and the icon stacks *below* the field instead of
   sitting inside it. The wrapper needs a positioning context too. */
.st-login-form-col .email-field,
.st-login-form-col .password-field {
	position: relative !important;
}

.st-login-form-col .field-icon {
	position: absolute !important;
	left: 14px !important;
	top: 23px !important;
	transform: translateY(-50%) !important;
	width: 16px !important;
	height: 16px !important;
	margin: 0 !important;
	fill: #8792A2 !important;
	color: #8792A2 !important;
	pointer-events: none !important;
}

.st-login-form-col .toggle-password {
	position: absolute !important;
	right: 14px !important;
	top: 23px !important;
	transform: translateY(-50%) !important;
}

/* Focus: a thin gold ring, not the heavy 3px halo. */
.st-login-form-col .form-control:focus,
.st-login-form-col .page-card-body input:focus {
	border-color: var(--brand-gold) !important;
	box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.25) !important;
}

/* "Remember me" and "Forgot password?" share one row, split to the edges. */
.st-login-form-col .forgot-password-message {
	text-align: right !important;
	margin: 0 !important;
}

.st-login-form-col .forgot-password-message a {
	color: #2563EB !important;
	font-size: 13px !important;
	font-weight: 500 !important;
}

/* Sign In button: full width navy, matching the reference's proportions. */
.st-login-form-col .btn-primary,
.st-login-form-col .btn-login,
.st-login-form-col .btn-forgot,
.st-login-form-col .btn-login-with-email-link {
	width: 100% !important;
	height: 50px !important;
	border-radius: 8px !important;
	letter-spacing: 0.2px !important;
}

/* Form side: navy primary button, gold focus ring. */
.st-login-form-col .btn-primary,
.st-login-form-col .btn-login,
.st-login-form-col .btn-forgot,
.st-login-form-col .btn-login-with-email-link {
	background: var(--app-primary) !important;
	color: var(--app-primary-fg) !important;
}

.st-login-form-col .btn-primary:hover,
.st-login-form-col .btn-login:hover,
.st-login-form-col .btn-forgot:hover,
.st-login-form-col .btn-login-with-email-link:hover {
	background: var(--app-primary-hover) !important;
	box-shadow: 0 4px 12px rgba(27, 42, 74, 0.28) !important;
}

.st-login-form-col .page-card-body input:focus {
	border-color: var(--brand-gold) !important;
	box-shadow: 0 0 0 3px var(--app-focus-ring) !important;
}

.st-login-form-col .toggle-password:hover,
.st-login-form-col .forgot-password-message a:hover {
	color: var(--app-primary) !important;
}

/* ============================================
   FOCUS RING & SELECTION
   ============================================ */
:root :focus-visible {
	outline: 2px solid var(--brand-gold);
	outline-offset: 2px;
}

::selection {
	background-color: rgba(240, 180, 41, 0.30);
	color: var(--app-heading);
}
