/* ============================================================
   Widget Framework — ce-widget-* classes
   Shared visual shell for all right-rail widgets.
   Preserves the existing Cardboard Empires design language:
   dark translucent panels, thin slate borders, gold accents,
   rounded corners, existing typography and spacing rhythm.
   ============================================================ */

/* Stack — vertical container in the right rail */
.ce-widget-stack {
    display: grid;
    gap: 16px;
}

/* Individual widget card */
.ce-widget {
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 16px;
    background:
        radial-gradient(circle at 18% 10%, rgba(212, 168, 83, 0.08), transparent 34%),
        linear-gradient(180deg, rgba(17, 24, 39, 0.72), rgba(7, 11, 18, 0.54));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 18px 40px rgba(0, 0, 0, 0.22);
    padding: 18px;
    position: relative;
}

/* ---- Header ---- */
.ce-widget__header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ce-widget__icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(212, 168, 83, 0.1);
    color: #d4a853;
    font-size: 1.15rem;
    font-weight: 950;
    flex-shrink: 0;
}

.ce-widget__heading {
    flex: 1;
    min-width: 0;
}

.ce-widget__title {
    color: #f4cf80;
    font-size: 1rem;
    font-weight: 950;
    letter-spacing: -0.01em;
}

.ce-widget__subtitle {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.56);
    font-size: 0.74rem;
    line-height: 1.4;
}

/* ---- Close button (hide widget) ---- */
.ce-widget__close {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease;
    padding: 0;
}

.ce-widget__close:hover,
.ce-widget__close:focus-visible {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.ce-widget__close:focus-visible {
    outline: 2px solid rgba(212, 168, 83, 0.5);
    outline-offset: 1px;
}

.ce-widget__close svg {
    width: 14px;
    height: 14px;
}

/* ---- Content body ---- */
.ce-widget__content {
    margin-top: 16px;
}

.ce-widget__select-label {
    display: block;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.56);
    font-size: 0.74rem;
    font-weight: 700;
}

.ce-widget__select {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(3, 7, 14, 0.64);
    color: #e5e7eb;
    padding: 9px 10px;
    font-size: 0.8rem;
}

.ce-widget__dropdown {
    position: relative;
    width: 100%;
}

.ce-widget__dropdown summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(3, 7, 14, 0.64);
    color: #e5e7eb;
    cursor: pointer;
    list-style: none;
    padding: 9px 10px;
    font-size: 0.8rem;
}

.ce-widget__dropdown summary::-webkit-details-marker { display: none; }
.ce-widget__dropdown[open] summary { border-color: rgba(212, 168, 83, 0.52); }

.ce-widget__dropdown-menu {
    position: absolute;
    z-index: 20;
    right: 0;
    left: 0;
    display: grid;
    overflow: hidden;
    margin-top: 5px;
    border: 1px solid rgba(212, 168, 83, 0.25);
    border-radius: 10px;
    background: #111827;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
}

.ce-widget__dropdown-menu a,
.ce-widget__dropdown-menu button {
    border: 0;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    padding: 9px 10px;
    text-align: left;
    text-decoration: none;
    font-size: 0.8rem;
}

.ce-widget__dropdown-menu a:hover,
.ce-widget__dropdown-menu a.is-selected,
.ce-widget__dropdown-menu button:hover {
    background: rgba(212, 168, 83, 0.12);
    color: #f4cf80;
}

.ce-widget__tabs {
    display: flex;
    gap: 6px;
    margin-top: 14px;
}

.ce-widget__tab {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(3, 7, 14, 0.38);
    color: rgba(255, 255, 255, 0.62);
    padding: 7px 8px;
    font-size: 0.74rem;
    font-weight: 800;
}

.ce-widget__tab.is-active {
    border-color: rgba(212, 168, 83, 0.4);
    background: rgba(212, 168, 83, 0.12);
    color: #f4cf80;
}

.ce-widget__trade-panel[hidden] {
    display: none;
}

.ce-widget__empty {
    margin: 14px 0 0;
    color: rgba(255, 255, 255, 0.56);
    font-size: 0.78rem;
    line-height: 1.45;
}

.ce-widget__collector-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.ce-widget__collector {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    background: rgba(3, 7, 14, 0.38);
    padding: 8px;
    font-size: 0.82rem;
    white-space: nowrap;
}

.ce-widget__avatar {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(212, 168, 83, 0.14);
    color: #f4cf80;
    font-size: 0.72rem;
    font-weight: 900;
    flex-shrink: 0;
}

.ce-widget__username {
    overflow: hidden;
    color: #e5e7eb;
    font-weight: 800;
    text-overflow: ellipsis;
}

.ce-widget__reputation {
    color: #f4cf80;
    flex-shrink: 0;
}

.ce-widget__score {
    margin-left: auto;
    color: #f4cf80;
    font-weight: 900;
    flex-shrink: 0;
}

.ce-widget__away {
    margin: -3px 8px 0 41px;
    color: #fbbf24;
    font-size: 0.68rem;
}

.ce-widget__pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.ce-widget__page {
    width: 28px;
    height: 26px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    background: rgba(3, 7, 14, 0.38);
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.74rem;
    font-weight: 800;
}

.ce-widget__page.is-active {
    border-color: rgba(212, 168, 83, 0.4);
    background: rgba(212, 168, 83, 0.12);
    color: #f4cf80;
}

.ce-widget__pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.ce-widget__page {
    width: 28px;
    height: 26px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    background: rgba(3, 7, 14, 0.38);
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.74rem;
    font-weight: 800;
}

.ce-widget__page.is-active {
    border-color: rgba(212, 168, 83, 0.4);
    background: rgba(212, 168, 83, 0.12);
    color: #f4cf80;
}

/* ---- Row (label + value) ---- */
.ce-widget__rows {
    display: grid;
    gap: 10px;
    margin: 0;
}

.ce-widget__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
    padding-bottom: 9px;
}

.ce-widget__row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ce-widget__label {
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.78rem;
    line-height: 1.25;
    display: flex;
    align-items: center;
}

.ce-widget__value {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 950;
    white-space: nowrap;
}

.ce-widget__hint {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.44);
    font-size: 0.68rem;
}

/* ---- Tooltip trigger (inline ? button) ---- */
.ce-widget__tooltip-trigger {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(245, 166, 35, 0.3);
    background: rgba(245, 166, 35, 0.08);
    color: #f5a623;
    font-size: 10px;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    margin-left: 6px;
    vertical-align: middle;
    padding: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
    user-select: none;
    flex-shrink: 0;
}

.ce-widget__tooltip-trigger:hover,
.ce-widget__tooltip-trigger:focus-visible {
    background: rgba(245, 166, 35, 0.16);
    border-color: rgba(245, 166, 35, 0.5);
}

.ce-widget__tooltip-trigger:focus-visible {
    outline: 2px solid rgba(212, 168, 83, 0.5);
    outline-offset: 1px;
}

/* Tooltip content — positioned above trigger */
.ce-widget__tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: 320px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(16, 24, 40, 0.98);
    border: 1px solid rgba(245, 166, 35, 0.2);
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 5000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.ce-widget__tooltip::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(245, 166, 35, 0.2);
    pointer-events: none;
}

/* Tooltip visible state */
.ce-widget__tooltip-trigger:hover .ce-widget__tooltip,
.ce-widget__tooltip-trigger:focus .ce-widget__tooltip,
.ce-widget__tooltip.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ---- Footer action link ---- */
.ce-widget__action {
    display: inline-flex;
    justify-content: center;
    margin-top: 16px;
    width: 100%;
    border: 1px solid rgba(212, 168, 83, 0.32);
    border-radius: 10px;
    color: #f4cf80;
    padding: 9px 12px;
    font-size: 0.82rem;
    font-weight: 950;
    text-decoration: none;
    transition: background 0.15s ease;
}

.ce-widget__action:hover {
    background: rgba(212, 168, 83, 0.08);
}

/* ---- Error state ---- */
.ce-widget--error {
    border-color: rgba(239, 68, 68, 0.25);
}

.ce-widget__error {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: rgba(252, 165, 165, 0.9);
    font-size: 0.78rem;
    line-height: 1.5;
}

.ce-widget__retry {
    display: inline-block;
    margin-top: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    background: transparent;
    color: #fca5a5;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ce-widget__retry:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ---- Animations ---- */
.ce-widget.is-hiding {
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* ---- Undo toast ---- */
.ce-widget-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(212, 168, 83, 0.2);
    background: rgba(17, 24, 39, 0.85);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.78rem;
    line-height: 1.4;
}

.ce-widget-toast__text {
    flex: 1;
    min-width: 0;
}

.ce-widget-toast__undo {
    border: 1px solid rgba(212, 168, 83, 0.32);
    border-radius: 8px;
    background: transparent;
    color: #f4cf80;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.ce-widget-toast__undo:hover {
    background: rgba(212, 168, 83, 0.1);
}
