body {
    padding-top: 2rem;
    padding-bottom: 2rem;
    background-color: #f7f7f7;
}

#results-container .card .image {
    background-color: #eee;
}

#results-container .card .image img {
    object-fit: cover;
    width: 100%;
    height: auto;
}

.card .meta .label {
    margin-top: 5px !important;
}

#filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

#filter-controls .field {
    margin-bottom: 0 !important;
}

.card-item .card-name,
.card-item .card-source {
    /* Allow text to wrap and break */
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* To prevent layout shifts, give it a consistent height */
    line-height: 1.2em;
    width: 100%; /* Ensure it takes full width of the card item */
}

.card-item .card-name {
    font-weight: bold;
    margin-top: 5px;
    text-align: center;
    min-height: 2.4em; /* ~2 lines for name */
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-item .card-source {
    font-size: 0.8em;
    color: #666;
    text-align: center;
    margin-top: 2px;
}

/* New styles for card sources display */
.card-sources {
    margin-top: 5px;
    text-align: center;
    max-width: 100%;
}

.card-source-line {
    font-size: 0.75em;
    color: #888;
    line-height: 1.2;
    margin: 1px 0;
    padding: 1px 3px;
    background-color: #f8f9fa;
    border-radius: 3px;
    border-left: 3px solid #007bff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    box-sizing: border-box;
}

.card-source-line:nth-child(odd) {
    border-left-color: #28a745;
}

.card-source-line:nth-child(3n) {
    border-left-color: #ffc107;
}

.card-source-line:nth-child(4n) {
    border-left-color: #dc3545;
}

.card-image-container {
    position: relative;
    width: 100%;
}

.card-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #db2828; /* Semantic UI red */
    color: white;
    font-size: 12px;
    font-weight: bold;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border: 1px solid white;
}

/* New limit styling with glowing borders (box-shadow) */
.card-item.limit-forbidden {
    box-shadow: 0 0 8px 3px rgba(219, 40, 40, 0.7); /* Red glow */
}
.card-item.limit-limited {
    box-shadow: 0 0 8px 3px rgba(251, 189, 8, 0.7); /* Gold/Yellow glow */
}
.card-item.limit-semi-limited {
    box-shadow: 0 0 8px 3px rgba(33, 133, 208, 0.7); /* Bright Blue glow */
}

/* Font scaling and text truncation for smaller cards */
.ui.cards > .card > .content {
    /* Enforce a minimum height to help with alignment */
    min-height: 6.5em;
}

.ui.seven.cards > .card .header,
.ui.six.cards > .card .header {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.3em !important;
}

.ui.seven.cards > .card .meta,
.ui.six.cards > .card .meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ui.seven.cards > .card .header {
    font-size: 0.8em !important; /* smaller */
}

.ui.seven.cards > .card .meta {
    font-size: 0.75em !important; /* smaller */
}

.ui.six.cards > .card .header {
    font-size: 0.85em !important; /* smaller */
}

.ui.six.cards > .card .meta {
    font-size: 0.8em !important; /* smaller */
}

/* Simplified Popover Styles for Text-Only View */
.tippy-box[data-theme~='light-border'] .tippy-content {
    padding: 1em; /* Add back padding */
}

.card-popover-text-only {
    max-width: 350px; /* Adjust as needed */
    text-align: left;
}

.card-popover-text-only h4 {
    margin-top: 0;
    font-size: 1.1em;
}

.card-popover-text-only .ui.divider {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.card-popover-text-only .popover-desc-scroll {
    max-height: 250px; /* Adjust max-height as needed */
    overflow-y: auto;
    font-size: 0.95em;
    white-space: pre-wrap;
    padding-right: 5px; /* For scrollbar */
}

/* Optional: Keep the scrollbar styling or remove it for default look */
.popover-desc-scroll::-webkit-scrollbar {
    width: 5px;
}
.popover-desc-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.popover-desc-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.popover-desc-scroll::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.set-tag {
    display: inline-block;
}

#results-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding-top: 15px;
}

.card-item {
    width: 150px; /* Adjust width as needed */
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: box-shadow 0.2s;
    position: relative; /* Needed for feedback positioning */
    cursor: pointer; /* Indicate it's clickable */
    min-height: 200px; /* Increased to accommodate source display */
}

.copy-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    opacity: 1;
    white-space: nowrap;
    width: fit-content;
    min-width: 0;
    display: inline-block;
    transition: opacity 0.3s ease-out;
    pointer-events: none; /* Prevent it from blocking clicks */
    white-space: nowrap;
    width: fit-content;
    min-width: 0;
    display: inline-block;
}

.card-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card-item .card-image-container img {
    max-width: 100%;
    border-radius: 4px;
}

/* Responsive adjustments for card sources based on card size */
.seven-cards-per-row .card-source-line {
    font-size: 0.65em;
}

.six-cards-per-row .card-source-line {
    font-size: 0.68em;
}

.five-cards-per-row .card-source-line {
    font-size: 0.7em;
}

.four-cards-per-row .card-source-line {
    font-size: 0.75em;
}

.three-cards-per-row .card-source-line {
    font-size: 0.8em;
}

/* Responsive adjustments for card names based on card size */
.seven-cards-per-row .card-name {
    font-size: 0.85em;
}

.six-cards-per-row .card-name {
    font-size: 0.9em;
}

.five-cards-per-row .card-name {
    font-size: 1em;
}

.four-cards-per-row .card-name {
    font-size: 1.1em;
}

.three-cards-per-row .card-name {
    font-size: 1.2em;
}

/* Card Sizing Helpers */
.seven-cards-per-row .card-item { width: calc(100% / 7 - 16px); }
.six-cards-per-row .card-item { width: calc(100% / 6 - 16px); }
.five-cards-per-row .card-item { width: calc(100% / 5 - 16px); }
.four-cards-per-row .card-item { width: calc(100% / 4 - 16px); }
.three-cards-per-row .card-item { width: calc(100% / 3 - 16px); }

/*
  This forces the file selection button and its pointing hint label
  to stack vertically, with appropriate spacing.
*/
.field .icon.button {
    display: block;
    margin-bottom: 0.5em;
}

.field .pointing.label {
    display: block;
    width: fit-content; /* Prevent the label from stretching to full width */
}

/* Reduce vertical padding on the upload segment to make it more compact */
#upload-segment {
    padding-top: 0.5rem !important;
    padding-bottom: 1rem !important;
}

/* Remove extra spacing from the YDK file list */
#ydk-file-list .ui.list {
    margin-top: 5px !important; /* Keep a small gap from the input */
    margin-bottom: 0 !important;
    padding-left: 0 !important;
}

/* Local folder browser styles */
.local-folder-section {
    margin-top: 1rem;
}

#local-folder-tree {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #d4d4d5;
    border-radius: 4px;
    padding: 0.5rem;
}

#local-folder-tree .item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

#local-folder-tree .item:last-child {
    border-bottom: none;
}

#local-folder-tree .header {
    font-weight: bold;
    margin-bottom: 0.2rem;
}

#local-folder-tree .description {
    color: #666;
    font-size: 0.9rem;
}

.local-resource-status .item {
    padding: 0.2rem 0 !important;
}

.local-resource-status .header {
    font-size: 0.9rem !important;
    margin-bottom: 0.2rem !important;
}

.local-resource-status .description {
    font-size: 0.8rem !important;
}

/* Deck selector styling */
#deck-selector {
    margin-bottom: 0.5rem;
}

#deck-selector .menu .item {
    padding: 0.7rem 1rem !important;
}

#deck-selector .menu .item i {
    margin-right: 0.5rem;
}

/* Tab content spacing */
.ui.tab.segment {
    margin-top: 0 !important;
    border-top: none !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

/* Modal styling */
#recommend-local-folder-modal .content .list .item {
    margin-bottom: 1rem;
}

#recommend-local-folder-modal .content .list .item .header {
    font-weight: bold;
    margin-bottom: 0.3rem;
}

/* Deck filter styling */
#deck-filter-container {
    margin-bottom: 1rem;
}

#deck-filter-container .ui.segment {
    margin-bottom: 0;
}

#deck-filter-container .ui.header {
    margin-bottom: 1rem;
}

#result-deck-filter .menu .item {
    padding: 0.7rem 1rem !important;
}

#result-deck-filter .menu .item i {
    margin-right: 0.5rem;
    color: #999;
}

/* Responsive design for deck filter */
@media (max-width: 768px) {
    #result-deck-filter .menu .item {
        padding: 0.5rem 0.8rem !important;
        font-size: 0.9rem;
    }
}

/* Support Author Button Styles */
.support-author-btn {
    position: relative;
    transition: all 0.3s ease;
}

.support-author-btn.clickable {
    animation: heartbeat 2s infinite;
    box-shadow: 0 0 15px rgba(0, 181, 173, 0.5) !important;
}

.support-author-btn.clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(0, 181, 173, 0.8) !important;
}

.support-author-btn.cooldown {
    opacity: 0.6;
    cursor: not-allowed;
    animation: none;
    box-shadow: none !important;
}

.support-author-btn.cooldown:hover {
    transform: none;
}

.support-author-btn .cooldown-timer {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.1);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(1);
    }
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .support-author-btn {
        font-size: 0.9rem;
        padding: 0.5rem 0.8rem;
    }
}
