/* CSS Variables for centralized card sizing */
:root {
    --card-width: 160px;
    --card-height: calc(var(--card-width) * 1.447);
    --card-min-width: min(var(--card-width), 30vw);
    --card-min-height: calc(var(--card-min-width) * 1.447);
}

/* Mobile Photo Button Styles */
.mobile-photo-btn {
    display: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.mobile-photo-btn.show {
    display: inline-flex !important;
}

.mobile-photo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mobile-photo-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mobile-photo-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-photo-btn:disabled:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-photo-btn i {
    margin-right: 6px;
    font-size: 16px;
}

.mobile-photo-text {
    display: inline;
    white-space: nowrap;
}

/* Mobile Photo Modal Styles */
.deck-photo-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1B1B1B;
    z-index: 10000;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}

.deck-photo-modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.deck-photo-content {
    background: #1B1B1B;
    border-radius: 12px;
    padding: 20px;
    width: 100vw;
    max-width: 100vw;
    overflow: visible;
    position: relative;
    box-sizing: border-box;
}

.deck-photo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    border-bottom: 2px solid #f0f0f0;
}

.deck-photo-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.deck-photo-close:hover {
    background-color: #f0f0f0;
}

.deck-photo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    background: #1B1B1B;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #1B1B1B;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
}

.deck-photo-card {
    width: 100%;
    aspect-ratio: 5 / 7;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none;
    position: relative;
    background: #f8f9fa;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    text-align: center;
}

.deck-photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.deck-photo-card.loaded {
    /* Optional: styles for when image is loaded */
}

/* Quantity counter overlay */
.deck-photo-card .quantity-counter {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.deck-photo-info {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 10px;
    border: 1px solid #e9ecef;
    font-size: 13px;
}

.card-name-fallback {
    padding: 8px;
    font-size: 10px;
    word-break: break-word;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deck-photo-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.deck-photo-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.deck-photo-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.deck-photo-btn.secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.deck-photo-btn.download {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.deck-photo-btn.copy {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

/* Show mobile photo button only on mobile */
@media (max-width: 768px) {
    .mobile-photo-btn {
        display: inline-flex;
        align-items: center;
    }

    .mobile-photo-text {
        display: inline;
    }

    .deck-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .mobile-photo-text {
        display: inline;
        margin-left: 5px;
    }

    .mobile-photo-btn {
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
    }

    .mobile-photo-btn i {
        margin-right: 0;
        font-size: 18px;
    }

    .deck-photo-modal {
        padding: 5px;
    }

    .deck-photo-grid {
        gap: 6px;
        padding: 6px;
    }

    .deck-photo-content {
        padding: 4px;
        margin: 2px;
        width: 100vw;
        max-width: 100vw;
    }

    .deck-photo-actions {
        gap: 8px;
    }

    .deck-photo-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .deck-photo-card .quantity-counter {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
}

/* Mobile optimization for photo modal */
@media (max-width: 768px) {
    .deck-photo-modal {
        padding: 5px;
    }

    .deck-photo-content {
        width: 100vw;
        max-width: 100vw;
        padding: 15px;
    }

    .branding-left {
        display: flex;
        align-items: left;
        gap: 12px;
        max-width: 40%;
    }
}

@media (max-width: 360px) {
    .deck-photo-grid {
        gap: 4px;
        padding: 4px;
    }

    .deck-photo-content {
        padding: 2px;
        margin: 1px;
        width: 100vw;
        max-width: 100vw;
    }

    .deck-photo-actions {
        flex-direction: column;
        gap: 6px;
    }

    .deck-photo-btn {
        width: 100%;
        justify-content: center;
    }

    .deck-photo-card .quantity-counter {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

/* Capture Container */
.deck-photo-capture-container {
    background: #1B1B1B;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
}

/* Branding Header */
.deck-photo-branding-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
    background-color: #1B1B1B;
    font-family: 'Inter', sans-serif;
}

.branding-left {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 60%;
}

.branding-logo {
    height: 12px;
    width: auto;
}

.branding-text {
    display: flex;
    flex-direction: column;
    font-size: 8px !important;
}

.branding-site {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: #e2e8f0;
}

.branding-deck-name {
    font-size: 8px !important;
    color: #a0aec0;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* QR Code */
.branding-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: auto;
}

.deck-photo-qr-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 40px;
    background: #1B1B1B;
}

/* Ensure QR code canvas/image fits exactly if library adds overflow */
.deck-photo-qr-container img,
.deck-photo-qr-container canvas {
    display: block;
}

/* Grid Override within capture container */
.deck-photo-capture-container .deck-photo-grid {
    margin-bottom: 0;
    padding: 0;
    border: none;
    background: #1B1B1B;
}

/* Ensure modal content handles the size */
.deck-photo-grid-wrapper {
    width: 100%;
    background: #1B1B1B;
}

/* Extra small screens - maximize card size */
@media (max-width: 320px) {
    .deck-photo-grid {
        gap: 4px;
        padding: 4px;
    }

    .deck-photo-content {
        padding: 1px;
        margin: 0px;
        width: 100vw;
        max-width: 100vw;
        background: #1B1B1B;
    }

    .deck-photo-card .quantity-counter {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
}

/* Responsive adjustments for the branding header */
@media (max-width: 480px) {
    .deck-photo-branding-header {
        flex-direction: row;
        align-items: center;
        background-color: #1B1B1B;
        gap: 10px;
    }

    .branding-right {
        width: auto;
        justify-content: flex-end;
    }

    .branding-deck-name {
        max-width: 200px;
    }
}