/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0);
    backdrop-filter: blur(0px);
    transition: background-color 0.3s ease;
}

.modal.show {
    background-color: rgba(0,0,0,0.8);
    /* Blur-Effekt entfernt für bessere Performance */
}

.modal-content {
    background: #2d2d2d;
    margin: 4% auto;
    padding: 0;
    border-radius: 16px;
    width: 92%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: translateY(-30px) scale(0.98);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.modal.show .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a1a;
}

.modal-header h2 {
    margin: 0;
    color: #ffffff;
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background: #404040;
    color: #ffffff;
}

.modal-body {
    padding: 30px;
    max-height: calc(85vh - 100px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.item-gallery {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

/* Modal Search Section */
.modal-search-section {
    margin-bottom: 30px;
}

.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-container input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    background: #404040;
    border: 2px solid #555;
    border-radius: 10px;
    color: #ffffff;
    font-size: 16px;
    transition: all 0.2s ease;
}

.search-container input:focus {
    outline: none;
    border-color: #667eea;
    background: #4a4a4a;
}

.search-container .search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
}

.search-filters {
    display: flex;
    gap: 15px;
}

.search-filters select {
    padding: 10px 15px;
    background: #404040;
    border: 1px solid #555;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    min-width: 150px;
}

.search-filters select:focus {
    outline: none;
    border-color: #667eea;
}

/* Item Gallery */
.item-gallery {
    margin-bottom: 30px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.gallery-item {
    background: #1a1a1a;
    border: 2px solid #404040;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    opacity: 1;
    transform: translateY(0);
}

.gallery-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.gallery-item.selected {
    border-color: #667eea;
    background: #2a2a4a;
}

.gallery-item-image {
    width: 100%;
    height: 120px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 8px;
}

.gallery-item-name {
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 5px;
    font-size: 0.9rem;
    line-height: 1.3;
}

.gallery-item-type {
    color: #999;
    font-size: 0.8rem;
    margin-bottom: 3px;
}

.gallery-item-rarity {
    color: #666;
    font-size: 0.75rem;
}

.gallery-loading {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.load-more-btn {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
}

.load-more-btn button {
    padding: 12px 24px;
    font-size: 0.9rem;
}

/* Selected Item Form */
.selected-item-form {
    background: #1a1a1a;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 25px;
    margin-top: 20px;
    opacity: 1;
    transform: translateY(0);
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
}

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

.selected-item-info {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #404040;
}

.selected-item-info img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    background: #404040;
}

.selected-item-details h3 {
    color: #ffffff;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.selected-item-details p {
    color: #999;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.investment-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .investment-form .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .selected-item-info {
        flex-direction: column;
        text-align: center;
    }
}

/* Gallery Item Animation removed for better performance */

/* Sell Modal Styles */
#sellItemModal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(0px);
    transition: background-color 0.3s ease;
}

#sellItemModal.show {
    background-color: rgba(0,0,0,0.8);
}

#sellItemModal .modal-content {
    background: #2d2d2d;
    margin: 6% auto;
    padding: 0;
    border-radius: 12px;
    width: 92%;
    max-width: 520px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: translateY(-30px) scale(0.98);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#sellItemModal.show .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.sell-item-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #1e1e1e;
    border-radius: 8px;
    border: 1px solid #404040;
}

.sell-item-info.compact {
    margin-bottom: 12px;
    padding: 10px 12px;
}

.sell-item-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    background: #404040;
}

.sell-item-details h3 {
    color: #ffffff;
    margin-bottom: 4px;
    font-size: 1rem;
    line-height: 1.2;
}

.sell-item-details p {
    color: #999;
    margin-bottom: 0;
    font-size: 0.8rem;
}

.current-value, .purchase-value {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.current-value .label, .purchase-value .label {
    color: #ccc;
    font-weight: 500;
}

.sell-form {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #404040;
}

#sellItemModal .modal-body {
    padding: 14px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.sell-form.sell-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
    align-items: start;
}

.sell-form.sell-grid .form-group {
    margin-bottom: 0;
    min-width: 0;
}

.sell-form.sell-grid .fee-calculator,
.sell-form.sell-grid .form-actions {
    grid-column: 1 / -1;
}

.qty-input-row {
    display: grid;
    grid-template-columns: 1fr 56px;
    gap: 8px;
}
.sell-form .form-group label {
    display: block;
    color: #cfcfcf;
    font-size: 0.85rem;
    margin-bottom: 6px;
    font-weight: 500;
}

#sellItemModal .sell-form input,
#sellItemModal .sell-form select {
    height: 36px;
    padding: 6px 10px;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
    font-variant-numeric: tabular-nums;
}

.btn-ghost {
    background: transparent;
    border: 1px solid #555;
    color: #ddd;
}

.btn-ghost:hover {
    background: #3a3a3a;
}

.fee-calculator.compact .fee-item {
    padding: 6px 0;
}

@media (max-width: 640px) {
    .sell-form.sell-grid {
        grid-template-columns: 1fr;
    }
}

.fee-calculator {
    background: #2a2a2a;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 8px 0 10px 0;
    border: 1px solid #404040;
}

.fee-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding: 2px 0;
    color: #ffffff;
}

.fee-item span {
    color: #ffffff;
}

.fee-item.total { border-top: 1px solid #404040; padding-top: 8px; margin-top: 8px; font-weight: 600; color: #fff; }

.fee-item.profit { font-weight: 700; font-size: 1rem; border-top: 1px dashed #404040; padding-top: 8px; margin-top: 8px; }

.fee-item.total { background: transparent; }

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 6px;
}

#sellItemModal .btn { height: 40px; }
#sellItemModal .btn-ghost { height: 36px; }

/* Slightly smaller typography inside the sell modal for a denser layout */
#sellItemModal .modal-content {
    font-size: 0.95rem;
}

#sellItemModal .modal-header h2 {
    font-size: 1.25rem;
}

#sellItemModal .sell-form .form-group label {
    font-size: 0.8rem;
}

#sellItemModal .sell-form input,
#sellItemModal .sell-form select {
    font-size: 0.85rem;
}

#sellItemModal .fee-item {
    font-size: 0.9rem;
}

#sellItemModal .fee-item.profit {
    font-size: 0.95rem;
}

/* Condition Dropdown Styles */
.gallery-item-condition {
    color: #666;
    font-size: 0.75rem;
    margin-top: 4px;
}

.gallery-item.has-conditions {
    border-color: #667eea;
    position: relative;
}

.condition-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.condition-dropdown {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2d2d2d;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 0;
    z-index: 3000;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.8);
}

.condition-dropdown-header {
    background: #667eea;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 10px 10px 0 0;
}

.condition-dropdown-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.close-dropdown {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-dropdown:hover {
    background-color: rgba(255,255,255,0.2);
}

.condition-options {
    padding: 10px 0;
}

.condition-option {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #404040;
}

.condition-option:hover {
    background-color: #404040;
}

.condition-option:last-child {
    border-bottom: none;
}

.condition-name {
    font-weight: 500;
    color: #fff;
    text-align: center;
}

/* Stabilize number input spinners to avoid layout jitter */
#sellItemModal .sell-form input[type="number"]::-webkit-outer-spin-button,
#sellItemModal .sell-form input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#sellItemModal .sell-form input[type="number"] { -moz-appearance: textfield; }
