/* ============================================================
   AItw9 Mobile  —  tw.css
   Revision 4  (AItw-Mod9_v4.1 package)
   Palette: brand navy #0e286a, amber accent #e8913a
   Sun/moon manual theme toggle + auto dark mode via prefers-color-scheme
   SVG icon styling (icons themselves injected by AI-TW_Update-ver9.js)
   ============================================================ */
 
 
/* ---------- 1. COLOUR VARIABLES (light mode, default) ---------- */
:root,
:root[data-theme="light"] {
    --color-bg-primary:        #eef1f8;
    --color-bg-secondary:      #dde2ee;
    --color-bg-surface:        #e0e4f0;
    --color-bg-input:          #ffffff;
    --color-bg-readonly:       #e8ecf4;
 
    --color-navy:              #0e286a;
    --color-navy-deep:         #091a45;
    --color-navy-light:        #3a6ae8;
    --color-amber:             #e8913a;
    --color-amber-light:       #f5c542;
 
    --color-text-primary:      #0e286a;
    --color-text-secondary:    #3a4a6e;
    --color-text-muted:        #6a7490;
    --color-text-on-navy:      #ffffff;
    --color-text-danger:       #CC0000;
    --color-text-warning:      #800000;
 
    --color-border:            #6a7490;
    --color-border-subtle:     #c4cbdc;
    --color-divider:           #8a94b0;
 
    --color-btn-primary-bg:    #0e286a;
    --color-btn-primary-text:  #ffffff;
    --color-btn-primary-pressed:#091a45;
    --color-btn-glass-bg:      rgba(255,255,255,0.55);
    --color-btn-glass-border:  #6a7490;
 
    --color-header-bg:         #0e286a;
    --color-header-text:       #ffffff;
    --color-accent:            #e8913a;
    --color-list-divider:      #dde2ee;
}
 
 
/* ---------- 2. COLOUR VARIABLES (dark mode) ---------- */
:root[data-theme="dark"] {
    --color-bg-primary:        #0f1629;
    --color-bg-secondary:      #141d33;
    --color-bg-surface:        #1a2240;
    --color-bg-input:          #0a0f1e;
    --color-bg-readonly:       #202840;
 
    --color-navy:              #3a6ae8;
    --color-navy-deep:         #0e286a;
    --color-navy-light:        #6a9af8;
    --color-amber:             #f5c542;
 
    --color-text-primary:      #e8eaf0;
    --color-text-secondary:    #b0b8cc;
    --color-text-muted:        #7788aa;
    --color-text-on-navy:      #ffffff;
    --color-text-danger:       #ff6666;
    --color-text-warning:      #ffaa66;
 
    --color-border:            #555555;
    --color-border-subtle:     #2a3352;
    --color-divider:           #444444;
 
    --color-btn-primary-bg:    #3a6ae8;
    --color-btn-primary-text:  #ffffff;
    --color-btn-primary-pressed:#2a4ac8;
    --color-btn-glass-bg:      rgba(255,255,255,0.08);
    --color-btn-glass-border:  #555555;
 
    --color-header-bg:         #0e286a;
    --color-header-text:       #e8eaf0;
    --color-accent:            #f5c542;
    --color-list-divider:      #1a2240;
}
 
 
/* ---------- 3. SYSTEM DARK MODE (fallback when user hasn't picked) ---------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --color-bg-primary:        #0f1629;
        --color-bg-secondary:      #141d33;
        --color-bg-surface:        #1a2240;
        --color-bg-input:          #0a0f1e;
        --color-bg-readonly:       #202840;
        --color-navy:              #3a6ae8;
        --color-navy-deep:         #0e286a;
        --color-navy-light:        #6a9af8;
        --color-amber:             #f5c542;
        --color-text-primary:      #e8eaf0;
        --color-text-secondary:    #b0b8cc;
        --color-text-muted:        #7788aa;
        --color-text-on-navy:      #ffffff;
        --color-text-danger:       #ff6666;
        --color-text-warning:      #ffaa66;
        --color-border:            #555555;
        --color-border-subtle:     #2a3352;
        --color-divider:           #444444;
        --color-btn-primary-bg:    #3a6ae8;
        --color-btn-primary-pressed:#2a4ac8;
        --color-btn-glass-bg:      rgba(255,255,255,0.08);
        --color-btn-glass-border:  #555555;
        --color-header-bg:         #0e286a;
        --color-header-text:       #e8eaf0;
        --color-accent:            #f5c542;
        --color-list-divider:      #1a2240;
    }
}
 
 
/* ---------- 4. KILL JQM DECORATION GHOSTS ---------- */
.ui-btn::after,
.ui-btn > .ui-icon,
.ui-btn > .ui-btn-inner,
input[type="submit"]::after,
input[type="submit"]::before,
[data-icon="check"]::after,
[data-icon="plus"]::after,
[data-icon="none"]::after,
[data-icon="arrow-l"]::before,
[data-icon="arrow-r"]::after {
    display: none !important;
    background-image: none !important;
    content: none !important;
    width: 0 !important;
}
 
.ui-li a.ui-btn::after,
li.ui-li a::after {
    display: block !important;
    content: '' !important;
    background-image: url('images/icons-png/carat-r-black.png') !important;
    width: 22px !important;
}
 
#themeToggle,
.ui-header .ui-btn-left:empty,
.ui-header .ui-btn-right:empty {
    display: none !important;
}

/* ---------- 4b. HIDE AUTO-INJECTED DIALOG CLOSE BUTTON ---------- */
/* jQuery Mobile auto-injects a top-left "Close" button into every  */
/* data-role="dialog" page. We use the Cancel button inside the     */
/* form instead. Higher specificity required to beat glass-button.  */
.ui-dialog .ui-header a.ui-btn.ui-btn-left,
.ui-dialog .ui-header .ui-btn.ui-btn-left {
    display: none !important;
}
 
/* ---------- 5. RESET AND BASE ---------- */
body {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}
 
 
/* ---------- 6. ACCENT STRIPE ---------- */
[data-role="page"]::before {
    content: '';
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg,
        var(--color-navy) 0%,
        var(--color-navy-light) 50%,
        var(--color-amber) 100%);
    z-index: 1200;
    pointer-events: none;
}
 
 
/* ---------- 7. STATUS BAR (date left, theme toggle right) ---------- */
.tw-statusbar {
    position: fixed;
    top: 5px;
    left: 0;
    right: 0;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border-subtle);
    z-index: 1150;
    pointer-events: none;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-primary);
}
 
.tw-date {
    letter-spacing: 0.02em;
}
 
 
/* ---------- 8. SHIFT PAGE HEADERS DOWN ---------- */
[data-role="page"] > [data-role="header"],
[data-role="page"] > .ui-header {
    margin-top: 35px !important;
}
 
 
/* ---------- 9. HEADER BAR ---------- */
.ui-header,
[data-role="header"] {
    background: var(--color-header-bg) !important;
    color: var(--color-header-text) !important;
    border: none !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    min-height: 44px;
}
 
[data-role="header"] h1,
.ui-header h1 {
    background-color: transparent !important;
    color: var(--color-header-text) !important;
    border: none !important;
    font-size: 1.1em;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-shadow: none;
    padding: 12px 0;
    margin: 0;
    text-align: center;
}
 
 
/* ---------- 10. PAGE BACKGROUND ---------- */
.ui-page,
.ui-content,
.ui-body-a, .ui-body-b, .ui-body-c, .ui-body-d {
    background-color: var(--color-bg-primary) !important;
    color: var(--color-text-primary) !important;
}
 
 
/* ---------- 11. CONTENT TYPOGRAPHY ---------- */
[data-role="content"] p,
[data-role="content"] label {
    color: var(--color-text-primary);
    font-size: 15px;
    line-height: 1.5;
}
 
[data-role="content"] h1 {
    background-color: transparent !important;
    color: var(--color-text-primary) !important;
    border: none !important;
}
 
h2 {
    color: var(--color-text-primary);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-align: center;
}
 
 
/* ---------- 12. INPUT FIELDS ---------- */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea,
.ui-input-text input {
    min-height: 52px !important;
    font-size: 16px !important;
    padding: 12px 14px !important;
    background: var(--color-bg-input) !important;
    color: var(--color-text-primary) !important;
    border: 2px solid var(--color-border-subtle) !important;
    border-radius: 8px !important;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
 
input:focus,
textarea:focus,
.ui-input-text input:focus {
    border-color: var(--color-navy) !important;
    box-shadow: 0 0 0 3px rgba(14, 40, 106, 0.15) !important;
    outline: none;
}
 
input:disabled,
textarea[readonly] {
    background-color: var(--color-bg-readonly) !important;
    color: var(--color-text-muted) !important;
}
 
 
/* ---------- 13. PRIMARY BUTTONS ---------- */
input[type="submit"],
button[type="submit"],
.ui-btn-b,
a[data-role="button"][data-theme="b"],
.tw-btn-primary {
    background: var(--color-btn-primary-bg) !important;
    color: var(--color-btn-primary-text) !important;
    border: none !important;
    border-radius: 12px !important;
    min-height: 56px !important;
    padding: 14px 20px !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    box-shadow: 0 3px 10px rgba(14, 40, 106, 0.25);
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
    text-shadow: none !important;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px;
}
 
input[type="submit"]:active,
button[type="submit"]:active,
.ui-btn-b:active,
.tw-btn-primary:active {
    background: var(--color-btn-primary-pressed) !important;
    box-shadow: 0 1px 3px rgba(14, 40, 106, 0.4);
    transform: translateY(1px);
}
 
 
/* ---------- 14. GLASS MENU BUTTONS ---------- */
.ui-btn:not(.ui-btn-b):not([data-theme="b"]):not(.backtomain):not(#cancel):not(.tw-theme-toggle),
.tw-btn-glass {
    background: var(--color-btn-glass-bg) !important;
    color: var(--color-text-primary) !important;
    border: 1.5px solid var(--color-btn-glass-border) !important;
    border-radius: 12px !important;
    min-height: 56px !important;
    padding: 14px 18px !important;
    box-sizing: border-box;
    font-size: 16px !important;
    font-weight: 500 !important;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 4px rgba(14, 40, 106, 0.08);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    backdrop-filter: blur(12px) saturate(1.2);
    transition: background 0.15s ease, transform 0.05s ease;
    text-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px;
}
 
.ui-btn:not(.ui-btn-b):not([data-theme="b"]):not(.backtomain):not(.tw-theme-toggle):active,
.tw-btn-glass:active {
    background: rgba(255,255,255,0.72) !important;
    transform: translateY(1px);
}
 
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .ui-btn:not(.ui-btn-b):not([data-theme="b"]):not(.backtomain):not(.tw-theme-toggle),
    .tw-btn-glass {
        background: var(--color-bg-secondary) !important;
    }
}
 
 
/* ---------- 15. SECONDARY / CANCEL BUTTONS ---------- */
.backtomain,
#cancel,
.tw-btn-cancel,
a[data-role="button"][data-rel="back"] {
    background: transparent !important;
    color: var(--color-text-secondary) !important;
    border: 1.5px solid var(--color-border-subtle) !important;
    border-radius: 10px !important;
    min-height: 40px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-align: center;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px;
}
 
 
/* ---------- 16. LOGIN CARD LAYOUT ---------- */
#login form p {
    display: flex;
    justify-content: center;
    padding: 8px 0;
    margin: 0;
}
 
#login form p input[type="submit"],
#login form p button[type="submit"] {
    width: 85%;
    max-width: 320px;
}
 
#login form p a#cancel,
#login form p .backtomain {
    width: 55%;
    max-width: 200px;
    display: inline-flex;
}
 
 
/* ---------- 17. LOGO CIRCLE FRAME ---------- */
.tw-logo-circle {
    display: block;
    margin: 12px auto;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: var(--color-bg-surface);
    border: 3px solid var(--color-border);
    padding: 8px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(14, 40, 106, 0.15);
}
.tw-logo-circle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 50%;
}
.tw-logo-circle.tw-logo-circle-small {
    width: 70px;
    height: 70px;
    padding: 6px;
    border-width: 2px;
}
 
 
/* ---------- 18. LIST ITEMS (dynamic menu buttons) ---------- */
.ui-li-static,
.ui-li a {
    min-height: 48px;
    padding-top: 14px;
    padding-bottom: 14px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text-primary);
}
 
.ui-li a,
#selectionlist a,
.ui-navbar li a {
    display: flex !important;
    align-items: center !important;
    gap: 12px;
}
 
.ui-li-divider {
    background-color: var(--color-list-divider) !important;
    color: var(--color-text-primary) !important;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 10px 14px !important;
}
 
 
/* ---------- 19. FOOTER BAR ---------- */
.ui-footer,
[data-role="footer"] {
    background: var(--color-bg-secondary) !important;
    color: var(--color-text-secondary) !important;
    border-top: 1px solid var(--color-border-subtle) !important;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
}
 
.tw-footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 11px;
    color: var(--color-text-muted);
}
.tw-footer-brand img {
    height: 18px;
    width: 18px;
    object-fit: contain;
}
.tw-footer-brand .tw-version {
    font-size: 10px;
    margin-left: 8px;
    color: var(--color-text-muted);
}
 
 
/* ---------- 20. POPUPS ---------- */
.ui-popup {
    background: var(--color-bg-secondary) !important;
    color: var(--color-text-primary) !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 32px rgba(14, 40, 106, 0.35) !important;
    border: 1px solid var(--color-border-subtle) !important;
}
 
 
/* ---------- 21. LOGIN SCREEN specifics ---------- */
#login #login_message {
    color: var(--color-amber);
    font-weight: 500;
    background: transparent !important;
    text-align: center;
}
 
 
/* ---------- 22. SUN / MOON THEME TOGGLE ---------- */
.tw-theme-toggle {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--color-bg-secondary) !important;
    border: 1px solid var(--color-border-subtle) !important;
    color: var(--color-text-primary) !important;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background 0.15s ease;
    padding: 0;
    margin: 0;
}
 
.tw-theme-toggle:active {
    transform: scale(0.92);
    background: var(--color-bg-surface) !important;
}
 
/* ---------- 22b. ADD BUTTON (status bar, next to theme toggle) ---------- */
.tw-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--color-bg-secondary) !important;
    border: 1px solid var(--color-border-subtle) !important;
    color: var(--color-text-primary) !important;
    padding: 0;
    margin: 0;
}

/* ---------- 23. BUTTON ICONS (SVG, injected by AI-TW_Update-ver9.js) ---------- */
.tw-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}
 
input[type="submit"] .tw-icon,
button[type="submit"] .tw-icon,
.tw-btn-primary .tw-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}
 
.backtomain .tw-icon,
#cancel .tw-icon {
    width: 16px;
    height: 16px;
}
 
#selectionlist a .tw-icon,
.ui-li a .tw-icon {
    width: 22px;
    height: 22px;
    margin-left: 4px;
}
 
 
/* ============================================================
   APP-SPECIFIC RULES (preserved from original tw.css)
   ============================================================ */
 
.ui-page .ui-content .ui-listview .ui-li-desc { white-space: normal !important; }
.ui-panel-inner { padding: 0 !important; }
li.ui-li-divider { text-align: center !important; }
li.ui-li-divider[name=disphead],
li[name=dispbody] {
    color: #808080 !important;
    font-style: italic !important;
}
li.ui-li-divider[name=hazass] { font-style: bold !important; }
th.invoicede { border-bottom: 1px solid #d6d6d6; }
table[id=invoice] { font-size: 14px; }
td.price, th.price { text-align: right; }
td.total, p.total { font-style: bold !important; }
td.redtext { font-size: 20px; color: var(--color-text-danger) !important; }
td.outtopay { font-weight: bold; }
.blank_row { height: 20px !important; border-bottom: 1px solid #d6d6d6 !important; }
li[name=unconfirmedbody] { color: var(--color-text-danger) !important; font-style: italic !important; }
.addhead { font-size: 12px !important; }
.scroll-wrapper { -webkit-overflow-scrolling: touch; overflow-y: scroll; }
section { text-align: center; margin: 50px 0; }
.buttons { margin: 40px 0 0; }
img.itemimage { position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; }
p.phone { text-align: left; padding: 0 30px 0 15px; font-size: 16px !important; }
p.signature { font-size: 12px; }
p.banner { color: var(--color-text-warning) !important; }
textarea[name=openponote] { resize: none !important; }
 
 
/* ============================================================
   END tw.css
   ============================================================ */
 
