/* ==========================================================================
   Quorveta — "Obsidian Orange" theme. ONE central token layer for every surface (admin, user, merchant, agent,
   auth, checkout, installer, errors). Loaded last via <x-quorveta-theme/>. The generated companion
   quorveta-palette.css remaps the legacy literal-hex tokens (tools/theme/generate_quorveta_palette.py).
   ========================================================================== */

:root,
[data-theme="light"],
[data-theme="dark"],
[data-coreui-theme="light"],
[data-coreui-theme="dark"] {
    color-scheme: dark;

    /* ---- Brand tokens (the only place the palette is written) ---- */
    --qv-bg:            #111214;   /* app background, sidebar, header */
    --qv-card:          #1C1E23;   /* cards, panels, modals */
    --qv-card-2:        #17191D;   /* inset / alternate surface */
    --qv-card-3:        #23262C;   /* hover / soft surface */
    --qv-border:        #303238;
    --qv-border-soft:   #26282D;
    --qv-text:          #F7F5F2;
    --qv-text-2:        #A6A9B0;
    --qv-text-3:        #7C7F86;
    --qv-orange:        #F47A2A;   /* primary */
    --qv-orange-hover:  #FF8A3D;
    --qv-orange-on-light: #BA4A0C; /* orange used on light surfaces (e-mail, print) */
    --qv-orange-rgb:    244, 122, 42;
    --qv-on-orange:     #14110E;   /* text on orange buttons (dark, AA contrast) */
    /* semantic colours keep their meaning */
    --qv-success:       #34C759;
    --qv-warning:       #F5B63A;
    --qv-danger:        #F0524F;
    --qv-info:          #5AA9F2;

    /* ---- Frontend (user / merchant / agent / auth) semantic tokens ---- */
    --front-color-primary:       var(--qv-orange);
    --front-color-primary-rgb:   var(--qv-orange-rgb);
    --front-color-primary-hover: var(--qv-orange-hover);
    --front-color-primary-dark:  var(--qv-orange-on-light);
    --front-color-secondary:     var(--qv-orange-hover);
    --front-color-accent:        var(--qv-orange-hover);
    --front-color-success:       var(--qv-success);
    --front-color-success-rgb:   52, 199, 89;
    --front-color-warning:       var(--qv-warning);
    --front-color-warning-rgb:   245, 182, 58;
    --front-color-danger:        var(--qv-danger);
    --front-color-danger-rgb:    240, 82, 79;

    --front-color-bg:            var(--qv-bg);
    --front-color-card:          var(--qv-card);
    --front-color-surface:       var(--qv-card-2);
    --front-color-surface-soft:  var(--qv-card-3);
    --front-color-heading:       var(--qv-text);
    --front-color-text:          var(--qv-text);
    --front-color-text-rgb:      247, 245, 242;
    --front-color-text-soft:     var(--qv-text-2);
    --front-color-muted:         var(--qv-text-2);
    --front-color-muted-rgb:     166, 169, 176;
    --front-color-border:        var(--qv-border);
    --front-color-border-soft:   var(--qv-border-soft);
    --background-color-rgb:      17, 18, 20;
    /* The legacy UI uses "white" as its surface colour (glass cards, headers, inputs): it becomes the card colour. */
    --front-color-white:         var(--qv-card);
    --front-color-white-rgb:     28, 30, 35;

    /* ---- Admin (CoreUI) semantic tokens ---- */
    --color-primary:        var(--qv-orange);
    --color-primary-rgb:    var(--qv-orange-rgb);
    --color-primary-hover:  var(--qv-orange-hover);
    --color-primary-deep:   var(--qv-orange-on-light);
    --color-primary-soft:   rgba(var(--qv-orange-rgb), .14);
    --color-primary-subtle: rgba(var(--qv-orange-rgb), .12);
    --color-secondary:      var(--qv-orange-hover);
    --color-accent:         var(--qv-orange-hover);
    --color-success:        var(--qv-success);
    --color-success-rgb:    52, 199, 89;
    --color-warning:        var(--qv-warning);
    --color-danger:         var(--qv-danger);
    --color-info:           var(--qv-info);

    --color-bg:             var(--qv-bg);
    --color-card:           var(--qv-card);
    --color-surface-alt:    var(--qv-card-2);
    --color-surface-alt-rgb: 23, 25, 29;
    --color-surface-soft:   var(--qv-card-3);
    --color-surface-soft-rgb: 35, 38, 44;
    --color-text:           var(--qv-text);
    --color-text-rgb:       247, 245, 242;
    --color-text-soft:      var(--qv-text-2);
    --color-text-subtle:    var(--qv-text-2);
    --color-text-muted:     var(--qv-text-2);
    --color-text-faint:     var(--qv-text-3);
    --color-text-inverse:   var(--qv-on-orange);
    --color-border:         var(--qv-border);
    --color-border-soft:    var(--qv-border-soft);
    --color-border-strong:  #3C3F47;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow-md: 0 8px 18px rgba(0,0,0,.35);
    --shadow-lg: 0 18px 44px rgba(0,0,0,.5);

    --color-white:          var(--qv-card);          /* legacy "white" == surface colour */
    --color-white-rgb:      28, 30, 35;

    --cui-body-bg:          var(--qv-bg);
    --cui-body-bg-rgb:      17, 18, 20;
    --cui-body-color:       var(--qv-text);
    --cui-body-color-rgb:   247, 245, 242;
    --cui-secondary-bg:     var(--qv-card-2);
    --cui-secondary-bg-rgb: 23, 25, 29;
    --cui-tertiary-bg:      var(--qv-card-3);
    --cui-tertiary-bg-rgb:  35, 38, 44;
    --cui-emphasis-color:   var(--qv-text);
    --cui-heading-color:    var(--qv-text);
    --cui-border-color:     var(--qv-border);
    --cui-border-color-translucent: rgba(255,255,255,.08);
    --cui-secondary-color:  var(--qv-text-2);
    --cui-link-color:       var(--qv-orange);
    --cui-link-hover-color: var(--qv-orange-hover);
}

html, body { background: var(--qv-bg); color: var(--qv-text); }

/* ---- Primary actions: orange fill with DARK text (contrast), hover = Orange Hover ---- */
.btn-primary, .btn-primary:focus, .primary-btn, .site-btn, .site-btn-primary, .btn-main, .theme-btn,
button.btn-primary, a.btn-primary, .modal .btn-primary, .swal2-confirm {
    background: var(--qv-orange); border-color: var(--qv-orange); color: var(--qv-on-orange);
}
.btn-primary:hover, .primary-btn:hover, .site-btn:hover, .site-btn-primary:hover, .btn-main:hover, .theme-btn:hover,
.btn-primary:active, .btn-check:checked + .btn-primary {
    background: var(--qv-orange-hover); border-color: var(--qv-orange-hover); color: var(--qv-on-orange);
}
.btn-outline-primary { color: var(--qv-orange); border-color: var(--qv-orange); background: transparent; }
.btn-outline-primary:hover { background: var(--qv-orange); color: var(--qv-on-orange); }

/* ---- Focus ---- */
:focus-visible { outline: 2px solid var(--qv-orange); outline-offset: 2px; }
.form-control:focus, .form-select:focus, input:focus, textarea:focus, select:focus {
    border-color: var(--qv-orange) !important;
    box-shadow: 0 0 0 .2rem rgba(var(--qv-orange-rgb), .22) !important;
}

/* ---- Surfaces and form controls on the dark base ---- */
.card, .modal-content, .dropdown-menu, .offcanvas, .popover, .list-group-item, .accordion-item {
    background-color: var(--qv-card); color: var(--qv-text); border-color: var(--qv-border);
}
.form-control, .form-select, .input-group-text, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="tel"], input[type="url"], textarea, select {
    background-color: var(--qv-card-2); color: var(--qv-text); border-color: var(--qv-border);
}
.form-control::placeholder, input::placeholder, textarea::placeholder { color: var(--qv-text-3); opacity: 1; }
.form-control:disabled, .form-select:disabled { background-color: var(--qv-card-3); color: var(--qv-text-2); }
.table { --bs-table-color: var(--qv-text); --bs-table-bg: transparent; --bs-table-border-color: var(--qv-border);
         --bs-table-striped-bg: rgba(255,255,255,.025); --bs-table-hover-bg: rgba(var(--qv-orange-rgb), .06); color: var(--qv-text); }
.table > :not(caption) > * > * { border-color: var(--qv-border); }
.text-muted, .text-secondary, small, .small { color: var(--qv-text-2) !important; }
hr { border-color: var(--qv-border); opacity: 1; }
.modal-backdrop { --bs-backdrop-bg: #000; }
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
::selection { background: rgba(var(--qv-orange-rgb), .35); color: #fff; }

/* Scrollbars */
* { scrollbar-color: #3C3F47 var(--qv-bg); }

/* ---- Logo sizing in common containers ---- */
.auth-logo, .admin-auth-brand__logo { max-height: 44px; width: auto; }
.sidebar-brand-full { height: 32px; width: auto; }

/* ---- Header brand lockup: full Quorveta logo, role tag beside it ---- */
.ph-brand { gap: 12px; }
.ph-brand__logo { display: block; height: 30px; width: auto; }
.ph-brand__mark { background: transparent !important; box-shadow: none !important; }
.ph-brand__mark img { max-height: 32px; width: auto; }
.ph-brand { min-width: max-content; flex-shrink: 0; }
.ph-brand__text { white-space: nowrap; }

/* ---- Admin sidebar: icons follow the secondary text colour, orange when active/hovered ---- */
.sidebar .nav-icon { color: var(--qv-text-2) !important; }
.sidebar .nav-link:hover .nav-icon, .sidebar .nav-link.active .nav-icon, .sidebar .nav-group.show > .nav-group-toggle .nav-icon { color: var(--qv-orange) !important; }
