@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    /* Core colors */
    --color-bg-primary: 17, 24, 39;    /* #111827 */
    --color-bg-secondary: 31, 41, 55;  /* #1F2937 */
    --color-bg-tertiary: 55, 65, 81;   /* #374151 */
    
    /* Accent colors */
    --color-accent-purple: 139, 92, 246; /* #8B5CF6 */
    --color-accent-blue: 59, 130, 246;   /* #3B82F6 */
    --color-accent-orange: 249, 115, 22;  /* #F97316 */
    
    /* Text colors */
    --color-text-primary: 255, 255, 255;    /* #FFFFFF */
    --color-text-secondary: 209, 213, 219;  /* #D1D5DB */
    --color-text-tertiary: 156, 163, 175;   /* #9CA3AF */
    
    /* Status colors */
    --color-success: 34, 197, 94;     /* #22C55E */
    --color-warning: 234, 179, 8;     /* #EAB308 */
    --color-error: 239, 68, 68;       /* #EF4444 */
    
    /* Glass effect */
    --glass-bg: rgba(31, 41, 55, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.25);
  }

  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    color: rgb(var(--color-text-primary));
    overflow: hidden;
    user-select: none;
  }

  #root {
    height: 100%;
  }

  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-track {
    background: rgba(var(--color-bg-tertiary), 0.2);
    border-radius: 8px;
  }

  ::-webkit-scrollbar-thumb {
    background: rgba(var(--color-accent-purple), 0.5);
    border-radius: 8px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-accent-purple), 0.7);
  }
  
  p {
    margin: 0;
    padding: 0;
    font-family: inherit;
  }
  
  input[type=number]::-webkit-inner-spin-button,
  input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0;
  }
  
  button:active {
    transform: translateY(2px);
    transition: transform 0.15s ease;
  }
}

@layer components {
  /* App wrapper */
  .app-wrapper {
    height: 100%;
    width: 100%;
    color: rgb(var(--color-text-primary));
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  /* Context menu */
  .context-menu-list {
    min-width: 220px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgb(var(--color-text-primary));
    padding: 8px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--glass-shadow);
    outline: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeIn 0.2s ease;
  }
  
  .context-menu-item {
    padding: 10px 12px;
    border-radius: 8px;
    background-color: transparent;
    outline: none;
    border: none;
    color: rgb(var(--color-text-primary));
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
  }
  
  .context-menu-item:hover {
    background-color: rgba(var(--color-accent-purple), 0.15);
    cursor: pointer;
  }
  
  /* Tooltip */
  .tooltip-wrapper {
    pointer-events: none;
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 240px;
    padding: 12px;
    flex-direction: column;
    color: rgb(var(--color-text-primary));
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px var(--glass-shadow);
    animation: fadeIn 0.2s ease;
  }
  
  .tooltip-wrapper p {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
  }
  
  .tooltip-header-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  
  .tooltip-header-wrapper p {
    font-size: 16px;
    font-weight: 600;
  }
  
  .tooltip-description {
    padding-top: 6px;
    color: rgb(var(--color-text-secondary));
  }
  
  .tooltip-markdown > p {
    margin: 0;
  }
  
  .tooltip-crafting-duration {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background-color: rgba(var(--color-bg-tertiary), 0.3);
    border-radius: 8px;
    padding: 6px 10px;
    margin: 8px 0;
  }
  
  .tooltip-crafting-duration svg {
    padding-right: 6px;
    color: rgb(var(--color-accent-blue));
  }
  
  .tooltip-crafting-duration p {
    font-size: 14px;
  }
  
  .tooltip-ingredients {
    padding-top: 8px;
  }
  
  .tooltip-ingredient {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 4px 0;
  }
  
  .tooltip-ingredient img {
    width: 32px;
    height: 32px;
    padding-right: 8px;
    border-radius: 6px;
  }
}

@layer components {
  /* Inventory */
  .inventory-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 24px;
    padding: 60px;
    background-color: rgb(var(--color-bg-primary));
  }
  
  .inventory-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px var(--glass-shadow);
    animation: fadeIn 0.3s ease;
  }
  
  .inventory-grid-header-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px 12px 8px;
    border-bottom: 1px solid rgba(var(--color-text-primary), 0.1);
    margin-bottom: 8px;
  }
  
  .inventory-grid-header-wrapper p {
    font-size: 18px;
    font-weight: 600;
  }
  
  .inventory-grid-container {
    display: grid;
    height: calc(52.1vh + 10px);
    grid-template-columns: repeat(5, 11vh);
    grid-auto-rows: 11vh;
    gap: 8px;
    overflow-y: auto;
    padding: 4px;
  }
  
  .inventory-slot,
  .item-notification-item-box,
  .hotbar-item-slot {
    background: rgba(var(--color-bg-secondary), 0.6);
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 12px;
    image-rendering: -webkit-optimize-contrast;
    position: relative;
    background-size: 7vh;
    color: rgb(var(--color-text-primary));
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    overflow: hidden;
  }
  
  .inventory-slot:hover,
  .hotbar-item-slot:hover {
    border-color: rgba(var(--color-accent-purple), 0.6);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15), 
                0 0 0 1px rgba(var(--color-accent-purple), 0.2);
    transform: translateY(-2px);
  }
  
  .inventory-slot:active,
  .hotbar-item-slot:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
  }
  
  .inventory-slot-label-box {
    background: rgba(var(--color-bg-tertiary), 0.9);
    color: rgb(var(--color-text-primary));
    text-align: center;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .inventory-slot-label-text {
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 4px 6px;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.5px;
  }
  
  .inventory-slot-number {
    background: rgb(var(--color-accent-purple));
    color: white;
    height: 16px;
    border-top-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: 600;
  }
}

@layer components {
  /* Item slots */
  .item-slot-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
  }
  
  .item-slot-wrapper p {
    font-size: 13px;
  }
  
  .item-slot-header-wrapper,
  .item-hotslot-header-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    padding: 6px;
  }
  
  .item-hotslot-header-wrapper {
    justify-content: space-between !important;
  }
  
  .item-slot-info-wrapper {
    display: flex;
    flex-direction: row;
    align-self: flex-end;
    padding: 6px;
    gap: 6px;
  }
  
  .item-slot-info-wrapper p {
    font-size: 13px;
    font-weight: 500;
  }
  
  .item-slot-currency-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    padding: 6px;
  }
  
  .item-slot-currency-wrapper p {
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    color: rgb(var(--color-accent-orange));
  }
  
  .item-slot-price-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    padding: 6px;
  }
  
  .item-slot-price-wrapper p {
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    color: rgb(var(--color-success));
  }
  
  /* Hotbar */
  .hotbar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: 100%;
    position: absolute;
    bottom: 24px;
    animation: slideUp 0.4s ease;
  }
  
  .hotbar-item-slot {
    width: 11vh;
    height: 11vh;
  }
  
  .hotbar-slot-header-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 6px;
  }
  
  /* Notifications */
  .item-notification-container {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 8px;
    position: absolute;
    bottom: 20vh;
    left: 50%;
    width: auto;
    max-width: 80%;
    transform: translateX(-50%);
    padding: 0 16px;
  }
  
  .item-notification-action-box {
    width: 100%;
    color: rgb(var(--color-text-primary));
    background: rgba(var(--color-accent-purple), 0.9);
    text-transform: uppercase;
    text-align: center;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
  }
  
  .item-notification-action-box p {
    font-size: 12px;
    padding: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
  }
  
  .item-notification-item-box {
    height: 11vh;
    width: 11vh;
  }
}

@layer components {
  /* Controls and dialog */
  .inventory-control {
    display: flex;
  }
  
  .inventory-control .inventory-control-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px var(--glass-shadow);
    animation: fadeIn 0.3s ease;
  }
  
  .inventory-control .inventory-control-input {
    transition: all 0.2s ease;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    text-align: center;
    outline: none;
    border: 1px solid var(--glass-border);
    color: rgb(var(--color-text-primary));
    background: rgba(var(--color-bg-secondary), 0.6);
    width: 180px;
  }
  
  .inventory-control .inventory-control-input:focus {
    background: rgba(var(--color-bg-secondary), 0.8);
    border-color: rgba(var(--color-accent-purple), 0.6);
    box-shadow: 0 0 0 2px rgba(var(--color-accent-purple), 0.2);
  }
  
  .inventory-control .inventory-control-button {
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: rgba(var(--color-accent-purple), 0.9);
    transition: all 0.2s ease;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    text-transform: uppercase;
    font-family: inherit;
    width: 100%;
    letter-spacing: 0.5px;
  }
  
  .inventory-control .inventory-control-button:hover {
    background: rgb(var(--color-accent-purple));
    box-shadow: 0 4px 12px rgba(var(--color-accent-purple), 0.3);
    transform: translateY(-2px);
  }
  
  .inventory-control .inventory-control-button:active {
    transform: translateY(1px);
  }
  
  .useful-controls-dialog {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgb(var(--color-text-primary));
    width: 480px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px var(--glass-shadow);
    gap: 16px;
    animation: scaleIn 0.3s ease;
  }
  
  .useful-controls-dialog-overlay {
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.2s ease;
  }
  
  .useful-controls-dialog-title {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    font-weight: 600;
  }
  
  .useful-controls-dialog-close {
    width: 32px;
    height: 32px;
    padding: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    fill: rgb(var(--color-text-primary));
    transition: all 0.2s ease;
  }
  
  .useful-controls-dialog-close:hover {
    background: rgba(var(--color-bg-tertiary), 0.8);
    cursor: pointer;
  }
  
  .useful-controls-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .divider {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
  }
  
  .useful-controls-button {
    position: absolute !important;
    bottom: 24px;
    right: 24px;
    transition: all 0.2s ease !important;
    border: none;
    color: white;
    width: 56px;
    height: 56px;
    display: flex;
    justify-content: center;
    align-items: center;
    fill: white;
    border-radius: 16px !important;
    background: rgba(var(--color-accent-purple), 0.9) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  }
  
  .useful-controls-button:hover {
    background: rgb(var(--color-accent-purple)) !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3) !important;
    cursor: pointer;
  }
  
  .useful-controls-exit-button {
    position: absolute !important;
    right: 12px;
    top: 12px;
    border-radius: 8px !important;
    color: rgba(var(--color-text-secondary), 0.8) !important;
  }
}

@layer components {
  /* Item drag */
  .item-drag-preview {
    width: 8vh;
    height: 8vh;
    z-index: 100;
    position: fixed;
    pointer-events: none;
    top: 0;
    left: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 7vh;
    image-rendering: -webkit-optimize-contrast;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    opacity: 0.9;
    border-radius: 12px;
    border: 2px solid rgba(var(--color-accent-purple), 0.6);
    background: rgba(var(--color-bg-secondary), 0.5);
  }
  
  /* Status bars */
  .durability-bar {
    background: rgba(0, 0, 0, 0.5);
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    margin: 4px 0;
  }
  
  .durability-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--durability, 50%);
    background: rgb(var(--color-accent-blue));
    border-radius: 2px;
  }
  
  .weight-bar {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.1);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin: 6px 0;
  }
  
  .weight-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--weight, 30%);
    background: rgb(var(--color-success));
    border-radius: 3px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes scaleIn {
  from { transform: translate(-50%, -50%) scale(0.95); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.transition-fade-enter {
  opacity: 0;
}

.transition-fade-enter-active {
  opacity: 1;
  transition: opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.transition-fade-exit {
  opacity: 1;
}

.transition-fade-exit-active {
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.transition-slide-up-enter {
  transform: translateY(20px);
  opacity: 0;
}

.transition-slide-up-enter-active {
  transform: translateY(0);
  opacity: 1;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.transition-slide-up-exit {
  transform: translateY(0);
  opacity: 1;
}

.transition-slide-up-exit-active {
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Animation delay utility classes */
.animation-delay-100 {
  animation-delay: 100ms;
}

.animation-delay-200 {
  animation-delay: 200ms;
}

.animation-delay-300 {
  animation-delay: 300ms;
}

/* Custom animation for notification entries */
@keyframes notificationSlideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.notification-animate-in {
  animation: notificationSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}