/* inventory.css */

/* Base Reset and Variables */
:root {
    --panel-bg: rgba(30, 30, 40, 0.95);
    --panel-border: #3a3a4c;
    --header-bg: #2a2a35;
    --text-color: #e0e0e0;
    --text-muted: #a0a0a0;
    --primary-color: #4d96ff;
    --secondary-color: #6c5ce7;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --slot-border: #666;
    --slot-bg: rgba(60, 60, 70, 0.5);
    --item-bg: rgba(40, 40, 50, 0.8);
    
    --rarity-common: #9e9e9e;
    --rarity-uncommon: #4caf50;
    --rarity-rare: #2196f3;
    --rarity-epic: #9c27b0;
    --rarity-legendary: #ff9800;
    
    --transition-speed: 0.2s;
  }
  
  /* Main UI Container */
  .inventory-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    font-family: 'Arial', sans-serif;
    color: var(--text-color);
    user-select: none;
  }
  
  .inventory-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  
  .inventory-panel {
    background-color: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 90vh;
    min-width: 320px;
    transition: all var(--transition-speed) ease;
  }
  
  /* Header */
  .inventory-header {
    background-color: var(--header-bg);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
  }
  
  .inventory-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-color);
  }
  
  .inventory-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
  }
  
  .inventory-close-btn:hover {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  /* Tabs */
  .inventory-tabs {
    display: flex;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--panel-border);
  }
  
  .inventory-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    flex: 1;
    text-align: center;
    position: relative;
  }
  
  .inventory-tab:hover {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  .inventory-tab.active {
    color: var(--primary-color);
    font-weight: bold;
  }
  
  .inventory-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
  }
  
  /* Content Area */
  .inventory-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
  }
  
  /* Equipment Panel */
  .equipment-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow-y: auto;
    position: relative;
  }
  
  .character-silhouette {
    width: 240px;
    height: 400px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 200"><path d="M50,30 C60,30 70,40 70,50 C70,60 65,65 65,75 L65,90 L62,100 L60,120 L55,150 C55,150 55,155 50,155 C45,155 45,150 45,150 L40,120 L38,100 L35,90 L35,75 C35,65 30,60 30,50 C30,40 40,30 50,30 Z" fill="rgba(255,255,255,0.1)" stroke="rgba(255,255,255,0.3)" stroke-width="1"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    margin: 0 auto;
    position: relative;
  }
  
  .equipment-slot {
    position: absolute;
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .slot-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-align: center;
  }
  
  .item-container {
    width: 50px;
    height: 50px;
    border: 2px solid var(--slot-border);
    border-radius: 6px;
    background-color: var(--slot-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--transition-speed) ease;
  }
  
  .item-container.empty {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z" fill="rgba(255,255,255,0.2)"/></svg>');
    background-repeat: no-repeat;
    background-size: 20px;
    background-position: center;
  }
  
  .item-container:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px var(--primary-color);
  }
  
  /* Slot positions */
  .slot-top {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .slot-top-right {
    top: 10px;
    right: 20%;
  }
  
  .slot-middle-center {
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .slot-middle-lower {
    top: 45%;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .slot-middle-sides {
    top: 35%;
    right: 10%;
  }
  
  .slot-bottom-center {
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .slot-bottom {
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .slot-right-hand {
    top: 40%;
    right: 0;
  }
  
  .slot-left-hand {
    top: 40%;
    left: 0;
  }
  
  /* Stats Panel */
  .stats-panel {
    margin-top: 20px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    max-height: 30%;
    overflow-y: auto;
  }
  
  .stats-panel h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 5px;
  }
  
  .stats-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
  }
  
  .stat-group h4 {
    margin: 0 0 5px 0;
    color: var(--text-color);
    font-size: 0.9rem;
  }
  
  .stat-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }
  
  .stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
  }
  
  .stat-name {
    color: var(--text-muted);
  }
  
  .stat-value {
    color: var(--text-color);
    font-weight: bold;
  }
  
  .stat-value.positive {
    color: var(--success-color);
  }
  
  .stat-value.negative {
    color: var(--danger-color);
  }
  
  .equipment-sets {
    margin-top: 10px;
    border-top: 1px solid var(--panel-border);
    padding-top: 10px;
  }
  
  .equipment-sets h4 {
    margin: 0 0 5px 0;
    color: var(--text-color);
    font-size: 0.9rem;
  }
  
  .set-item {
    margin-bottom: 8px;
  }
  
  .set-name {
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 0.85rem;
    margin-bottom: 3px;
  }
  
  .set-bonuses {
    padding-left: 10px;
    font-size: 0.8rem;
  }
  
  .set-bonus {
    margin-bottom: 2px;
  }
  
  .set-bonus.active {
    color: var(--success-color);
  }
  
  .set-bonus.inactive {
    color: var(--text-muted);
    font-style: italic;
  }
  
  .bonus-req {
    font-weight: bold;
    margin-right: 5px;
  }
  
  /* Inventory Panel */
  .inventory-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow-y: auto;
  }
  
  .inventory-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
  }
  
  .control-group {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  
  .control-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
  }
  
  .inventory-filter,
  .inventory-sort {
    background-color: var(--slot-bg);
    border: 1px solid var(--slot-border);
    border-radius: 4px;
    color: var(--text-color);
    padding: 5px 8px;
    font-size: 0.9rem;
  }
  
  .sort-direction {
    background-color: var(--slot-bg);
    border: 1px solid var(--slot-border);
    border-radius: 4px;
    color: var(--text-color);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
  }
  
  .capacity-indicator {
    margin-bottom: 15px;
    padding: 8px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background-color: rgba(0, 0, 0, 0.2);
  }
  
  .capacity-text {
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--text-muted);
  }
  
  .capacity-bar {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
  }
  
  .capacity-fill {
    height: 100%;
    background-color: var(--success-color);
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
  }
  
  .items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    padding: 5px;
  }
  
  .empty-inventory {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-style: italic;
  }
  
  /* Item Elements */
  .inventory-item {
    width: 100%;
    aspect-ratio: 1/1;
    background-color: var(--item-bg);
    border: 2px solid var(--rarity-common);
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .inventory-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .inventory-item.rarity-common {
    border-color: var(--rarity-common);
  }
  
  .inventory-item.rarity-uncommon {
    border-color: var(--rarity-uncommon);
  }
  
  .inventory-item.rarity-rare {
    border-color: var(--rarity-rare);
  }
  
  .inventory-item.rarity-epic {
    border-color: var(--rarity-epic);
  }
  
  .inventory-item.rarity-legendary {
    border-color: var(--rarity-legendary);
    box-shadow: 0 0 5px var(--rarity-legendary);
  }
  
  .item-icon {
    font-size: 1.8rem;
    color: var(--text-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  }
  
  .item-level {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--text-color);
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Detail Panel */
  .item-detail-panel {
    position: absolute;
    z-index: 100;
    background-color: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-width: 500px;
    width: 90%;
    max-height: 80%;
    left: 50%;
    transform: translateX(-50%);
    top: 10%;
    overflow: hidden;
  }
  
  .detail-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 5;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }
  
  .detail-close-btn:hover {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .detail-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
  }
  
  .detail-header {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
  }
  
  .detail-icon {
    font-size: 3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  }
  
  .detail-title {
    flex: 1;
  }
  
  .detail-title h3 {
    margin: 0 0 5px 0;
    font-size: 1.4rem;
    color: var(--text-color);
  }
  
  .detail-subtitle {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }
  
  .item-type,
  .item-level {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  .item-rarity {
    font-size: 0.8rem;
    font-weight: bold;
  }
  
  .item-rarity.common {
    color: var(--rarity-common);
  }
  
  .item-rarity.uncommon {
    color: var(--rarity-uncommon);
  }
  
  .item-rarity.rare {
    color: var(--rarity-rare);
  }
  
  .item-rarity.epic {
    color: var(--rarity-epic);
  }
  
  .item-rarity.legendary {
    color: var(--rarity-legendary);
  }
  
  .detail-description {
    margin-bottom: 15px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-muted);
  }
  
  .detail-stats,
  .detail-effects {
    margin-bottom: 15px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
  }
  
  .detail-stats h4,
  .detail-effects h4 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 1rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 5px;
  }
  
  .detail-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--panel-border);
  }
  
  .item-value {
    font-size: 0.9rem;
    color: var(--text-muted);
  }
  
  .two-handed-tag {
    background-color: var(--panel-border);
    color: var(--text-color);
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 4px;
  }
  
  .detail-actions {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    background-color: var(--header-bg);
    border-top: 1px solid var(--panel-border);
  }
  
  .action-button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    background-color: var(--panel-bg);
    color: var(--text-color);
    flex: 1;
  }
  
  .action-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  .equip-btn {
    background-color: var(--primary-color);
    color: white;
  }
  
  .equip-btn:hover {
    background-color: var(--secondary-color);
  }
  
  .unequip-btn {
    background-color: var(--secondary-color);
    color: white;
  }
  
  .unequip-btn:hover {
    background-color: var(--primary-color);
  }
  
  .discard-btn {
    background-color: var(--danger-color);
    color: white;
  }
  
  .discard-btn:hover {
    background-color: #c0392b;
  }
  
  /* Context Menu */
  .context-menu {
    position: fixed;
    z-index: 2000;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    overflow: hidden;
  }
  
  .menu-title {
    padding: 8px 12px;
    background-color: var(--header-bg);
    color: var(--text-color);
    font-weight: bold;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--panel-border);
  }
  
  .menu-actions {
    display: flex;
    flex-direction: column;
  }
  
  .menu-action {
    padding: 8px 12px;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease;
  }
  
  .menu-action:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .menu-action:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
  }
  
  .menu-action.discard-action {
    color: var(--danger-color);
  }
  
  .menu-action.discard-action:hover {
    background-color: rgba(231, 76, 60, 0.1);
  }
  
  /* Confirmation Dialog */
  .confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .dialog-content {
    background-color: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
  }
  
  .dialog-content p {
    margin-top: 0;
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 20px;
    text-align: center;
  }
  
  .dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
  }
  
  .confirm-btn,
  .cancel-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
  }
  
  .confirm-btn {
    background-color: var(--danger-color);
    color: white;
  }
  
  .confirm-btn:hover {
    background-color: #c0392b;
  }
  
  .cancel-btn {
    background-color: var(--slot-bg);
    color: var(--text-color);
  }
  
  .cancel-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
  }
  
  /* Notifications */
  .notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 5000;
    max-width: 300px;
  }
  
  .notification.show {
    opacity: 1;
    transform: translateY(0);
  }
  
  .notification.success {
    background-color: var(--success-color);
  }
  
  .notification.error {
    background-color: var(--danger-color);
  }
  
  .notification.info {
    background-color: var(--primary-color);
  }
  
  /* Inventory Button */
  .inventory-toggle-btn {
    padding: 8px 15px;
    background-color: var(--panel-bg);
    color: var(--text-color);
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  }
  
  .inventory-toggle-btn:hover {
    background-color: rgba(77, 150, 255, 0.2);
    border-color: var(--primary-color);
  }
  
  /* Slot Options Grid */
  .slot-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    margin-top: 10px;
  }
  
  .message-content {
    text-align: center;
    padding: 20px 0;
  }
  
  /* Responsive Styles */
  @media (max-width: 768px) {
    .inventory-panel {
      width: 95vw;
    }
    
    .items-grid {
      grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
      gap: 8px;
    }
    
    .inventory-controls {
      flex-direction: column;
      gap: 10px;
    }
    
    .inventory-title {
      font-size: 1.2rem;
    }
    
    .stats-grid {
      grid-template-columns: 1fr;
    }
    
    .item-detail-panel {
      width: 100%;
      max-width: 100%;
      border-radius: 12px 12px 0 0;
      bottom: 0;
      top: auto;
      left: 0;
      transform: none;
    }
    
    .detail-icon {
      font-size: 2.5rem;
    }
    
    .detail-title h3 {
      font-size: 1.2rem;
    }
    
    .slot-options-grid {
      grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
  }
  
  /* Drag and Drop Styling */
  .drag-item-preview {
    position: fixed;
    opacity: 0.7;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
  }
  
  .drop-target-active {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 8px var(--primary-color) !important;
  }
  
  .drop-target-valid {
    border-color: var(--success-color) !important;
    box-shadow: 0 0 8px var(--success-color) !important;
  }
  
  .drop-target-invalid {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 8px var(--danger-color) !important;
  }
  
  /* Animation for Item Equip/Unequip */
  @keyframes item-equip-flash {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); box-shadow: 0 0 10px var(--primary-color); }
    100% { transform: scale(1); }
  }
  
  .item-equip-animation {
    animation: item-equip-flash 0.5s ease;
  }
  
  /* Safe Area Handling (for iPhones with notches) */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .inventory-panel {
      padding-bottom: env(safe-area-inset-bottom);
    }
    
    .detail-actions {
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
  }