/**
 * Game Flavor CSS - Ragnarok Frontier
 * Job class badges, stat grids, map names, and other game-specific styling.
 */

/* ==================== Job Class Badges ==================== */

.job-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

/* Swordsman family: warm red */
.job-swordsman {
    background: #fef2f2;
    color: #b91c1c;
}

/* Mage family: blue */
.job-mage {
    background: #eff6ff;
    color: #1d4ed8;
}

/* Archer family: green */
.job-archer {
    background: #f0fdf4;
    color: #15803d;
}

/* Acolyte family: yellow/gold */
.job-acolyte {
    background: #fefce8;
    color: #a16207;
}

/* Merchant family: brown/amber */
.job-merchant {
    background: #fef3c7;
    color: #92400e;
}

/* Thief family: purple */
.job-thief {
    background: #faf5ff;
    color: #7e22ce;
}

/* Special classes */
.job-novice {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.job-taekwon {
    background: #fdf4ff;
    color: #a21caf;
}

.job-gunslinger {
    background: #f5f5f4;
    color: #57534e;
}

.job-ninja {
    background: #0f172a;
    color: #e2e8f0;
}

/* Dark theme adjustments */
[data-theme="dark"] .job-swordsman {
    background: rgba(185, 28, 28, 0.15);
    color: #fca5a5;
}

[data-theme="dark"] .job-mage {
    background: rgba(29, 78, 216, 0.15);
    color: #93c5fd;
}

[data-theme="dark"] .job-archer {
    background: rgba(21, 128, 61, 0.15);
    color: #86efac;
}

[data-theme="dark"] .job-acolyte {
    background: rgba(161, 98, 7, 0.15);
    color: #fde68a;
}

[data-theme="dark"] .job-merchant {
    background: rgba(146, 64, 14, 0.15);
    color: #fcd34d;
}

[data-theme="dark"] .job-thief {
    background: rgba(126, 34, 206, 0.15);
    color: #d8b4fe;
}

[data-theme="dark"] .job-novice {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

[data-theme="dark"] .job-taekwon {
    background: rgba(162, 28, 175, 0.15);
    color: #f0abfc;
}

[data-theme="dark"] .job-gunslinger {
    background: rgba(87, 83, 78, 0.15);
    color: #d6d3d1;
}

[data-theme="dark"] .job-ninja {
    background: rgba(15, 23, 42, 0.4);
    color: #94a3b8;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .job-swordsman {
        background: rgba(185, 28, 28, 0.15);
        color: #fca5a5;
    }
    :root:not([data-theme="light"]) .job-mage {
        background: rgba(29, 78, 216, 0.15);
        color: #93c5fd;
    }
    :root:not([data-theme="light"]) .job-archer {
        background: rgba(21, 128, 61, 0.15);
        color: #86efac;
    }
    :root:not([data-theme="light"]) .job-acolyte {
        background: rgba(161, 98, 7, 0.15);
        color: #fde68a;
    }
    :root:not([data-theme="light"]) .job-merchant {
        background: rgba(146, 64, 14, 0.15);
        color: #fcd34d;
    }
    :root:not([data-theme="light"]) .job-thief {
        background: rgba(126, 34, 206, 0.15);
        color: #d8b4fe;
    }
    :root:not([data-theme="light"]) .job-novice {
        background: rgba(255, 255, 255, 0.06);
        color: var(--text-secondary);
    }
    :root:not([data-theme="light"]) .job-taekwon {
        background: rgba(162, 28, 175, 0.15);
        color: #f0abfc;
    }
    :root:not([data-theme="light"]) .job-gunslinger {
        background: rgba(87, 83, 78, 0.15);
        color: #d6d3d1;
    }
    :root:not([data-theme="light"]) .job-ninja {
        background: rgba(15, 23, 42, 0.4);
        color: #94a3b8;
    }
}

/* ==================== Item Type Badges ==================== */

.item-type-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

.item-type-weapon { background: var(--item-weapon-bg); color: var(--item-weapon-text); }
.item-type-armor { background: var(--item-armor-bg); color: var(--item-armor-text); }
.item-type-consumable, .item-type-heal { background: var(--item-consumable-bg); color: var(--item-consumable-text); }
.item-type-card { background: var(--item-card-bg); color: var(--item-card-text); }
.item-type-usable { background: var(--item-usable-bg); color: var(--item-usable-text); }
.item-type-special { background: var(--item-special-bg); color: var(--item-special-text); }
.item-type-etc, .item-type-ammo, .item-type-pet_egg, .item-type-pet_equip {
    background: var(--item-etc-bg); color: var(--item-etc-text);
}

/* ==================== Stat Grid ==================== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 8px 0;
}

.stat-cell {
    background: var(--bg-muted);
    border-radius: var(--radius);
    padding: 8px 10px;
    text-align: center;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* ==================== Map Name ==================== */

.map-name {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-muted);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ==================== Level Display ==================== */

.level-display {
    color: var(--primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.level-separator {
    color: var(--text-muted);
    font-weight: 400;
    margin: 0 2px;
}

/* ==================== Character Detail Page ==================== */

.char-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) 0 var(--space-4);
    flex-wrap: wrap;
}

.char-detail-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.char-sprite-container {
    flex-shrink: 0;
    width: 56px;
    height: 80px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: visible;
}

.char-sprite-container img {
    image-rendering: pixelated;
    max-width: 56px;
    height: auto;
}

.char-detail-identity {
    min-width: 0;
}

.char-detail-name-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.char-detail-name {
    font-size: var(--text-xl);
    line-height: var(--leading-xl);
    font-weight: 650;
    font-family: var(--font-body);
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-detail-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-1);
}

.char-detail-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 20px;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    background: none;
}

.char-detail-back-btn:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    text-decoration: none;
}

.char-detail-gid {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-muted);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
}

.char-detail-level {
    font-size: 14px;
    color: var(--text-secondary);
}

.char-detail-zeny {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.char-detail-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.char-mail-item {
    margin-bottom: var(--space-2);
}

.char-mail-item--unread {
    border-left: 3px solid var(--primary);
}

.char-mail-body {
    flex: 1;
    min-width: 0;
}

.char-mail-body .server-name {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.char-mail-subject {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

.char-mail-subject:hover {
    text-decoration: underline;
}

.char-edit-tabs {
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.char-warp-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-2);
}

button.equip-slot {
    width: 100%;
    font: inherit;
    color: inherit;
    text-align: start;
}

.char-equip-hint {
    text-align: center;
    margin: var(--space-4) 0 0;
}

/* Compact card body for overview tab */
.card-body-compact {
    padding: var(--space-4);
}

/* Character detail sub-tabs — pinned in panel header */
.char-detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    padding: 0 var(--space-6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.char-detail-tabs::-webkit-scrollbar { display: none; }

.char-tab {
    padding: var(--space-3) var(--space-3);
    border: none;
    background: none;
    font-family: var(--font-body);
    font-size: 13px;
    min-height: 44px;
    font-weight: 400;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.char-tab:hover {
    color: var(--text-primary);
}

.char-tab.active {
    color: var(--text-primary);
    font-weight: 500;
    border-bottom-color: var(--primary);
}

.char-tab-content {
    display: none;
}

.char-tab-content.active {
    display: block;
}

/* Panel header row: sprite + identity */
.char-panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.char-panel-header img {
    image-rendering: pixelated;
    height: 64px;
    width: auto;
    flex-shrink: 0;
}

.char-panel-identity {
    min-width: 0;
}

.char-panel-name-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 2px;
}

.char-panel-name {
    font-size: 16px;
    font-weight: 600;
}

.char-panel-meta {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
    font-size: 13px;
}

/* Panel info grid (2x2 in slide-out) */
.char-panel-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    overflow: hidden;
}

.char-panel-info-cell {
    background: var(--bg-surface);
    padding: var(--space-2) var(--space-3);
}

/* Panel admin actions row */
.char-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

/* Panel section header row */
.char-panel-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.char-panel-section-spacer {
    margin-top: var(--space-3);
}

/* HP/SP progress bars */
.char-progress-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.char-progress-bar {
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    height: 18px;
    overflow: hidden;
    position: relative;
}

.char-progress-fill {
    height: 100%;
    transition: width 0.3s;
}

.char-progress-fill-hp { background: var(--error); }
.char-progress-fill-sp { background: var(--info); }

.char-progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

/* The bar prints its own "cur / max" text; drop a11y.css's generic percent overlay */
.char-progress-bar[role="progressbar"][aria-valuenow]::after {
    content: none;
}

/* Overview stat pairs (EXP, points) */
.char-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4) var(--space-6);
    margin-top: var(--space-3);
}

.char-overview-value {
    font-size: 14px;
}

.char-overview-value.has-points {
    color: var(--primary);
    font-weight: 600;
}

/* Skill points label in panel */
.char-skill-points-label {
    font-size: 12px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .char-detail-header {
        flex-direction: column;
        align-items: stretch;
    }

    .char-detail-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .char-warp-fields {
        grid-template-columns: 1fr;
    }
}

/* Character hotkey bar: icon grid laid out like the client's bars */
.hotkey-bars {
    display: grid;
    gap: var(--space-2);
}

.hotkey-bar {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    align-items: center;
    gap: var(--space-2);
}

.hotkey-bar__label {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.hotkey-bar__slots {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 2.25rem));
    gap: var(--space-1);
}

.hotkey-slot {
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface-alt);
}

.hotkey-slot--empty {
    border-color: var(--border-subtle);
    background: var(--bg-inset);
}

.hotkey-slot__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

.hotkey-slot__link img {
    max-width: 100%;
    image-rendering: pixelated;
}

.hotkey-slot__link:hover {
    background: var(--bg-muted);
}

.hotkey-slot__link[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + var(--space-1));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--text-primary);
    color: var(--bg-surface);
    font-size: var(--text-xs);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.hotkey-slot__link[data-tip]:hover::after,
.hotkey-slot__link[data-tip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transition-delay: 300ms;
    transition-property: opacity, visibility;
}

/* Character skills / script state: multi-column name–value list instead of a full-width table */
.kv-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    column-gap: var(--space-6);
}

.kv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 2.5rem;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.kv-row[hidden] {
    display: none;
}

.kv-row__name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kv-row__value {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kv-row__edit {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.kv-row__edit .skill-level-input {
    width: 7ch;
}

/* Inventory row actions (Edit + remove) stay on one line */
.inv-table .inv-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

/* Companions: pet / homunculus blocks share the record facts grid */
.companion + .companion {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.companion__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.record-facts.companion__facts {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: var(--space-3);
}

.companion__stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    text-align: center;
}

.companion__stats .detail-label {
    display: block;
}

.companion__actions {
    justify-content: flex-end;
}

.companion__skills {
    margin-bottom: var(--space-3);
}

.companion__skills .kv-row__name img {
    margin-right: var(--space-2);
}

.companion-section + .companion-section {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}

.companion-section__title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.companion-section .record-empty {
    padding: 0;
    text-align: left;
}
