.deck-viewer {
  max-width: 1800px; /* wider to fit preview */
  display: flex;
  gap: 20px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-color, #333);
  background: var(--background-color, transparent);
  padding: 12px;
  border-radius: 6px;
}

/* LIST VIEW */

.deck-list {
  flex: 1;
}

.deck-card {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color, #ddd);
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

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

.deck-card:hover {
  background-color: var(--hover-bg, #f0f0f0);
}

.deck-card.selected {
  background-color: var(--accent-bg, #dbefff);
}

.card-count {
  min-width: 30px;
    max-width: 70px;
  transition: background-color 0.3s ease;

  font-weight: 600;
  color: var(--accent-color, #666);
  margin-right: 2px;
  flex-shrink: 0;
}

.card-count-invalid {
  background-color: #ffe5e5; /* light red */
}

.card-name {
  flex-grow: 1;
  font-size: 1rem;
  color: var(--text-color, #333);
  transition: color 0.2s ease;
}

.deck-card.selected .card-name {
  color: var(--accent-color, #0073aa);
}

/* Card preview container */
#card-preview {
  flex-shrink: 0;
  width: 220px;
  background: var(--preview-bg, #fff);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  user-select: none;
}

#card-preview.show {
  display: block;
}

#card-preview img {
  display: block;
  max-width: 100%;
  border-radius: 4px;
  user-select: none;
  pointer-events: none;
}

/* GRID VIEW */

.deck-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.deck-card-grid {
  position: relative;
  cursor: default;
  user-select: none;
  display: inline-block; /* shrink-wrap */
  line-height: 0;
}

.deck-card-grid img {
  width: 150px;
  height: auto;
  display: block;          /* remove whitespace below img */
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
}

.card-count-overlay {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 10px;
  user-select: none;
  pointer-events: none;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
}
/* Inputs in deck-card-row */
.deck-card-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.card-count {
    max-width: 18px;
    padding: 6px 8px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.card-name {
    flex-grow: 1;
    min-width: 150px;
    padding: 6px 8px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Remove card button */
.remove-card {
    background: #e74c3c;
    border: none;
    color: white;
    font-size: 18px;
    padding: 0 10px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.2s ease;
}

.remove-card:hover {
    background: #c0392b;
}



/* Invalid card input highlight */
.invalid-card {
    border: 2px solid #e74c3c !important;
    background-color: #ffecec;
}

/* Autocomplete styles */
.ui-autocomplete {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: visible;       /* allow horizontal expansion */
    background: #fff;
    border: 1px solid #ccc;
    z-index: 9999 !important;
    font-family: Arial, sans-serif;
    font-size: 14px;
    padding: 0;
    margin-top: 2px;

    min-width: 200px;          /* minimum width */
    width: auto !important;    /* override 100% width */
    white-space: nowrap;       /* no wrapping */
    display: inline-block;     /* shrink-wrap content */
    box-sizing: border-box;    /* include padding/border in width */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Individual autocomplete item */
.autocomplete-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-img {
    height: 50px;
    width: auto;
    margin-right: 10px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.autocomplete-label {
    font-weight: 500;
    color: #333;
}

.ui-menu-item-wrapper.ui-state-active,
.autocomplete-item:hover {
    background-color: #fff0f0;
}

/* Search panel container */
#card-search-panel {
    width: 300px;
    background: #f9faff;
    border-right: 1px solid #ccc;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    max-height: 650px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    color: #222;
    transition: transform 0.3s ease;
}

/* Inputs and button inside search panel */
#card-search-panel input,
#card-search-panel select,
#card-search-panel button {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px 10px;
    font-size: 15px;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

#card-search-panel input:focus,
#card-search-panel select:focus,
#card-search-panel button:focus {
    border-color: #2a7ae2;
    outline: none;
}

#card-search-panel button#search-cards {
    background-color: #2a7ae2;
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#card-search-panel button#search-cards:hover {
    background-color: #1d5bbf;
}

/* Search results list */
#card-search-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#card-search-panel li {
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 14px;
    word-break: break-word;
}

#card-search-panel li:hover {
    background: #e6f0ff;
}

/* Search result text spans */
#card-search-panel li span {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 6px;
    white-space: normal;
    color: #222;
}

/* Add card button inside search result */
#card-search-panel li button.add-card-to-deck {
    flex: 0 0 auto;
    background: #2a7ae2;
    border: none;
    color: white;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

#card-search-panel li button.add-card-to-deck:hover {
    background-color: #1d5bbf;
}

/* Hover image next to search results */
.hover-img {
    position: absolute;
    right: -160px;
    top: 0;
    width: 150px;
    z-index: 10;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

/* Deck content main area */
#deck-content {
    flex: 1;
      padding: 8px;

}

/* Toggle button for search panel (mobile) */
#toggle-search-panel {
    display: none;
    position: fixed;
    top: 50px;
    left: 12px;
    background: #2a7ae2;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    z-index: 1001;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Responsive and toggle behavior */
@media (max-width: 900px) {
    #deck-manager-container {
        flex-direction: column;
    }
    #card-search-panel {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        max-height: none;
        width: 280px;
        background: #f9faff;
        box-shadow: 2px 0 8px rgba(0,0,0,0.15);
        padding: 20px 15px;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    #card-search-panel.active {
        transform: translateX(0);
    }
    #deck-content {
        padding-left: 15px;
        margin-top: 60px; /* space for toggle button */
    }
    #toggle-search-panel {
        display: block;
    }
}

/* Container and form */
#deck-content {
  flex: 1;
  padding-left: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  color: #222;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.07);
  min-width: 320px;
  max-width: 600px;
}

#new-deck-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Deck name input */
#new-deck-form input[name="deck_name"] {
  font-size: 1.2rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1.5px solid #ccc;
  transition: border-color 0.25s ease;
  box-sizing: border-box;
  width: 100%;
}

#new-deck-form input[name="deck_name"]:focus {
  outline: none;
  border-color: #2a7ae2;
  box-shadow: 0 0 6px rgba(42, 122, 226, 0.4);
  padding: 8px 8px;

}

/* Deck card editor container */
#deck-card-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafafa;
  border: 1px solid #ddd;
  padding: 12px 16px;
  border-radius: 8px;
  max-height: 960px;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Deck card row (reuse and extend your styles) */
.deck-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: white;
  border-radius: 6px;
  border: 1px solid #ccc;
  transition: border-color 0.3s ease;
}

.deck-card-row:hover {
  border-color: #2a7ae2;
}

/* Card count input */
.card-count-view {
  width: 60px;
  padding: 8px 10px;
  font-size: 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  text-align: center;
  transition: border-color 0.25s ease;
}

.card-count:focus {
  outline: none;
  border-color: #2a7ae2;
  box-shadow: 0 0 5px rgba(42, 122, 226, 0.4);
}

/* Card name input */
.card-name-view {
  flex-grow: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  transition: border-color 0.25s ease;
}

.card-name:focus {
  outline: none;
  border-color: #2a7ae2;
  box-shadow: 0 0 5px rgba(42, 122, 226, 0.4);
}

/* Remove card button */
.remove-card {
  background-color: #e74c3c;
  border: none;
  color: white;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.remove-card:hover {
  background-color: #c0392b;
}

/* Deck textarea */
#deck-textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px 16px;
  font-family: monospace, monospace;
  font-size: 14px;
  border-radius: 8px;
  border: 1.5px solid #ccc;
  box-sizing: border-box;
  resize: vertical;
  transition: border-color 0.25s ease;
}

#deck-textarea:focus {
  outline: none;
  border-color: #2a7ae2;
  box-shadow: 0 0 6px rgba(42, 122, 226, 0.4);
}

/* Buttons inside deck content */
#toggle-deck-text,
#add-card,
#new-deck-form > button[type="submit"] {
  background-color: #2a7ae2;
  border: none;
  color: white;
  padding: 12px 18px;
  font-size: 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.25s ease;
  user-select: none;
  align-self: flex-start;
}

#toggle-deck-text:hover,
#add-card:hover,
#new-deck-form > button[type="submit"]:hover {
  background-color: #1d5bbf;
}

/* Disabled state */
#new-deck-form > button[type="submit"]:disabled {
  background-color: #a0b8f9;
  cursor: not-allowed;
}

/* Scrollbar styling for deck-card-editor (optional) */
#deck-card-editor::-webkit-scrollbar {
  width: 8px;
}

#deck-card-editor::-webkit-scrollbar-thumb {
  background-color: rgba(42, 122, 226, 0.3);
  border-radius: 4px;
}

#deck-card-editor::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.deck-stats-chart-container {
  max-width: 1800px;   /* max width for desktop */
  width: 100%;        /* full width responsive */
  margin: 20px auto;
  height: auto;
}
.deck-stats-chart-container canvas {
  width: 100% !important;
  height: 300px !important; /* fixed height, adjust as needed */
}
@media (max-width: 480px) {
  .deck-stats-chart-container canvas {
    height: 250px !important; /* smaller height on mobile */
  }
}

/* User Deck List Styles */

#user-deck-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 1800px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  border-radius: 8px;
  background: var(--background-color, #fff);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.07);
  overflow: hidden;
}

#user-deck-list .deck-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color, #ddd);
  transition: background-color 0.2s ease;
  user-select: none;
}

#user-deck-list .deck-item:last-child {
  border-bottom: none;
}

#user-deck-list .deck-item:hover {
  background-color: var(--hover-bg, #f0f8ff);
}

.deck-link {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-color, #222);
  text-decoration: none;
  flex-grow: 1;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-link:hover,
.deck-link:focus {
  color: var(--accent-color, #2a7ae2);
  outline: none;
  text-decoration: underline;
}

.deck-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.deck-actions .btn {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
  color: white;
  background-color: var(--accent-color, #2a7ae2);
  box-shadow: 0 2px 6px rgb(42 122 226 / 0.3);
}

.deck-actions .btn.edit-deck {
  background-color: var(--accent-color, #2a7ae2);
}

.deck-actions .btn.edit-deck:hover,
.deck-actions .btn.edit-deck:focus {
  background-color: #1d5bbf;
  outline: none;
}

.deck-actions .btn.delete-deck {
  background-color: #e74c3c;
  box-shadow: 0 2px 6px rgb(231 76 60 / 0.3);
}

.deck-actions .btn.delete-deck:hover,
.deck-actions .btn.delete-deck:focus {
  background-color: #c0392b;
  outline: none;
}

/* Style for edit and delete buttons in deck list */
#user-deck-list button.edit-deck,
#user-deck-list button.delete-deck {
  all: unset; /* Reset inherited styles */
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background-color: #2a7ae2;
  border: 1.5px solid #2a7ae2;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  user-select: none;
  margin-left: 8px;
  display: inline-block;
  line-height: 1.2;
  min-width: 60px;
  text-align: center;
}

#user-deck-list button.edit-deck:hover,
#user-deck-list button.delete-deck:hover {
  background-color: #1d5bbf;
  border-color: #1d5bbf;
}

/* Optional: Differentiate delete button color */
#user-deck-list button.delete-deck {
  background-color: #e74c3c;
  border-color: #e74c3c;
}

#user-deck-list button.delete-deck:hover {
  background-color: #c0392b;
  border-color: #c0392b;
}

.deck-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.deck-header-actions a {
  text-decoration: none;
  padding: 6px 12px;
  background: #eee;
  border-radius: 6px;
  color: #333;
  font-weight: 500;
}

#deck-summary {
  padding: 0.5em 1em;
  border-radius: 0.5em;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.deck-under {
  background-color: #ffe5e5; /* light red */
}

.deck-exact {
  background-color: #e5ffe5; /* light green */
}

.deck-over {
  background-color: #ffffe0; /* light yellow */
}

#card-preview {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: white;
  border: 2px solid #444;
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: none;
  max-width: 90vw;
}

#card-preview.visible {
  display: block;
   width:150%;
    max-width: 80vw;
}

#card-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

#close-preview {
  position: absolute;
  top: 0;
  right: 0;
  background: #000000;
  color: white;
  border: none;
  border-radius: 0 6px 0 6px;
  font-size: 1.2rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

@media (min-width: 768px) {
   #card-preview {
    position: fixed;       /* Fix it relative to viewport */
    top: 50%;             /* Move to vertical center */
    left: auto;           /* Keep current horizontal position */
    right: 1rem;          /* For example, keep it near the right edge or wherever it is now */
    transform: translateY(-50%); /* Center vertically */
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid #444;
    padding: 0.5rem;
    background: white;
    display: none;
    width: 300px !important;  

  }

  
  
  
}

@media (min-width: 768px) {
  .deck-list {
    /* Adjust this value based on the width of #card-preview */
    margin-right: 320px; /* leave space for preview image on right */
    /* or you can use max-width if you prefer:
    max-width: calc(100% - 320px);
    */
  }


}

