/* Workbench Overlay */
.workbench-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

/* Specific Override for GameModal container when used as Workbench */
.game-modal-container.workbench-modal {
    width: 95vw;
    max-width: 1400px;
    height: 90%;
    max-height: 90%;
    background: var(--game-bg-modal);
    border: 1px solid var(--game-border-color);
    box-shadow: var(--game-shadow-modal);
    color: var(--game-text-primary);
    font-family: var(--game-font-main);
}

.game-modal-container.workbench-modal .game-modal-content {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.workbench-menu {
    /* Legacy class support or internal structure if needed, but GameModal is the container */
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.workbench-menu-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.workbench-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--game-bg-panel);
    border-bottom: 1px solid var(--game-border-color);
}

.workbench-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--game-text-highlight);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.workbench-header-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--game-bg-panel);
    border-bottom: 1px solid var(--game-border-color);
    flex-shrink: 0;
}

.workbench-tabs {
    display: flex;
    gap: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #a0aec0;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    clip-path: var(--game-clip-path-sm);
}

.tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: #3182ce;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.close-btn {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(245, 101, 101, 0.2);
    color: #f56565;
}

/* Workbench Layout */
.workbench-content-grid {
    display: flex;
    /* Changed to flex to match inventory layout logic if needed, but grid is fine if aligned */
    /* Keeping grid but fixing transparency */
    display: grid;
    grid-template-columns: 220px 1fr;
    /* Changed to 2-column layout to match inventory? No, Inventory has 2 cols (sidebar + content). Workbench has 3 (sidebar + items + details). */
    /* Let's keep 3 columns but better styled */
    grid-template-columns: 220px 350px 1fr;
    height: 100%;
    overflow: hidden;
    background: var(--game-bg-app);
    /* Solid background */
}

/* Column 1: Sidebar */
.workbench-sidebar {
    background: var(--game-bg-panel);
    border-right: 1px solid var(--game-border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.sidebar-title {
    color: #a0aec0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.workbench-sidebar .category-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.workbench-sidebar .category-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.workbench-sidebar .category-btn.active {
    background: rgba(66, 153, 225, 0.15);
    border-color: #4299e1;
    color: #63b3ed;
}

.workbench-sidebar .cat-icon {
    font-size: 1.2rem;
    width: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.workbench-sidebar .cat-label {
    font-weight: 500;
}

/* Column 2: Items List */
.workbench-items-column {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--game-border-color);
    background: var(--game-bg-panel);
    overflow: hidden;
}

.workbench-filters {
    padding: 1rem;
    border-bottom: 1px solid var(--game-border-color);
    background: var(--game-bg-input);
    width: 100%;
    box-sizing: border-box;
    /* Match search bar bg */
}

.workbench-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.workbench-item-card {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: #ffffff08;
    border: 1px solid var(--game-border-color);
    clip-path: var(--game-clip-path);
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.5rem;
}

.workbench-item-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(2px);
}

.workbench-item-card.selected {
    background: rgba(234, 113, 66, 0.1);
    border-color: var(--game-color-primary);
    box-shadow: 0 0 0 1px var(--game-color-primary);
}

.workbench-item-card.craftable {
    border-left: 3px solid var(--game-color-success);
}

.workbench-item-card.repairable {
    border-left: 3px solid var(--game-color-warning);
}

.workbench-item-card.salvageable {
    border-left: 3px solid var(--game-color-danger);
}

.item-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.item-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.item-emoji {
    font-size: 1.2rem;
}

.item-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.95rem;
}

.item-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.tier-badge {
    background: #2d3748;
    padding: 1px 4px;
    border-radius: 3px;
    color: #a0aec0;
    font-weight: bold;
}

.tier-badge.tier-1 {
    color: #fff;
}

.tier-badge.tier-2 {
    color: #68d391;
}

.tier-badge.tier-3 {
    color: #63b3ed;
}

.tier-badge.tier-4 {
    color: #9f7aea;
}

.tier-badge.tier-5 {
    color: #ed8936;
}

.equipped-badge {
    color: #48bb78;
    font-weight: bold;
    background: rgba(72, 187, 120, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

.item-stats-mini {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.stat-mini {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    color: #cbd5e0;
    white-space: nowrap;
}

.stat-mini.durability {
    color: #fbbf24;
}

.status-icon {
    font-size: 1.2rem;
    margin-left: 0.5rem;
}

/* Item Image Thumbnail */
.item-image-thumb {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #4a5568;
    margin-right: 0.75rem;
    clip-path: var(--game-clip-path-sm);
}

.item-thumb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    clip-path: var(--game-clip-path-sm);
}

.item-thumb-emoji {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-thumb-emoji.hidden {
    display: none;
}

/* Tier Colors for Item Names */
.item-name.text-tier-0 {
    color: #a0aec0;
}

.item-name.text-tier-1 {
    color: #ffffff;
}

.item-name.text-tier-2 {
    color: #68d391;
}

.item-name.text-tier-3 {
    color: #63b3ed;
}

.item-name.text-tier-4 {
    color: #9f7aea;
}

.item-name.text-tier-5 {
    color: #ed8936;
}

/* Condition Text for Salvage Tab */
.condition-text {
    font-size: 0.75rem;
    color: #a0aec0;
    font-weight: 500;
}

/* Mini Progress Bar */
.mini-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
    width: 100%;
}

.mini-progress-fill {
    height: 100%;
    border-radius: 2px;
}

.mini-progress-fill.good {
    background: #48bb78;
}

.mini-progress-fill.warning {
    background: #ed8936;
}

.mini-progress-fill.critical {
    background: #f56565;
}

/* Repair Preview - Dual Color Durability Bar */
.repair-preview-bar {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    margin-bottom: 0.5rem;
}

.repair-preview-current {
    position: absolute;
    height: 100%;
    background: #ed8936;
    transition: width 0.3s ease;
}

.repair-preview-restored {
    position: absolute;
    height: 100%;
    background: #48bb78;
    transition: width 0.3s ease, left 0.3s ease;
}

.repair-preview-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #a0aec0;
    margin-bottom: 0.5rem;
}

.repair-preview-text .current {
    color: #ed8936;
}

.repair-preview-text .restored {
    color: #48bb78;
}

/* Column 3: Details */
.workbench-details-column {
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--game-bg-panel);
}

.detail-header {
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 600px;
}

.detail-image-container {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem auto;
    clip-path: var(--game-clip-path);
    overflow: hidden;
    border: 2px solid var(--game-border-color);
    background: var(--game-bg-input);
    box-shadow: var(--game-shadow-card);
}

.detail-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--game-bg-card);
}

.detail-title {
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 0.5rem;
}

.detail-description {
    color: #a0aec0;
    font-style: italic;
    line-height: 1.5;
}

.detail-requirements {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    clip-path: var(--game-clip-path);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.detail-requirements h4 {
    color: #63b3ed;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.requirement-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

.requirement-item.met {
    color: #48bb78;
}

.requirement-item.missing {
    color: #f56565;
}

.detail-actions {
    width: 100%;
    max-width: 600px;
    margin-top: auto;
}

.craft-btn,
.repair-btn,
.uncraft-btn {
    width: 100%;
    padding: 1rem;
    clip-path: var(--game-clip-path);
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.craft-btn {
    background: linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%);
    color: #1a202c;
}

.craft-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(236, 201, 75, 0.3);
}

.repair-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #fff;
}

.repair-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.uncraft-btn {
    background: linear-gradient(135deg, #f56565 0%, #c53030 100%);
    color: #fff;
}

.uncraft-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.3);
}

.craft-btn:disabled,
.repair-btn:disabled,
.uncraft-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: #4a5568;
    color: #a0aec0;
}

.workbench-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #718096;
    text-align: center;
}

/* Equipped Badge - Matches InventoryModal */
.item-card-equipped {
    font-size: 0.7rem;
    padding: 2px 6px;
    clip-path: var(--game-clip-path-sm);
    background: rgba(66, 153, 225, 0.2);
    color: #63b3ed;
    border: 1px solid rgba(66, 153, 225, 0.4);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    vertical-align: middle;
}

/* Action Info Labels */
.action-info {
    text-align: center;
    font-size: 0.9rem;
    color: #a0aec0;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.action-info.warning {
    color: #ed8936;
    font-weight: 600;
}

.action-info.success {
    color: #48bb78;
    font-weight: 600;
}