/* =====================================================================
   CGSCSC  -  Government portal theme
   SHARED by Login.aspx and MasterPage.master

   Presentation only. No ASP.NET control, ID, event or attribute is
   changed. Everything is matched by page structure or by ID *suffix*
   ([id$="TreeView1"]) so it keeps working whether the control renders
   as "TreeView1" (Login) or "ctl00_TreeView1" (Master).

   Needs a modern browser (Chrome / Edge / Firefox). IE11 has no CSS
   variables, so it is not supported.
   ===================================================================== */

/* ---------- 1. Design tokens (all taken from the existing palette) ---- */
:root {
    --brand: #665b96;       /* existing header colour            */
    --brand-dark: #4f4580;  /* darker shade of the same hue      */
    --accent: #b19dd4;      /* existing sidebar / button colour  */
    --soft: #e9e9fa;        /* existing light panel colour       */
    --link: #5555dd;        /* existing tree hover colour        */
    --gold: #ffeb3b;        /* existing "Yellow", a touch softer */
    --ink: #2b2550;
    --muted: #6b6590;
    --line: #d9d4ee;
    --page: #f4f3fb;
    --danger: #b3261e;
    --sidebar-w: 232px;
}

/* ---------- 2. Base ---------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", "Noto Sans Devanagari", "Nirmala UI", Mangal, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

/* Light polish for every field/button in the app; child pages can still
   override these because the selectors are deliberately low-specificity. */
input[type="text"], input[type="password"], select, textarea {
    border: 1px solid #bdb5dd;
    border-radius: 6px;
    font-family: inherit;
    color: var(--ink);
}
input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    border-color: var(--brand);
}
input[type="submit"], input[type="button"], button {
    border-radius: 6px;
    font-family: inherit;
    cursor: pointer;
    transition: filter .15s ease;
}
input[type="submit"]:hover, input[type="button"]:hover { filter: brightness(.92); }

/* ---------- 3. Page skeleton ------------------------------------------
   The old markup is one big layout <table>. We keep it, but turn it into
   flexbox so it can reflow. "P" below means:
       #form1 > div > table > tbody > tr
   (written out in full each time - plain CSS has no aliases).
   ----------------------------------------------------------------------- */
#form1 > div { font-size: 0; }                     /* removes the stray &nbsp; above the table */

#form1 > div > table {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    font-size: 14px;
    border-collapse: collapse;
}
#form1 > div > table > tbody {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
#form1 > div > table > tbody > tr {
    display: flex;
    flex: 1 0 auto;                                 /* main row grows -> sidebar is full height */
}
/* header row and toolbar row keep their natural height */
#form1 > div > table > tbody > tr:first-child,
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) {
    flex: 0 0 auto;
}
/* cells that span the whole width (header + toolbar) */
#form1 > div > table > tbody > tr > td[colspan] {
    display: block;
    flex: 1 1 100%;
    min-width: 0;
    box-sizing: border-box;
    width: 100% !important;
    height: auto !important;
}
/* the empty spacer row at the bottom of the master page */
#form1 > div > table > tbody > tr > td:only-child:not([colspan]) { display: none; }

/* ---------- 4. Header -------------------------------------------------- */
#form1 > div > table > tbody > tr:first-child > td {
    position: relative;
    padding: 12px 16px 12px !important;
    text-align: center !important;
    color: #fff !important;
    font-size: 17px;
    font-size: clamp(15px, 1.8vw, 20px);
    font-weight: 700 !important;
    line-height: 1.55;
    letter-spacing: .2px;
    background-color: var(--brand) !important;
    background-image:
        radial-gradient(circle at 8% 15%, rgba(255,255,255,.12) 0 110px, transparent 111px),
        radial-gradient(circle at 94% 90%, rgba(177,157,212,.28) 0 170px, transparent 171px),
        linear-gradient(135deg, #7468a6 0%, var(--brand) 45%, var(--brand-dark) 100%) !important;
    border-bottom: 4px solid var(--accent);
}

/* "प्रदायकेन्द्र - " and the godown name become two small chips */
#form1 > div > table > tbody > tr:first-child > td a[id$="HyperLink1"],
#form1 > div > table > tbody > tr:first-child > td span[id$="Label4"] {
    display: inline-block;
    max-width: 100%;
    margin-top: 6px;
    padding: 2px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--gold) !important;
    text-decoration: none;
    border-radius: 999px;
}
#form1 > div > table > tbody > tr:first-child > td a[id$="HyperLink1"]  { background: rgba(255,255,255,.10); border: 1px solid rgba(255,235,59,.45); }
#form1 > div > table > tbody > tr:first-child > td span[id$="Label4"]   { background: rgba(255,255,255,.16); margin-left: 6px; }

/* ---------- 5. Toolbar (Change password / Logout) --------------------- */
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) {
    position: sticky;
    top: 0;
    z-index: 40;
}
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td {
    padding: 5px 16px !important;
    text-align: right !important;
    font-size: 0 !important;                        /* swallows the dozens of &nbsp; spacers */
    background: var(--brand-dark) !important;
    box-shadow: 0 3px 10px rgba(43,37,80,.25);
}
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink4"],
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink3"] {
    display: inline-block;
    margin-left: 8px;
    padding: 4px 13px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    color: #fff !important;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.30);
    border-radius: 999px;
    transition: background .15s ease, color .15s ease;
}
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink4"]:hover { background: #fff; color: var(--brand-dark) !important; }
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink3"]       { background: var(--accent); border-color: var(--accent); color: #2a2250 !important; }
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink3"]:hover { background: #fff; border-color: #fff; }

#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink4"]::before,
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink3"]::before {
    content: "";
    display: inline-block;
    width: 15px; height: 15px;
    margin-right: 8px;
    vertical-align: -2px;
    background: currentColor;
    -webkit-mask: var(--ico) center / contain no-repeat;
            mask: var(--ico) center / contain no-repeat;
}
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink4"] { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12.65 10C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H17v4h4v-4h2v-4H12.65zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z'/></svg>"); }
#form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink3"] { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z'/></svg>"); }

/* ---------- 6. Sidebar (TreeView) ------------------------------------- */
#form1 > div > table > tbody > tr > td:first-child:not([colspan]):not(:only-child) {
    display: block;
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w) !important;
    box-sizing: border-box;
    padding: 10px 8px !important;
    font-size: 0;                                   /* removes the leading &nbsp; line */
    background: #fff !important;
    border-right: 1px solid var(--line);
}

#form1 [id$="TreeView1"] {
    position: sticky;
    top: 16px;
    box-sizing: border-box;
    width: 100% !important;
    max-height: calc(100vh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    background: transparent !important;
    border: 0 !important;
    color: var(--ink) !important;
    font-family: inherit !important;
    font-size: 13px !important;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
/* the master page also has the sticky toolbar above the menu */
#form1 > div > table > tbody > tr:nth-child(3) [id$="TreeView1"] {
    top: 54px;
    max-height: calc(100vh - 66px);
}
#form1 [id$="TreeView1"]::-webkit-scrollbar       { width: 6px; }
#form1 [id$="TreeView1"]::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 6px; }

#form1 [id$="TreeView1"]::before {
    content: "\092E\0947\0928\0942";                /* मेनू */
    display: block;
    margin: 0 0 4px;
    padding: 0 8px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--muted);
    border-bottom: 2px solid var(--soft);
}

/* Every node is a one-row <table>. Table auto-layout let the cells push each
   other around (arrow far left, text far right), so each row is a flex line:
   [indent][arrow][icon][text -> takes all remaining width, left aligned]. */
#form1 [id$="TreeView1"] table {
    display: block !important;
    width: 100% !important;
    border-radius: 6px;
    transition: background .15s ease;
}
#form1 [id$="TreeView1"] table:hover { background: var(--soft); }
#form1 [id$="TreeView1"] tbody { display: block; width: 100%; }
#form1 [id$="TreeView1"] tr { display: flex; align-items: center; width: 100%; }
#form1 [id$="TreeView1"] td {
    flex: 0 0 auto;
    width: auto !important;
    padding: 0 !important;
    text-align: left !important;
    white-space: normal !important;
}
#form1 [id$="TreeView1"] td:last-child { flex: 1 1 0%; min-width: 0; }
#form1 [id$="TreeView1"] img { vertical-align: middle; border: 0; margin: 0; }
#form1 [id$="TreeView1"] tr { min-height: 0; }

/* clickable nodes */
#form1 [id$="TreeView1"] a[class*="TreeView1_"],
#form1 [id$="TreeView1"] span[class*="TreeView1_"] {
    display: block;
    padding: 1px 6px !important;
    text-align: left !important;
    font-family: inherit !important;
    font-size: 13px !important;
    line-height: 1.3;
    color: var(--ink) !important;
    text-decoration: none !important;
    border-radius: 8px;
}
#form1 [id$="TreeView1"] a[class*="TreeView1_"]:hover { color: var(--link) !important; }
/* non-clickable group headings (SelectAction="None") */
#form1 [id$="TreeView1"] span[class*="TreeView1_"] { font-weight: 700; color: var(--brand) !important; }

/* ---------- 7. Content area ------------------------------------------- */
#form1 > div > table > tbody > tr > td:last-child:not([colspan]):not(:only-child) {
    display: block;
    flex: 1 1 0%;
    min-width: 0;
    width: auto !important;
    height: auto !important;
    box-sizing: border-box;
    align-self: flex-start;                         /* card is only as tall as its content */
    margin: 14px 18px 22px;
    padding: 20px 24px 24px !important;
    background-color: #fff !important;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(79,69,128,.10);
    overflow-x: auto;       /* old fixed-width forms scroll inside the card instead of breaking the page */
}

/* ---------- 7b. Desktop sidebar collapse (hamburger) ------------------
   Above 900px the sidebar can be folded away so wide forms get the full
   width. The toggle button lives in the toolbar row (MasterPage.master)
   and flips the class "sidebar-collapsed" on <html>. Below 900px the
   existing off-canvas drawer (section 9) is used instead, so everything
   here is limited to min-width: 901px.
   ----------------------------------------------------------------------- */
.gov-collapse-btn { display: none; }

@media (min-width: 901px) {
    /* the toolbar cell becomes the anchor for the absolutely placed button */
    #form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td { position: relative; }

    .gov-collapse-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        padding: 4px 13px;
        font-family: inherit;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.4;
        color: #fff;
        background: rgba(255,255,255,.12);
        border: 1px solid rgba(255,255,255,.30);
        border-radius: 999px;
        cursor: pointer;
        transition: background .15s ease, color .15s ease;
    }
    .gov-collapse-btn:hover { background: #fff; color: var(--brand-dark); }
    .gov-collapse-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
    /* menu hidden -> button is highlighted so it is obvious how to bring it back */
    .gov-collapse-btn[aria-expanded="false"] { background: var(--accent); border-color: var(--accent); color: #2a2250; }
    .gov-collapse-btn[aria-expanded="false"]:hover { background: #fff; }

    /* open state: only declares the transition, so the sidebar also animates when it re-opens */
    #form1 > div > table > tbody > tr > td:first-child:not([colspan]):not(:only-child) {
        transition: flex-basis .25s ease, width .25s ease, padding .25s ease,
                    border-width .25s ease, visibility 0s;
    }

    /* collapsed state */
    html.sidebar-collapsed #form1 > div > table > tbody > tr > td:first-child:not([colspan]):not(:only-child) {
        flex: 0 0 0px;
        width: 0 !important;
        min-width: 0;
        padding-left: 0 !important;
        padding-right: 0 !important;
        border-right-width: 0;
        overflow: hidden;
        visibility: hidden;                         /* hidden links must not be reachable with Tab */
        transition: flex-basis .25s ease, width .25s ease, padding .25s ease,
                    border-width .25s ease, visibility 0s linear .25s;
    }
}

/* ---------- 8. Mobile menu button + backdrop (created by gov-theme.js) */
.gov-menu-toggle, .gov-backdrop { display: none; }

/* ---------- 9. Tablet & phone ---------------------------------------- */
@media (max-width: 900px) {
    #form1 > div > table > tbody > tr { display: block; }
    #form1 > div > table > tbody > tr > td { width: 100% !important; }

    #form1 > div > table > tbody > tr > td:last-child:not([colspan]):not(:only-child) {
        margin: 10px;
        padding: 14px !important;
    }

    /* Without JavaScript: sidebar simply stacks above the content */
    #form1 > div > table > tbody > tr > td:first-child:not([colspan]):not(:only-child) {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    #form1 [id$="TreeView1"],
    #form1 > div > table > tbody > tr:nth-child(3) [id$="TreeView1"] {
        position: static;
        max-height: 45vh;
    }

    /* With JavaScript: sidebar becomes an off-canvas drawer.
       (The long selector is only there to out-rank the desktop sidebar rule.) */
    html.gov-js #form1 > div > table > tbody > tr > td.gov-sidebar:first-child:not([colspan]):not(:only-child) {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 90;
        width: min(86vw, 330px) !important;
        overflow-y: auto;
        border-bottom: 0;
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform .25s ease, visibility 0s linear .25s;
    }
    html.gov-js.menu-open #form1 > div > table > tbody > tr > td.gov-sidebar:first-child:not([colspan]):not(:only-child) {
        transform: none;
        visibility: visible;
        box-shadow: 0 0 40px rgba(20,15,50,.45);
        transition: transform .25s ease, visibility 0s;
    }
    html.gov-js #form1 > div > table > tbody > tr > td.gov-sidebar [id$="TreeView1"] {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .gov-backdrop {
        display: block;
        position: fixed;
        top: 0; right: 0; bottom: 0; left: 0;
        z-index: 80;
        background: rgba(30,24,60,.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }
    html.menu-open .gov-backdrop { opacity: 1; pointer-events: auto; }

    .gov-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 12px; left: 12px;
        width: 42px; height: 42px;
        padding: 0;
        font-size: 22px;
        line-height: 1;
        color: #fff;
        background: rgba(255,255,255,.16);
        border: 1px solid rgba(255,255,255,.40);
        border-radius: 10px;
    }
    html.gov-js #form1 > div > table > tbody > tr:first-child > td { padding-left: 64px !important; padding-right: 16px !important; }
}

@media (max-width: 480px) {
    #form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td { padding: 8px 10px !important; }
    #form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink4"], #form1 > div > table > tbody > tr:nth-child(2):not(:last-child) > td a[id$="HyperLink3"] { padding: 6px 12px; font-size: 13px; }
}

/* ---------- 10. Accessibility & print --------------------------------- */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
@media print {
    #form1 > div > table > tbody > tr:nth-child(2):not(:last-child),
    #form1 > div > table > tbody > tr > td:first-child:not([colspan]):not(:only-child),
    .gov-menu-toggle, .gov-backdrop { display: none !important; }
    #form1 > div > table > tbody > tr > td:last-child:not([colspan]):not(:only-child) { margin: 0; padding: 0 !important; border: 0; box-shadow: none; overflow: visible; }
}
