/* ==========================================================================
   Light / dark theme
   - Theme is set via  <html data-theme="light|dark">  (see assets/js/theme.js)
   - Light = the existing look (no overrides).  Dark = overrides below.
   ========================================================================== */

:root {
    --theme-bg: #ffffff;
    --theme-surface: #ffffff;
    --theme-surface-2: #f5f5f5;
    --theme-text: #333333;
    --theme-text-muted: #6c757d;
    --theme-border: #dddddd;
    --theme-link: #2e7d32;
    --theme-accent: #66bb6a;
    color-scheme: light;
}

html[data-theme="dark"] {
    --theme-bg: #121417;
    --theme-surface: #1c2024;
    --theme-surface-2: #252a30;
    --theme-text: #e4e6e8;
    --theme-text-muted: #9aa3ab;
    --theme-border: #3a4047;
    --theme-link: #81c784;
    --theme-accent: #81c784;
    color-scheme: dark;
}

/* smooth switch (class is only added on the first user toggle, so page load doesn't animate) */
html.theme-animate,
html.theme-animate body,
html.theme-animate * {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease !important;
}

/* ---------- toggle button ---------- */
#themeToggle {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 2000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--theme-border);
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
#themeToggle:hover { border-color: var(--theme-accent); }
#themeToggle:focus-visible { outline: 2px solid var(--theme-accent); outline-offset: 2px; }

/* ==========================================================================
   DARK overrides
   ========================================================================== */
html[data-theme="dark"],
html[data-theme="dark"] body {
    background-color: var(--theme-bg);
    color: var(--theme-text);
}

html[data-theme="dark"] a { color: var(--theme-link); }
html[data-theme="dark"] hr,
html[data-theme="dark"] md-divider { border-color: var(--theme-border); }
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3,
html[data-theme="dark"] h4, html[data-theme="dark"] h5, html[data-theme="dark"] h6,
html[data-theme="dark"] .h1, html[data-theme="dark"] .h2, html[data-theme="dark"] .h3,
html[data-theme="dark"] .h4, html[data-theme="dark"] .h5, html[data-theme="dark"] .h6 { color: inherit; }
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] small { color: var(--theme-text-muted); }

/* ----- Bootstrap 3 ----- */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .well,
html[data-theme="dark"] .jumbotron,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .thumbnail {
    background-color: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .panel-default > .panel-heading,
html[data-theme="dark"] .panel-footer,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .popover-title {
    background-color: var(--theme-surface-2);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .dropdown-menu > li > a { color: var(--theme-text); }
html[data-theme="dark"] .dropdown-menu > li > a:hover,
html[data-theme="dark"] .dropdown-menu > li > a:focus { background-color: var(--theme-surface-2); }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background-color: var(--theme-surface-2);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .form-control::placeholder { color: var(--theme-text-muted); }
html[data-theme="dark"] .input-group-addon {
    background-color: var(--theme-surface-2);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .btn-default {
    background-color: var(--theme-surface-2);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .table,
html[data-theme="dark"] table { color: var(--theme-text); }
html[data-theme="dark"] .table > thead > tr > th,
html[data-theme="dark"] .table > tbody > tr > td,
html[data-theme="dark"] .table > tbody > tr > th,
html[data-theme="dark"] .table > tfoot > tr > td { border-color: var(--theme-border); }
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) { background-color: var(--theme-surface-2); }
html[data-theme="dark"] .table-hover > tbody > tr:hover { background-color: #2d333a; }
html[data-theme="dark"] .nav-tabs { border-color: var(--theme-border); }
html[data-theme="dark"] .nav-tabs > li.active > a,
html[data-theme="dark"] .nav-tabs > li.active > a:hover,
html[data-theme="dark"] .nav-tabs > li.active > a:focus {
    background-color: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .close { color: var(--theme-text); text-shadow: none; }

/* ----- Angular Material ----- */
html[data-theme="dark"] md-content,
html[data-theme="dark"] md-sidenav,
html[data-theme="dark"] md-dialog,
html[data-theme="dark"] md-card,
html[data-theme="dark"] md-menu-content,
html[data-theme="dark"] md-select-menu,
html[data-theme="dark"] md-select-menu md-content,
html[data-theme="dark"] md-autocomplete,
html[data-theme="dark"] .md-autocomplete-suggestions-container,
html[data-theme="dark"] .md-autocomplete-suggestions,
html[data-theme="dark"] md-bottom-sheet,
html[data-theme="dark"] md-list,
html[data-theme="dark"] md-tabs-content-wrapper,
html[data-theme="dark"] .md-calendar-scroll-container,
html[data-theme="dark"] .md-datepicker-calendar-pane {
    background-color: var(--theme-surface);
    color: var(--theme-text);
}
html[data-theme="dark"] md-dialog md-dialog-content,
html[data-theme="dark"] md-dialog .md-dialog-content,
html[data-theme="dark"] md-list-item,
html[data-theme="dark"] md-list-item .md-list-item-text h3,
html[data-theme="dark"] md-list-item .md-list-item-text h4,
html[data-theme="dark"] md-option,
html[data-theme="dark"] .md-subheader,
html[data-theme="dark"] md-checkbox .md-label,
html[data-theme="dark"] md-radio-button .md-label,
html[data-theme="dark"] md-tab-item,
html[data-theme="dark"] md-card-content,
html[data-theme="dark"] md-card-title-text .md-headline,
html[data-theme="dark"] md-card-title-text .md-subhead { color: var(--theme-text); }
html[data-theme="dark"] .md-subheader { background-color: var(--theme-surface); }
html[data-theme="dark"] md-menu-item > .md-button { color: var(--theme-text); }
html[data-theme="dark"] md-menu-item > .md-button:hover,
html[data-theme="dark"] md-option:hover:not([disabled]),
html[data-theme="dark"] md-option:focus:not([disabled]),
html[data-theme="dark"] .md-autocomplete-suggestions li:hover,
html[data-theme="dark"] .md-autocomplete-suggestions li.selected { background-color: var(--theme-surface-2); }
html[data-theme="dark"] md-list-item.md-2-line .md-list-item-text p,
html[data-theme="dark"] md-list-item.md-3-line .md-list-item-text p,
html[data-theme="dark"] .md-input-container label,
html[data-theme="dark"] md-input-container label,
html[data-theme="dark"] md-input-container .md-placeholder { color: var(--theme-text-muted); }
html[data-theme="dark"] md-input-container .md-input,
html[data-theme="dark"] md-input-container textarea,
html[data-theme="dark"] md-select .md-select-value { color: var(--theme-text); background-color: transparent; }
html[data-theme="dark"] md-input-container:not(.md-input-invalid) .md-input,
html[data-theme="dark"] md-select .md-select-value { border-color: var(--theme-border); }
html[data-theme="dark"] md-input-container:not(.md-input-invalid).md-input-focused .md-input { color: var(--theme-accent); }
html[data-theme="dark"] md-dialog md-dialog-actions .md-button:not(.md-primary):not(.md-warn) { color: var(--theme-text); }
html[data-theme="dark"] .md-button:not([disabled]):hover { background-color: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .md-button.md-raised:not(.md-primary):not(.md-accent):not(.md-warn):not([disabled]) {
    background-color: var(--theme-surface-2);
    color: var(--theme-text);
}
html[data-theme="dark"] md-tabs md-tabs-wrapper { background-color: var(--theme-surface); }
html[data-theme="dark"] md-backdrop.md-opaque { background-color: rgba(0, 0, 0, .7); }
html[data-theme="dark"] md-toast .md-toast-content { background-color: #2f353c; color: var(--theme-text); }

/* ----- ng-table / pagination ----- */
html[data-theme="dark"] .ng-table th { color: var(--theme-text); text-shadow: none; }
html[data-theme="dark"] .ng-table th.sortable:hover { background-color: var(--theme-surface-2); }
html[data-theme="dark"] .pagination > li > a,
html[data-theme="dark"] .pagination > li > span {
    background-color: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}
html[data-theme="dark"] .pagination > .active > a { background-color: var(--theme-accent); color: #111; border-color: var(--theme-accent); }

/* ----- hard-coded light surfaces in the bundle / view templates ----- */
html[data-theme="dark"] #homepageSearch,
html[data-theme="dark"] #wrapper_sidenav_r,
html[data-theme="dark"] #wrapper_sidenav_l,
html[data-theme="dark"] [md-whiteframe],
html[data-theme="dark"] md-whiteframe,
html[data-theme="dark"] .outlineInput > label,
html[data-theme="dark"] .services .icon-box,
html[data-theme="dark"] .about-boxes .card,
html[data-theme="dark"] .team .member,
html[data-theme="dark"] #footer .footer-top .footer-newsletter form {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text);
}
html[data-theme="dark"] .about-boxes::before { background: rgba(18, 20, 23, .92) !important; }
html[data-theme="dark"] #preloader { background: var(--theme-bg) !important; }
html[data-theme="dark"] .section-bg { background-color: #181b1f !important; }
html[data-theme="dark"] .BidAskTable > tbody > tr:nth-of-type(2n+1),
html[data-theme="dark"] .tableExpander tr { background-color: var(--theme-surface-2); }
html[data-theme="dark"] .BidAskTable > tbody > tr:nth-of-type(2n) { background-color: var(--theme-surface); }
html[data-theme="dark"] #nav { background-color: rgba(18, 20, 23, .6); }

/* gantt chart */
html[data-theme="dark"] .gtaskheading, html[data-theme="dark"] .gmajorheading, html[data-theme="dark"] .gminorheading,
html[data-theme="dark"] .gmileitem, html[data-theme="dark"] .glineitem,
html[data-theme="dark"] .glistgrid, html[data-theme="dark"] .glistlbl,
html[data-theme="dark"] .gchartgrid, html[data-theme="dark"] .gchartlbl,
html[data-theme="dark"] .JSGanttToolTipcont { background-color: var(--theme-surface); color: var(--theme-text); }
html[data-theme="dark"] .gtaskcellwkend, html[data-theme="dark"] .gminorheadingwkend,
html[data-theme="dark"] .ggroupitem { background-color: var(--theme-surface-2); }

/* dark-navy text colours used by the home-page template (unreadable on dark) */
html[data-theme="dark"] .section-title p,
html[data-theme="dark"] .about .count-box span,
html[data-theme="dark"] .about .count-box p,
html[data-theme="dark"] .about .count-box a,
html[data-theme="dark"] .about .content h3,
html[data-theme="dark"] .about-boxes .card-title a,
html[data-theme="dark"] .about-boxes .card-text,
html[data-theme="dark"] .services .icon-box h4 a,
html[data-theme="dark"] .services .icon-box p,
html[data-theme="dark"] .team .member h4,
html[data-theme="dark"] .team .member span,
html[data-theme="dark"] .team .member p { color: var(--theme-text) !important; }
html[data-theme="dark"] .section-title h2 { color: var(--theme-text-muted); }

html[data-theme="dark"] tr, html[data-theme="dark"] ul.dropdown-menu { background-color: transparent; }

/* ==========================================================================
   View templates: hard-coded colours (sweep of app/views)
   ========================================================================== */

/* inline style="color:black / #000" on text inside views */
html[data-theme="dark"] [style*="color:black"],
html[data-theme="dark"] [style*="color: black"],
html[data-theme="dark"] [style*="color:#000"],
html[data-theme="dark"] [style*="color: #000"],
html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color: #333"] { color: var(--theme-text) !important; }

/* inline white / near-white backgrounds, incl. the ones the table controllers set from JS */
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background-color: rgb(255, 255, 255)"] { background-color: var(--theme-surface) !important; }
html[data-theme="dark"] [style*="background-color: rgb(238, 238, 238)"],
html[data-theme="dark"] [style*="background-color:#eee"],
html[data-theme="dark"] [style*="background-color: #eee"],
html[data-theme="dark"] [style*="background-color:#ddd"],
html[data-theme="dark"] [style*="background: #ddd"],
html[data-theme="dark"] [style*="background:#ddd"] { background-color: var(--theme-surface-2) !important; }
/* price up / down row tints */
html[data-theme="dark"] [style*="background-color: rgb(255, 238, 238)"] { background-color: #3a2326 !important; }
html[data-theme="dark"] [style*="background-color: rgb(238, 255, 238)"] { background-color: #1f3326 !important; }
html[data-theme="dark"] .bk-down { background-color: #3a2326 !important; }
html[data-theme="dark"] .unit-group { background-color: #1f3326 !important; }
html[data-theme="dark"] .tableclass tr:hover { background-color: #3a3820 !important; }

/* trading page: product-category containers (#aim<tableId>) and their rows */
html[data-theme="dark"] [id^="aim"],
html[data-theme="dark"] #productUniqueID,
html[data-theme="dark"] #sidePane { background-color: var(--theme-surface) !important; color: var(--theme-text); }
html[data-theme="dark"] [id^="aim"] .md-button,
html[data-theme="dark"] .productViewID { background-color: transparent; color: var(--theme-text); }
html[data-theme="dark"] [id^="aim"] .md-button:hover,
html[data-theme="dark"] .productViewID:hover { background-color: var(--theme-surface-2); }
html[data-theme="dark"] [style*="background-color:#f7f7f7"],
html[data-theme="dark"] [style*="background-color: #f7f7f7"],
html[data-theme="dark"] [style*="background-color: rgb(247, 247, 247)"] { background-color: var(--theme-surface-2) !important; }
html[data-theme="dark"] .menubtnsel { background-color: #1f3326 !important; color: var(--theme-text); }
html[data-theme="dark"] .active { background-color: var(--theme-surface-2); }

/* dialogs: .md-dialog-content { color: black !important } and  b/strong { color:#000 } */
html[data-theme="dark"] .md-dialog-content,
html[data-theme="dark"] md-dialog b,
html[data-theme="dark"] md-dialog strong,
html[data-theme="dark"] .md-dialog-content b,
html[data-theme="dark"] .md-dialog-content strong,
html[data-theme="dark"] .badgeText a,
html[data-theme="dark"] #sharenav a { color: var(--theme-text) !important; }
html[data-theme="dark"] .btn-tab-active { background-color: var(--theme-surface-2); box-shadow: none; border-color: var(--theme-border); }

/* login / register floating labels (rgb(250,250,250)) and white inputs */
html[data-theme="dark"] md-dialog label,
html[data-theme="dark"] .outlineInput > label { background-color: var(--theme-surface) !important; }
html[data-theme="dark"] #newordersearch,
html[data-theme="dark"] #newordersearch input,
html[data-theme="dark"] #filterBtnID,
html[data-theme="dark"] input[type="text"]:not(.md-input) { background-color: var(--theme-surface-2) !important; color: var(--theme-text) !important; }
html[data-theme="dark"] #newordersearch { border-color: var(--theme-border); box-shadow: none; }

/* sticky / fixed table headers and sidebars */
html[data-theme="dark"] .tableFixHead thead,
html[data-theme="dark"] .tableFixHead th,
html[data-theme="dark"] th,
html[data-theme="dark"] .sticky-header,
html[data-theme="dark"] #sidebar,
html[data-theme="dark"] #sidebar .sidebar-header,
html[data-theme="dark"] #sidebar ul ul a,
html[data-theme="dark"] .cardDeck,
html[data-theme="dark"] .clients { background-color: var(--theme-surface) !important; color: var(--theme-text); }
html[data-theme="dark"] #sidebar ul li a:hover,
html[data-theme="dark"] a.download { background-color: var(--theme-surface-2) !important; }
html[data-theme="dark"] .separator { background-color: var(--theme-surface-2); }

/* navbar drop-downs / feature tabs (home-page template) */
html[data-theme="dark"] .nav-menu .drop-down ul { background-color: var(--theme-surface) !important; }
html[data-theme="dark"] .nav-menu .drop-down ul a,
html[data-theme="dark"] .features .nav-link { color: var(--theme-text) !important; }
html[data-theme="dark"] .features .nav-link { border-color: var(--theme-border); }
html[data-theme="dark"] .features .nav-link.activeNav { color: #fff !important; }

/* chart tooltips */
html[data-theme="dark"] .floating-tooltip-2,
html[data-theme="dark"] .floating-tooltip-forecast { background-color: rgba(28, 32, 36, .85) !important; color: var(--theme-text) !important; }

/* <img> that are meant to look flat on white (icons, logos) keep full strength */
html[data-theme="dark"] img[src$=".svg"],
html[data-theme="dark"] md-icon { opacity: 1; }

/* ----- private cart (#!/pcart1) ----- */
/* page behind the cards: its inline white (or business-mode pale yellow) must stay darker than the cards */
html[data-theme="dark"] #sliderID { background-color: var(--theme-bg) !important; }
html[data-theme="dark"] #sliderID[style*="rgb(252, 252, 214)"] { background-color: #1a1a0f !important; }
/* outline drawn with box-shadow so the card size does not change */
html[data-theme="dark"] .cardDeck {
    background-color: var(--theme-surface-2) !important;
    box-shadow: 0 0 0 1px #4a525b, 0 12px 24px -8px rgba(0, 0, 0, .8);
}
/* unit / quality buttons: the view hard-codes near-black text */
html[data-theme="dark"] .btnUnit:not([disabled]) { color: var(--theme-text); }
html[data-theme="dark"] .btnUnit.btnUnitActive { color: #111; }
/* yellow highlighter behind the totals needs dark text */
html[data-theme="dark"] .totalMarker { color: #111; }
/* strip behind the search box and filter buttons (Bootstrap .navbar-default is light) */
html[data-theme="dark"] #content > .navbar-default {
    background-color: var(--theme-surface);
    border-color: var(--theme-border);
}
html[data-theme="dark"] #content > .navbar-default .topMenuBtn { border-color: var(--theme-border); }
html[data-theme="dark"] #moreFiltersID { color: var(--theme-link) !important; }
/* drop-down menu under the burger button (styled white in Navbar1Component) */
html[data-theme="dark"] .pcartMenuItems {
    background-color: var(--theme-surface-2);
    border-color: var(--theme-border);
    box-shadow: 2px 4px 12px 0 rgba(0, 0, 0, .7);
}
html[data-theme="dark"] .pcartMenuItems a[style*="color:red"] { color: #ff6b6b !important; }
/* link-buttons in pop-ups (contact: phone call / WhatsApp): the dark link colour made their text unreadable */
html[data-theme="dark"] .modal-content a.btn-warning,
html[data-theme="dark"] .modal-content a.btn-success { color: #fff; }

/* ==========================================================================
   Standalone content pages (privacy / terms: WordPress + Word exports with
   their own CSS). Opt in with <html data-theme-mode="invert"> and the whole
   page is colour-inverted in dark mode; images/video/toggle are re-inverted.
   ========================================================================== */
html[data-theme="dark"][data-theme-mode="invert"] {
    filter: invert(1) hue-rotate(180deg);
    background-color: #fff;
}
html[data-theme="dark"][data-theme-mode="invert"] img,
html[data-theme="dark"][data-theme-mode="invert"] video,
html[data-theme="dark"][data-theme-mode="invert"] iframe,
html[data-theme="dark"][data-theme-mode="invert"] #themeToggle {
    filter: invert(1) hue-rotate(180deg);
    opacity: 1;
}

/* ----- slightly soften images on dark ----- */
html[data-theme="dark"] img { opacity: .92; }

/* ==========================================================================
   Standalone payment result pages (successcc.html / failcc.html)
   ========================================================================== */
html[data-theme="dark"] .pay-result h1,
html[data-theme="dark"] .pay-result h2,
html[data-theme="dark"] .pay-result h3 { color: var(--theme-text); }
html[data-theme="dark"] .pay-result h1.pay-fail { color: #ff6b6b !important; }
