/* =========================================================
   I-SAPS ERPNext Modern Corporate Theme (Light & Dark) - V2
   ========================================================= */

/* --- 1. THEME VARIABLES (The Source of Truth) --- */
:root {
  /* I-SAPS Branding */
  --isaps-primary: #004b87;         /* Deep Corporate Blue */
  --isaps-primary-light: #e0f2fe;   /* Soft blue for light mode active states */
  
  /* Light Theme Defaults */
  --bg-app: #f3f4f6;                /* Neutral light gray canvas */
  --bg-sidebar: #ffffff;            
  --bg-surface: #ffffff;            /* Pure white cards */
  --bg-hover: #f9fafb;              
  --text-main: #111827;             /* Crisp dark text */
  --text-muted: #6b7280;            
  --border-color: #e5e7eb;          
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  /* Dark Theme Overrides - High Contrast Midnight Slate */
  --isaps-primary: #3b82f6;         /* Brighter, legible blue */
  --isaps-primary-light: rgba(59, 130, 246, 0.15); /* Translucent glow */
  
  --bg-app: #0b1120;                /* Ultra-deep slate background */
  --bg-sidebar: #111827;            /* Slightly elevated slate */
  --bg-surface: #111827;            /* Card backgrounds matching sidebar */
  --bg-hover: #1f2937;              
  --text-main: #f8fafc;             /* Brilliant white for readability */
  --text-muted: #94a3b8;            
  --border-color: #334155;          /* Crisp, visible dark borders */
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* =========================================================
   2. GLOBAL CANVAS FIXES
   ========================================================= */

body, 
.page-container, 
.workspace .layout-main-section {
  background-color: var(--bg-app) !important;
  color: var(--text-main) !important;
}

/* Strip out legacy ERPNext backgrounds that cause blocks of white/black */
.workspace .layout-main-section .desk-page {
  background-color: transparent !important;
  box-shadow: none !important; 
  border: none !important;
}

/* Ensure Page Headings are visible */
.desk-page .ce-header span.h4,
.page-title h3 {
  color: var(--text-main) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
}

/* =========================================================
   3. SIDEBAR POLISH (Fixing the margin/padding issues)
   ========================================================= */

.desk-sidebar {
  background-color: var(--bg-sidebar) !important;
  border-right: 1px solid var(--border-color) !important;
}

/* Section Labels */
.desk-sidebar .standard-sidebar-label {
  color: var(--text-muted) !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-left: 16px !important;
}

/* Base item spacing - pulling it off the edges */
.desk-sidebar .standard-sidebar-item .item-anchor {
  color: var(--text-main) !important;
  border-radius: 6px !important;
  padding: 8px 12px !important;
  margin: 4px 12px !important; /* FIX: Floats the highlight pill inside the sidebar */
  transition: all 0.2s ease;
}

.desk-sidebar .standard-sidebar-item .item-anchor:hover {
  background-color: var(--bg-hover) !important;
}

/* Selected State */
.desk-sidebar .standard-sidebar-item.selected .item-anchor {
  background-color: var(--isaps-primary-light) !important;
  color: var(--isaps-primary) !important;
  font-weight: 600;
}

/* Make the icons match the text color dynamically */
.desk-sidebar .standard-sidebar-item.selected .sidebar-item-icon svg {
  fill: var(--isaps-primary) !important;
  stroke: var(--isaps-primary) !important;
}


/* =========================================================
   10. BRANDED BLUE NAVBAR (Final & Fixed)
   ========================================================= */

/* Force the Navbar to be I-SAPS Blue in ALL themes (Light & Dark) */
body header.navbar.navbar-expand {
    background-color: #004b87 !important; /* The core brand color */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-top: none !important;
    box-shadow: 0 4px 12px rgba(0, 75, 135, 0.25) !important;
    height: 64px !important;
    padding: 0 20px !important;
}

/* Force Logo to fit and filter it to white if it's transparent, or keep original */
/* If your logo has a white background, remove the 'filter' line below */
body header.navbar .navbar-brand img.app-logo {
    max-height: 38px !important;
    width: auto !important;
}

/* Navbar Links & Text - Force White for contrast on Blue */
body header.navbar .nav-item .nav-link,
body header.navbar .nav-item .nav-link svg,
body header.navbar .navbar-brand {
    color: rgba(255, 255, 255, 0.9) !important;
    fill: rgba(255, 255, 255, 0.9) !important;
    stroke: rgba(255, 255, 255, 0.9) !important;
}

/* Hover States for Navbar Items */
body header.navbar .nav-item .nav-link:hover,
body header.navbar .nav-item .nav-link:hover svg {
    color: #ffffff !important;
    fill: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-radius: 6px !important;
}

/* The Search Bar - "Glassmorphism" Style */
body header.navbar .search-bar input#navbar-search {
    background-color: rgba(0, 0, 0, 0.2) !important; /* Darkens the blue slightly */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border-radius: 99px !important; /* Full Pill */
    padding: 8px 16px 8px 40px !important; /* Padding for the search icon */
    height: 38px !important;
    font-size: 13px !important;
    transition: all 0.2s ease !important;
}

/* Search Icon Color */
body header.navbar .search-bar .search-icon svg {
    fill: rgba(255, 255, 255, 0.6) !important;
    stroke: none !important;
}

body header.navbar .search-bar input#navbar-search:focus {
    background-color: #ffffff !important; /* Turns white on focus for readability */
    color: #111827 !important;
    border-color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

/* Avatar Border */
body header.navbar .avatar-frame {
    border: 2px solid rgba(255, 255, 255, 0.5) !important;
}

/* =========================================================
   11. LOGIN PAGE (Alignment Fixed via Flexbox)
   ========================================================= */

/* 1. The Background Canvas */
body.login-page {
    background-color: #f3f4f6 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100vh !important;
    width: 100vw !important;
    overflow: hidden !important;
}

/* 2. The Main Card Container */
body.login-page .page-card,
body.login-page .login-content {
    background-color: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    padding: 40px !important;
    width: 100% !important;
    max-width: 400px !important;
    margin: 0 auto !important;
    float: none !important; /* Resets ERPNext float behavior */
}

/* 3. Logo & Headers */
body.login-page .page-card-head {
    text-align: center !important;
    padding-bottom: 20px !important;
}

body.login-page .page-card-head img.app-logo {
    max-height: 50px !important;
    width: auto !important;
    margin-bottom: 16px !important;
}

body.login-page .page-card-head h4 {
    font-size: 18px !important;
    color: #111827 !important;
    font-weight: 700 !important;
}

/* 4. Input Fields - The "Alignment Fix" */
/* We set the parent to relative so the icon can lock to it */
body.login-page .email-field, 
body.login-page .password-field {
    position: relative !important;
    margin-bottom: 16px !important;
}

/* The Input Box itself */
body.login-page .form-control {
    height: 48px !important; /* Fixed height */
    padding-left: 44px !important; /* Space for the left icon */
    padding-right: 12px !important;
    background-color: #f9fafb !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    color: #1f2937 !important;
    width: 100% !important;
}

body.login-page .form-control:focus {
    background-color: #ffffff !important;
    border-color: #004b87 !important;
    box-shadow: 0 0 0 3px rgba(0, 75, 135, 0.1) !important;
}

/* The Left Icon (Lock/Email) */
body.login-page .field-icon {
    position: absolute !important;
    left: 14px !important;
    top: 50% !important;
    transform: translateY(-50%) !important; /* Perfectly centered vertically */
    width: 18px !important;
    height: 18px !important;
    fill: #6b7280 !important;
    stroke: none !important;
    pointer-events: none !important; /* Allows clicking through to the input */
}

/* The "Show" Password Toggle */
body.login-page .toggle-password {
    position: absolute !important;
    right: 14px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    font-size: 12px !important;
    color: #004b87 !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    z-index: 5 !important;
}

/* 5. Buttons */
body.login-page .btn-login {
    background-color: #004b87 !important;
    border: none !important;
    height: 48px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    width: 100% !important;
    margin-top: 10px !important;
    color: #fff !important;
}

body.login-page .btn-login:hover {
    background-color: #003662 !important;
}

body.login-page .btn-login-with-email-link {
    background-color: #ffffff !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
    height: 40px !important;
    margin-top: 16px !important;
    width: 100% !important;
    border-radius: 8px !important;
}
