/* ════════════════════════════════════════════════════════════════════
 * VMS Portal — Login chrome v1
 *
 * Modernizes Frappe's /login page WITHOUT touching frappe core.
 * Loaded on every website page via web_include_css; the body class
 * vms-login-chrome (added by vms_login_chrome_v1.js only on /login)
 * scopes every selector here so other pages render unchanged.
 *
 * Preserves every Frappe auth element + ID + class — only the visual
 * presentation changes. Email/password, OAuth, LDAP, Forgot Password,
 * Sign-up, Email-Link flows all still work because the form DOM is
 * untouched.
 *
 * Author: Adnan Anjum
 * ════════════════════════════════════════════════════════════════════ */

body[data-path="login"] {
  --vlx-brand-1: #0f172a;       /* slate-900 */
  --vlx-brand-2: #1e293b;       /* slate-800 */
  --vlx-accent:  #0ea5e9;       /* sky-500  — primary action */
  --vlx-accent-2: #6366f1;      /* indigo-500 — secondary highlight */
  --vlx-text:    #0f172a;
  --vlx-text-2:  #475569;       /* slate-600 */
  --vlx-muted:   #94a3b8;       /* slate-400 */
  --vlx-card-bg: #ffffff;
  --vlx-border:  #e2e8f0;       /* slate-200 */
  --vlx-input-bg: #ffffff;
  --vlx-pane-fg: #f1f5f9;       /* slate-100 — text on dark brand pane */
  --vlx-radius:  14px;
  --vlx-shadow:  0 20px 60px -10px rgba(15,23,42,.20),
                 0 8px 20px -8px rgba(15,23,42,.10);

  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--vlx-text);
  /* Frappe's default padding-top from website.bundle.css */
  padding-top: 0 !important;
}

/* ── Page shell — two-pane on desktop, stacked on mobile ──────────── */
body[data-path="login"] #page-login,
body[data-path="login"] .page_content {
  background: transparent;
  padding: 0;
  margin: 0;
  min-height: 100vh;
}

body[data-path="login"] .vlx-shell {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 520px);
  min-height: 100vh;
  background: transparent;
}

@media (max-width: 1024px) {
  body[data-path="login"] .vlx-shell {
    grid-template-columns: 1fr;
  }
  body[data-path="login"] .vlx-brand { display: none; }
}

/* ── Brand pane (left, desktop only) ──────────────────────────────── */
body[data-path="login"] .vlx-brand {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--vlx-brand-1) 0%,
                                       var(--vlx-brand-2) 100%);
  color: var(--vlx-pane-fg);
  padding: 60px 56px;
  display: flex; flex-direction: column;
  justify-content: space-between;
}

/* Subtle animated mesh overlay — pure CSS, no images */
body[data-path="login"] .vlx-brand::before {
  content: "";
  position: absolute; inset: -20%;
  background:
    radial-gradient(circle at 20% 30%, rgba(14,165,233,.35) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(99,102,241,.30) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(14,165,233,.15) 0%, transparent 60%);
  filter: blur(30px);
  animation: vlx-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes vlx-drift {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-3%, 3%) rotate(8deg); }
}

/* Dot-grid texture on top of the mesh */
body[data-path="login"] .vlx-brand::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.06) 1px,
                                            transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

body[data-path="login"] .vlx-brand-top,
body[data-path="login"] .vlx-brand-mid,
body[data-path="login"] .vlx-brand-bot {
  position: relative; z-index: 1;
}

body[data-path="login"] .vlx-brand-mark {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: 18px; letter-spacing: -0.01em;
}
body[data-path="login"] .vlx-brand-mark .vlx-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--vlx-accent), var(--vlx-accent-2));
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 16px -4px rgba(14,165,233,.5);
}

body[data-path="login"] .vlx-brand-title {
  font-size: 44px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 20px;
  color: white;
}
body[data-path="login"] .vlx-brand-tagline {
  font-size: 16px;
  line-height: 1.6;
  color: rgba(241,245,249,.75);
  max-width: 420px;
  margin: 0 0 36px;
}

body[data-path="login"] .vlx-feats {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 14px;
}
body[data-path="login"] .vlx-feats li {
  display: flex; align-items: flex-start; gap: 12px;
  font-size: 14px;
  color: rgba(241,245,249,.85);
}
body[data-path="login"] .vlx-feats svg {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  color: var(--vlx-accent);
  margin-top: 1px;
}

body[data-path="login"] .vlx-brand-bot {
  font-size: 12px;
  color: rgba(241,245,249,.55);
  display: flex; justify-content: space-between; align-items: center;
}

/* ── Form pane (right) ────────────────────────────────────────────── */
body[data-path="login"] .vlx-form-pane {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 32px;
  background: var(--vlx-card-bg);
}
@media (max-width: 1024px) {
  body[data-path="login"] .vlx-form-pane {
    background: transparent;
    padding: 24px 20px;
    align-items: flex-start;
    padding-top: 8vh;
  }
}

body[data-path="login"] .vlx-form-inner {
  width: 100%;
  max-width: 420px;
}

body[data-path="login"] .vlx-form-welcome {
  margin-bottom: 28px;
}
body[data-path="login"] .vlx-form-welcome h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--vlx-text);
}
body[data-path="login"] .vlx-form-welcome p {
  color: var(--vlx-text-2);
  font-size: 14px;
  margin: 0;
}

/* Mobile-only inline brand badge (since the brand pane is hidden) */
body[data-path="login"] .vlx-mobile-brand {
  display: none;
  align-items: center; gap: 10px;
  margin-bottom: 20px;
  font-weight: 700; font-size: 16px;
  color: var(--vlx-text);
}
@media (max-width: 1024px) {
  body[data-path="login"] .vlx-mobile-brand { display: flex; }
}
body[data-path="login"] .vlx-mobile-brand .vlx-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--vlx-accent), var(--vlx-accent-2));
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 14px;
}

/* ── Restyle Frappe's existing login form elements ────────────────── */

body[data-path="login"] .for-login,
body[data-path="login"] .for-email-login,
body[data-path="login"] .for-signup,
body[data-path="login"] .for-forgot,
body[data-path="login"] .for-login-with-email-link {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Frappe wraps the form in .login-content.page-card — flatten it */
body[data-path="login"] .login-content,
body[data-path="login"] .page-card {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
}

body[data-path="login"] .page-card-head {
  display: none !important;  /* replaced by .vlx-form-welcome */
}

body[data-path="login"] .page-card-body {
  padding: 0 !important;
}

body[data-path="login"] .page-card-actions {
  padding: 0 !important;
  margin-top: 8px !important;
}

/* Inputs */
body[data-path="login"] .form-control,
body[data-path="login"] .form-control:focus {
  height: 48px;
  border: 1.5px solid var(--vlx-border);
  border-radius: 10px;
  padding: 0 16px 0 44px;
  font-size: 15px;
  background: var(--vlx-input-bg);
  color: var(--vlx-text);
  box-shadow: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}
body[data-path="login"] .form-control::placeholder {
  color: var(--vlx-muted);
}
body[data-path="login"] .form-control:focus {
  border-color: var(--vlx-accent);
  box-shadow: 0 0 0 4px rgba(14,165,233,.12);
  outline: none;
}

body[data-path="login"] .form-group {
  margin-bottom: 16px;
  position: relative;
}

/* Frappe wraps inputs in .email-field / .password-field and injects
   an SVG icon — move the icon into the input padding zone. */
body[data-path="login"] .email-field,
body[data-path="login"] .password-field {
  position: relative;
}
body[data-path="login"] .field-icon {
  position: absolute !important;
  left: 16px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 18px !important; height: 18px !important;
  color: var(--vlx-muted) !important;
  pointer-events: none;
}
body[data-path="login"] .toggle-password {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--vlx-accent);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}
body[data-path="login"] .toggle-password:hover {
  color: var(--vlx-accent-2);
}

/* Forgot password link */
body[data-path="login"] .forgot-password-message {
  text-align: right;
  margin: -8px 0 18px;
  font-size: 13px;
}
body[data-path="login"] .forgot-password-message a {
  color: var(--vlx-accent);
  font-weight: 500;
  text-decoration: none;
}
body[data-path="login"] .forgot-password-message a:hover {
  text-decoration: underline;
}

/* Primary button — gradient + lift */
body[data-path="login"] .btn-primary,
body[data-path="login"] .btn-login,
body[data-path="login"] .btn-forgot {
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--vlx-accent), var(--vlx-accent-2)) !important;
  border: 0 !important;
  color: white !important;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px -2px rgba(14,165,233,.45) !important;
  transition: transform .12s ease, box-shadow .15s ease, opacity .15s ease;
  width: 100%;
}
body[data-path="login"] .btn-primary:hover,
body[data-path="login"] .btn-login:hover,
body[data-path="login"] .btn-forgot:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -2px rgba(14,165,233,.55) !important;
}
body[data-path="login"] .btn-primary:active,
body[data-path="login"] .btn-login:active {
  transform: translateY(0);
}
body[data-path="login"] .btn-primary:focus,
body[data-path="login"] .btn-login:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(14,165,233,.25),
              0 4px 14px -2px rgba(14,165,233,.45) !important;
}
body[data-path="login"] .btn-primary[disabled],
body[data-path="login"] .btn-login[disabled] {
  opacity: .65;
  transform: none;
  cursor: not-allowed;
}

/* Divider */
body[data-path="login"] .login-divider {
  position: relative;
  text-align: center;
  margin: 24px 0 18px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--vlx-muted);
}
body[data-path="login"] .login-divider::before,
body[data-path="login"] .login-divider::after {
  content: ""; display: block;
  position: absolute; top: 50%;
  width: calc(50% - 28px); height: 1px;
  background: var(--vlx-border);
}
body[data-path="login"] .login-divider::before { left: 0; }
body[data-path="login"] .login-divider::after  { right: 0; }

/* OAuth / social buttons */
body[data-path="login"] .social-login-buttons {
  display: grid;
  gap: 10px;
}
body[data-path="login"] .btn-default,
body[data-path="login"] .btn-login-option {
  height: 44px;
  border-radius: 10px !important;
  border: 1.5px solid var(--vlx-border) !important;
  background: white !important;
  color: var(--vlx-text) !important;
  font-weight: 500;
  font-size: 14px;
  display: flex !important;
  align-items: center; justify-content: center;
  gap: 10px;
  transition: border-color .12s ease, background .12s ease;
  width: 100%;
}
body[data-path="login"] .btn-default:hover,
body[data-path="login"] .btn-login-option:hover {
  border-color: var(--vlx-accent) !important;
  background: #f8fafc !important;
}

/* Sign-up link at the bottom */
body[data-path="login"] .sign-up-message {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--vlx-text-2);
}
body[data-path="login"] .sign-up-message a {
  color: var(--vlx-accent);
  font-weight: 600;
  text-decoration: none;
}
body[data-path="login"] .sign-up-message a:hover {
  text-decoration: underline;
}

/* Inline status / error messages */
body[data-path="login"] .login-status,
body[data-path="login"] .login-message {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  border-left: 3px solid #ef4444;
  font-size: 13px;
}
body[data-path="login"] .login-status:empty,
body[data-path="login"] .login-message:empty {
  display: none;
}

/* Hide the "Login with Email Link" option per user preference. The
   Frappe System Setting "Login with Email Link" still controls
   whether the underlying flow is *available* server-side; this only
   removes the UI affordance. Restore by deleting these rules — the
   form sections + button DOM are still rendered and would re-appear. */
body[data-path="login"] .login-with-email-link.social-login-buttons,
body[data-path="login"] .btn-login-with-email-link,
body[data-path="login"] .for-login-with-email-link,
body[data-path="login"] section.for-login-with-email-link {
  display: none !important;
}

/* Hide the "or" divider that Frappe renders between the email/password
   form and the social-login cluster. With Email Link hidden + no other
   social provider configured, the divider would float with nothing
   beneath it. */
body[data-path="login"] .login-divider,
body[data-path="login"] p.login-divider,
body[data-path="login"] .text-muted.login-divider {
  display: none !important;
}

/* Hide Frappe's small footer / navbar / footer-spacer / page-header
   chunks when on /login — they leave empty headers/breadcrumbs around
   our chrome. The .page_content body retains the form sections; the
   wrappers around it are only cosmetic. */
body[data-path="login"] .navbar,
body[data-path="login"] .web-footer,
body[data-path="login"] footer.web-footer,
body[data-path="login"] .footer-spacer,
body[data-path="login"] .page-breadcrumbs,
body[data-path="login"] .page-header-wrapper,
body[data-path="login"] .page-header {
  display: none !important;
}

/* Frappe's outer container has padding/centering — neutralize it so
   our shell can edge-to-edge fill the viewport. */
body[data-path="login"] #page-login,
body[data-path="login"] #page-login > .page-content-wrapper,
body[data-path="login"] #page-login main.container,
body[data-path="login"] #page-login main.container.my-4 {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Logout success message ribbon (set by vms_logout.py → /login?logged_out=1) */
body[data-path="login"] .vlx-toast {
  position: fixed;
  top: 24px; left: 50%; transform: translateX(-50%);
  background: white;
  border: 1px solid var(--vlx-border);
  border-left: 4px solid #10b981;  /* emerald */
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--vlx-text);
  box-shadow: var(--vlx-shadow);
  z-index: 1000;
  animation: vlx-toast-in .25s ease-out;
}
@keyframes vlx-toast-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
