/* assets/css/deck-exporter.css */
/* Deck Builder - Right-side drawer matching left sidebar */

/* ===== Gallery Content + Drawer Layout ===== */
/* Ensure #item-gallery works in its initial state */
#item-gallery {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    padding: var(--space-4);
}

/* Only apply flex layout when deck drawer exists */
.app-gallery-area.has-deck-builder {
    display: flex !important;
    gap: 0 !important;
}

.gallery-content-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    display: block;
    position: relative;
    padding: var(--space-4);
}

/* Ensure item-gallery displays correctly inside wrapper */
.gallery-content-wrapper #item-gallery {
    display: grid !important;
    width: 100% !important;
    gap: var(--space-4) !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    padding: var(--space-4) !important;
    padding-bottom: var(--space-4) !important;
    margin: 0 !important;
}

/* Override for starter decks */
#item-gallery.starter-deck-cards-container {
    display: flex !important;
    flex-flow: row wrap !important;
    grid-template-columns: none !important;
}

/* Ensure empty message displays correctly */
.gallery-content-wrapper #empty-folder-message {
    display: block;
    width: 100%;
}

/* ===== Deck Drawer (Right Sidebar) ===== */
.deck-drawer {
    position: relative;
    width: 280px;
    flex-shrink: 0;
    background-color: var(--color-background-panel);
    padding: var(--space-4);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    border-left: 1px solid var(--color-border);
    transition: width 0.3s ease, padding-left 0.3s ease, padding-right 0.3s ease;
}

/* Fix input text colors in deck drawer */
.deck-drawer .filter-input,
.deck-drawer #deck-name-input {
    color: var(--color-text-primary, #f3f4f6) !important;
}

.deck-drawer .filter-input::placeholder,
.deck-drawer #deck-name-input::placeholder {
    color: var(--color-text-tertiary, #6b7280);
    opacity: 0.7;
}

.deck-drawer.collapsed {
    width: 10px;
    padding-left: 0;
    padding-right: 0;
    border-left: none;
    overflow: visible !important;
}

.deck-drawer .sidebar-content {
    transition: opacity 0.2s ease 0.1s, visibility 0s ease 0.3s;
    opacity: 1;
    visibility: visible;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.deck-drawer.collapsed .sidebar-content {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s ease 0.2s;
}

/* ===== Toggle Button (Matches Left Sidebar) ===== */
.deck-drawer-toggle.sidebar-toggle {
    position: absolute;
    top: 50%;
    left: -13px;
    transform: translateY(-50%);
    width: 26px;
    height: 52px;
    background-color: var(--color-accent, #facc15);
    color: var(--color-background, #0a101e);
    border: 1px solid var(--color-border, #374151);
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.deck-drawer-toggle.sidebar-toggle:hover {
    background-color: var(--color-accent-hover, #fbbf24);
    width: 28px;
}

.deck-drawer-toggle.sidebar-toggle i {
    transition: transform 0.2s ease;
}

/* ===== Card Count Display ===== */
.deck-count-display {
    background: rgba(var(--color-accent-rgb, 250, 204, 21), 0.1);
    border: 1px solid rgba(var(--color-accent-rgb, 250, 204, 21), 0.3);
    border-radius: 6px;
    padding: 0.5rem;
    text-align: center;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.deck-count-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent, #facc15);
    line-height: 1;
}

.deck-count-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary, #9ca3af);
    margin-top: 0.125rem;
}

.deck-count-status {
    font-size: 0.6875rem;
    color: var(--color-text-secondary, #9ca3af);
    margin-top: 0.375rem;
    font-style: italic;
}

/* Color-coded validation */
.deck-count-display.deck-count-red {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
}

.deck-count-display.deck-count-red .deck-count-number {
    color: #ef4444;
}

.deck-count-display.deck-count-red .deck-count-status {
    color: #ef4444;
    font-weight: 600;
    font-style: normal;
}

.deck-count-display.deck-count-orange {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.4);
}

.deck-count-display.deck-count-orange .deck-count-number {
    color: #f59e0b;
}

.deck-count-display.deck-count-orange .deck-count-status {
    color: #f59e0b;
    font-weight: 600;
    font-style: normal;
}

.deck-count-display.deck-count-green {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.4);
}

.deck-count-display.deck-count-green .deck-count-number {
    color: #10b981;
}

.deck-count-display.deck-count-green .deck-count-status {
    color: #10b981;
    font-weight: 600;
    font-style: normal;
}

/* ===== Deck List Wrapper ===== */
.deck-list-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ===== Deck List ===== */
.deck-list {
    flex: 1;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--color-border, #374151);
    border-radius: 6px;
    padding: 0.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.deck-list-drag-over {
    background-color: rgba(var(--color-accent-rgb, 250, 204, 21), 0.1);
    border-color: var(--color-accent, #facc15);
}

.deck-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 150px;
    color: var(--color-text-tertiary, #6b7280);
    text-align: center;
    font-size: 0.875rem;
}

.deck-empty-state p {
    margin: 0.25rem 0;
}

.deck-empty-state p:first-child {
    font-size: 2rem;
}

/* ===== Deck Card Item ===== */
.deck-card-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border, #374151);
    border-radius: 4px;
    margin-bottom: 0.375rem;
    transition: all 0.2s ease;
}

.deck-card-item:hover {
    background-color: rgba(0, 0, 0, 0.4);
    border-color: var(--color-accent, #facc15);
}

/* Card Preview Image */
.deck-card-preview {
    width: 36px;
    height: 50px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--color-border, #374151);
    flex-shrink: 0;
}

.deck-card-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.deck-card-qty-control {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 0.125rem;
}

.qty-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(var(--color-accent-rgb, 250, 204, 21), 0.2);
    color: var(--color-accent, #facc15);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.qty-btn:hover {
    background: rgba(var(--color-accent-rgb, 250, 204, 21), 0.3);
    transform: scale(1.1);
}

.deck-card-qty-input {
    width: 24px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-primary, #f3f4f6);
    -moz-appearance: textfield;
}

.deck-card-qty-input::-webkit-outer-spin-button,
.deck-card-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.deck-card-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1;
}

.deck-card-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-primary, #f3f4f6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deck-card-type {
    font-size: 0.6875rem;
    color: var(--color-text-tertiary, #6b7280);
}

.deck-card-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.deck-card-remove:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(1.1);
}

/* ===== Clear Deck Button ===== */
.deck-clear-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.deck-clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* ===== Export Button ===== */
.deck-export-btn {
    width: 100%;
    padding: 0.625rem;
    background: var(--color-accent, #facc15);
    color: var(--color-background, #0a101e);
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.deck-export-btn:hover:not(:disabled) {
    background: var(--color-accent-hover, #fbbf24);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.deck-export-btn:disabled {
    background: #6b7280;
    cursor: not-allowed;
    opacity: 0.5;
}

/* ===== Card "+" Button ===== */
.card-add-to-deck-btn {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    background: rgba(var(--color-accent-rgb, 250, 204, 21), 0.95);
    color: var(--color-background, #0a101e);
    border: 2px solid var(--color-background, #0a101e);
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.thumbnail:hover .card-add-to-deck-btn {
    opacity: 1;
}

.card-add-to-deck-btn:hover {
    background: var(--color-accent-hover, #fbbf24);
    transform: translateX(-50%) scale(1.15);
    box-shadow: 0 4px 12px rgba(250, 204, 21, 0.5);
}

.card-add-feedback {
    animation: addFeedback 0.3s ease;
}

@keyframes addFeedback {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.3); }
}

/* ===== Drag States ===== */
.thumbnail.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* ===== Notifications ===== */
.deck-notification {
    position: fixed;
    top: 100px;
    right: 20px;
    padding: 0.875rem 1.25rem;
    background: var(--color-background-panel, #1f2937);
    border: 1px solid var(--color-border, #374151);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
    max-width: 300px;
    color: var(--color-text-primary, #f3f4f6);
}

.deck-notification-show {
    opacity: 1;
    transform: translateX(0);
}

.deck-notification-success {
    border-left: 4px solid #10b981;
}

.deck-notification-error {
    border-left: 4px solid #ef4444;
}

.deck-notification-warning {
    border-left: 4px solid #f59e0b;
}

.deck-notification-info {
    border-left: 4px solid var(--color-accent, #facc15);
}

/* ===== Responsive ===== */
@media (max-width: 1400px) {
    .deck-drawer {
        width: 240px;
    }
}

@media (max-width: 1200px) {
    .deck-drawer {
        width: 220px;
    }
    
    .deck-card-name {
        font-size: 0.75rem;
    }
}

@media (max-width: 1023px) {
    .app-gallery-area {
        flex-direction: column;
    }
    
    .deck-drawer {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid var(--color-border);
        order: -1;
    }
    
    .deck-drawer-toggle {
        display: none;
    }
}
