/* =========================================================================
   deckManager/MTG/deckManager.css — everything about creating, editing and
   listing MTG decks: the Create Deck / Add to Deck dialog (photo, Enter
   List, analysis results, accuracy bars), the deck editor (#editDeck), the
   deck list (#deckList), verification icons, qty selectors, delete-deck
   dialog specifics, and the card image hover preview.
   The shared overlay/dialog/form/message system lives in core/base.css.
   ========================================================================= */

/* ---------- Create Deck dialog: views + image handling ---------- */
.instruction-text {
    text-align: center;
    margin-bottom: 20px;
    color: #4a5568;
}

.loading-subtext {
    font-size: 14px;
    color: #718096;
    margin-top: 8px;
}

.image-preview-container {
    margin: 16px 0;
    text-align: center;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

#imagePreview {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.image-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

.btn {
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
}

.image-preview-container img {
    transition: transform 0.3s ease;
    max-width: 100%;
}

/* Enter List — card list textarea */
.card-list-input {
    width: 100%;
    min-height: 220px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    line-height: 1.6;
    color: #1f2937;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.card-list-input:focus {
    border-color: #2563eb;
    outline: none;
}

/* ---------- Create Deck dialog: analysis results ---------- */
.results-container {
    margin: 16px 0;
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.results-container h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #1e40af;
    font-size: 18px;
}

.claude-response {
    white-space: pre-wrap;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}

.results-title {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
    color: #2d3748;
    font-size: 20px;
}

.stats-summary {
    background-color: #ebf8ff;
    border: 1px solid #bee3f8;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #2c5282;
}

/* ---------- Card analysis result cards ---------- */
.card-result {
    background-color: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.card-header {
    margin-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}

.card-name {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #1a365d;
    display: flex;
    justify-content: space-between;
}

.card-count {
    font-weight: normal;
    color: #4a5568;
    background-color: #e2e8f0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
}

.card-type {
    font-size: 14px;
    color: #4a5568;
    margin-top: 4px;
    font-style: italic;
}

.card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 14px;
}

.card-mana {
    font-weight: 500;
    padding: 2px 8px;
    background-color: #edf2f7;
    border-radius: 4px;
}

.card-color {
    color: #4a5568;
    padding: 2px 8px;
    border-radius: 4px;
}

.card-color:before {
    content: "•";
    margin-right: 4px;
}

.card-pt {
    font-weight: 500;
    padding: 2px 8px;
    background-color: #edf2f7;
    border-radius: 4px;
}

.card-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    white-space: pre-wrap;
    padding: 12px;
    background-color: #ffffff;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.mana-symbol {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background-color: #e2e8f0;
    border-radius: 50%;
    font-weight: bold;
    margin: 0 2px;
}

/* ---------- Accuracy bars ---------- */
.accuracy {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 6px;
}

.accuracy-high {
    background-color: rgba(72, 187, 120, 0.1);
}

.accuracy-medium {
    background-color: rgba(236, 201, 75, 0.1);
}

.accuracy-low {
    background-color: rgba(245, 101, 101, 0.1);
}

.accuracy-label {
    font-weight: 500;
    min-width: 85px;
}

.accuracy-bar {
    flex-grow: 1;
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.accuracy-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.accuracy-high .accuracy-fill {
    background-color: #48bb78;
}

.accuracy-medium .accuracy-fill {
    background-color: #ecc94b;
}

.accuracy-low .accuracy-fill {
    background-color: #f56565;
}

.accuracy-value {
    font-weight: 500;
    min-width: 40px;
    text-align: right;
}

.parsing-error {
    color: #e53e3e;
    padding: 12px;
    background-color: #fff5f5;
    border-radius: 4px;
    margin-bottom: 16px;
}

.parsing-error pre {
    white-space: pre-wrap;
    margin-top: 8px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
}

/* Additional color indicators */
/* NOTE: :contains() is NOT standard CSS — browsers ignore these rules.
   Kept for reference; the JS-added class workaround covers the one case
   that matters (.unknown-section-title). */
.card-color:contains("White") {
    background-color: #FFFCF9;
    border: 1px solid #E6E6E6;
}

.card-color:contains("Blue") {
    background-color: #E5F1FB;
    border: 1px solid #A9D2F7;
}

.card-color:contains("Black") {
    background-color: #E5E7EA;
    border: 1px solid #A9ACB0;
}

.card-color:contains("Red") {
    background-color: #FCEFEF;
    border: 1px solid #F5C4C4;
}

.card-color:contains("Green") {
    background-color: #EDF7ED;
    border: 1px solid #C3E6C3;
}

.card-color:contains("Gold") {
    background-color: #FFF8E1;
    border: 1px solid #FFECB3;
}

.card-color:contains("Multi") {
    background-color: #F5F0FF;
    border: 1px solid #D4C4F7;
}

.card-color:contains("Colorless") {
    background-color: #F5F5F5;
    border: 1px solid #E0E0E0;
}

/* Results container scroll styles */
.results-container {
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.results-container::-webkit-scrollbar {
    width: 6px;
}

.results-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.results-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.results-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.warning-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background-color: #FFF5F5;
    border: 1px solid #FED7D7;
    border-radius: 8px;
    margin-bottom: 16px;
}

.warning-icon {
    color: #E53E3E;
    flex-shrink: 0;
    margin-top: 2px;
}

.warning-message p {
    margin: 0;
    color: #822727;
    font-size: 15px;
    line-height: 1.5;
}

.details-toggle {
    text-align: center;
    margin: 16px 0;
}

/* ---------- Deck Editor ---------- */
#editDeck {
    background-color: #f5f5f5;
    padding: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
    margin-top: 40px;
}

#editDeckSave { display: none;}

#editDeckButtons {
    margin-bottom: 20px;
    padding-bottom: 10px;
    display: flex;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

#editDeckButtons > div {
    background-color: #2563eb;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
    transition: background-color 0.2s;
    float: left
}

.editDeckBtnHeader {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

#editDeckButtons > div:hover {
    background-color: #1d4ed8;
}

#editDeckDelete {
    background-color: #dc2626 !important;
}

#editDeckDelete:hover {
    background-color: #b91c1c !important;
}

#EditDeckContents {
    width: 100%;
}

.add-cards-btn {
    background-color: #2563eb;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
    transition: background-color 0.2s;
    float: right;
    margin-bottom: 5px;
}
.add-cards-btn:hover {
    background-color: #1d4ed8;
}

.edit-cards-btn {
    background-color: #2563eb;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
    transition: background-color 0.2s;
    float: left;
}

.edit-cards-btn:hover {
    background-color: #1d4ed8;
}

.edit-cards-btn.active {
    background-color: #dc2626;
}

.edit-cards-btn.active:hover {
    background-color: #b91c1c;
}

/* Cancel button styling */
#editDeckCancel {
    background-color: #dc2626 !important;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
    transition: background-color 0.2s;
    float: left;
    display: none;
}

#editDeckCancel:hover {
    background-color: #b91c1c !important;
}

.remove-cell {
    flex: 0.5;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #dc2626;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.edit-mode .remove-cell {
    opacity: 1;
}

.remove-cell:hover {
    color: #b91c1c;
    transform: scale(1.2);
}

/* Add class to the deck header and rows when in edit mode */
.deck-flex-container.edit-mode .deck-row {
    background-color: #fff5f5;
    transition: background-color 0.3s ease;
}

.deck-flex-container.edit-mode .deck-row:hover {
    background-color: #fed7d7;
}

/* Add some subtle styling for the Unknown cards section */
.unknown-card-row {
    background-color: #fafafa;
}

.unknown-card-row:hover {
    background-color: #f5f5f5;
}

/* Add a subtle indicator for the Unknown section */
/* (:contains() is non-standard — the JS-added class below is the real rule) */
.deck-section-title:contains("Unknown / Other") {
    color: #6b7280;
}

/* Add a bit more space before the Unknown section */
.deck-section:last-child {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed #d1d5db;
}

.unknown-section-title {
    color: #6b7280 !important;
}

.deck-section {
    margin-bottom: 24px;
}

.deck-section-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #111827;
    display: flex;
    align-items: center;
}

.deck-section-title .card-count {
    margin-left: 8px;
    font-size: 14px;
    color: #6b7280;
    font-weight: normal;
}

.deck-table {
    width: 100%;
    border-collapse: collapse;
}

.deck-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    color: #4b5563;
    font-size: 14px;
}

.deck-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #1f2937;
}

.card-row:hover {
    background-color: #f9fafb;
}

.card-quantity {
    text-align: center;
    width: 40px;
    font-weight: bold;
}

.card-name {
    font-weight: 500;
}

.mana-symbols {
    display: flex;
    align-items: center;
    gap: 3px;
}

.mana-symbol {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.mana-text {
    color: #000;
    background-color: #e5e7eb;
}

.mana-white {
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    color: #000;
}

.mana-blue {
    background-color: #3b82f6;
    color: white;
}

.mana-black {
    background-color: #1f2937;
    color: white;
}

.mana-red {
    background-color: #ef4444;
    color: white;
}

.mana-green {
    background-color: #10b981;
    color: white;
}

.power-toughness {
    white-space: nowrap;
    font-weight: 500;
}

.verified-check {
    color: #10b981;
    font-size: 16px;
    text-align: center;
}

.accuracy-rating {
    font-weight: 500;
}

.card-price {
    text-align: right;
    font-weight: 500;
}

/* Editable title styling */
.deck-title-container {
    padding: 0 0 10px 0;
    flex: 1;
}

.editable-title {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    width: 100%;
    max-width: 400px;
    padding: 4px 0;
    transition: all 0.2s ease;
    outline: none;
}

.editable-title:hover {
    color: #2563eb;
    border-bottom: 2px solid #e5e7eb;
    cursor: pointer;
}

.editable-title:focus {
    color: #2563eb;
    border-bottom: 2px solid #2563eb;
    cursor: text;
}

/* Style for the Join button */
.deck-join-button {
    background-color: #059669; /* Darker green color */
    color: white;
}

.deck-join-button:hover {
    background-color: #047857; /* Even darker on hover */
}

/* Adjust spacing between buttons */
.deck-action-button {
    margin-left: 6px;
    margin-right: 6px;
}

/* Make buttons more consistent in size */
.deck-actions-cell {
    display: flex;
    justify-content: flex-end;
    min-width: 220px; /* Ensure enough space for all three buttons */
}

/* Flex layout for deck editor */
.deck-flex-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.deck-header {
    display: flex;
    background-color: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    border-bottom: 2px solid #e5e7eb;
}

.deck-row {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
}

.deck-row:last-child {
    border-bottom: none;
}

.deck-row:hover {
    background-color: #f9fafb;
}

.deck-cell {
    padding: 10px 12px;
    display: flex;
    align-items: center;
}

/* Cell widths using flex */
.qty-cell {
    flex: 1;
    justify-content: center;
    font-weight: 500;
}

.name-cell {
    flex: 5;
    font-weight: 500;
}

.mana-cell {
    flex: 2;
}

.pt-cell, .verified-cell, .accuracy-cell, .rarity-cell, .price-cell {
    flex: 1;
}

.verified-cell {
    justify-content: center;
    color: #10b981;
}

.accuracy-cell {
    font-weight: 500;
}

.price-cell {
    justify-content: flex-end;
    font-weight: 500;
}

/* ---------- Verification status icons ---------- */
.verification-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-weight: bold;
    text-align: center;
}

.verification-success {
    color: #046c4e;
    background-color: rgba(4, 108, 78, 0.1);
}

.verification-warning {
    background-color: #f59e0b;
    color: white;
}

.verification-failed {
    background-color: #ef4444;
    color: white;
}

.verification-pending {
    background-color: #6b7280;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* ---------- Deck List ---------- */
#deckList {
    background-color: #f5f5f5;
    padding: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    margin-top: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
}

.deckListBtnHeader {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.deckListBtnHeader .deck-title-container {
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
}

#deckListContents {
    width: 100%;
}

.deck-list-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.deck-list-header {
    display: flex;
    background-color: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    border-bottom: 2px solid #e5e7eb;
}

.deck-list-row {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background-color 0.2s;
}

.deck-list-row:last-child {
    border-bottom: none;
}

.deck-list-row:hover {
    background-color: #f0f9ff;
}

.deck-list-cell {
    padding: 14px 16px;
    display: flex;
    align-items: center;
}

.deck-name-cell {
    flex: 5;
    font-weight: 500;
    color: #2563eb;
}

.deck-qty-cell {
    flex: 1;
    justify-content: center;
}

.deck-actions-cell {
    flex: 1;
    justify-content: flex-end;
}

.deck-action-button {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 8px;
}

.deck-edit-button {
    background-color: #e5e7eb;
    color: #374151;
}

.deck-edit-button:hover {
    background-color: #d1d5db;
}

.deck-play-button {
    background-color: #2563eb;
    color: white;
}

.deck-play-button:hover {
    background-color: #1d4ed8;
}

.create-deck-button {
    background-color: #10b981;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.create-deck-button:hover {
    background-color: #059669;
}

.create-deck-button svg {
    margin-right: 6px;
}

/* Empty state styling */
.empty-deck-list {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
}

.empty-deck-list h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: #4b5563;
}

.empty-deck-list p {
    margin-bottom: 24px;
}

/* Fix for editDeck and deckList scrolling */
#editDeck, #deckList {
    max-height: calc(100vh - 50px);
    overflow-y: auto;
    margin-bottom: 20px;
    position: relative;
    z-index: 10; /* Ensure it's above other elements */
}

/* Make sure the internal container also scrolls */
#EditDeckContents, #deckListContents {
    overflow-y: visible;
    padding-bottom: 30px; /* Add padding at the bottom for better UX */
}

/* Add custom scrollbar for better visibility */
#editDeck::-webkit-scrollbar,
#deckList::-webkit-scrollbar {
    width: 10px;
}

#editDeck::-webkit-scrollbar-track,
#deckList::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#editDeck::-webkit-scrollbar-thumb,
#deckList::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

#editDeck::-webkit-scrollbar-thumb:hover,
#deckList::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ensure that the edit buttons stay fixed at the top */
.editDeckBtnHeader, .deckListBtnHeader {
    position: sticky;
    top: 0;
    background-color: #f5f5f5;
    z-index: 15;
    padding: 10px 0;
}

/* ---------- Delete deck dialog ---------- */
.delete-button {
    background-color: #dc2626;
}

.delete-button:hover {
    background-color: #b91c1c;
}

.confirmation-message {
    text-align: center;
    margin: 20px 0;
    color: #4a5568;
    line-height: 1.5;
}

/* ---------- Card hover image preview ---------- */
.card-hover-image {
    position: fixed;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    pointer-events: none; /* Makes sure hover doesn't trigger on the image itself */
    display: none;
    width: 280px; /* Width of the card, based on standard Magic card dimensions */
    height: 390px; /* Height of the card */
    background-color: #f8f9fa;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    overflow: hidden;
    transition: opacity 0.15s ease;
    opacity: 0;
}

.card-hover-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card-hover-image.visible {
    display: block;
    opacity: 1;
}

/* Add cursor style to name cells to indicate they're interactive */
.name-cell {
    cursor: pointer;
}

/* ---------- Quantity selector (Edit Cards mode) ---------- */
.qty-select {
    color: #2563eb;
    background: none;
    border: none;
    width: 100%;
    text-align: center;
    font-size: inherit;
    font-weight: inherit;
    cursor: pointer;
}

.qty-buttons {
    display: inline-block;
    margin-left: 2px;
    vertical-align: middle;
}

.qty-button {
    border: none;
    background: none;
    color: #2563eb;
    padding: 0;
    cursor: pointer;
    font-size: 10px;
    line-height: 10px;
    display: block;
    width: 12px;
    height: 10px;
}

.qty-button.disabled {
    color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Make sure the buttons container has a fixed width */
.qty-buttons {
    width: 12px;
}
