/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --frame-scale: 1;
    --frame-width: calc(200px * var(--frame-scale));
    --frame-height: calc(280px * var(--frame-scale));
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    line-height: 1.6;
}

/* Layout */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #2c3e50;
}

/* Disclaimer styling */
.disclaimer {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    text-align: center;
}

.disclaimer-text {
    margin: 0;
    font-size: 0.9rem;
    color: #856404;
    line-height: 1.4;
}

.disclaimer-text strong {
    color: #6c5502;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background: #95a5a6;
    color: white;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: #3498db;
}

.btn.success {
    background: #27ae60;
}

.btn.danger {
    background: #e74c3c;
}

.btn.secondary {
    background: #95a5a6;
}

.btn.secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

/* Camera Section */
.camera-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.camera-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    min-height: 300px;
    max-height: 80vh;
}

#video {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
    object-fit: contain;
}

/* Card Frame Overlay */
.card-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.frame-border {
    width: var(--frame-width);
    height: var(--frame-height);
    border: 3px solid #e74c3c;
    border-radius: 12px;
    background: rgba(231, 76, 60, 0.1);
    position: relative;
    transition: width 0.3s ease, height 0.3s ease;
}

.collector-area {
    position: absolute;
    left: 0;
    top: 92%;
    width: 30%;
    height: 8%;
    border: 2px dashed #f39c12;
    background: rgba(243, 156, 18, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(0.6rem * var(--frame-scale));
    color: #f39c12;
    font-weight: bold;
}

/* Frame Size Controls */
.frame-size-controls {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.frame-size-label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.frame-size-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.frame-size-slider {
    flex: 1;
    max-width: 300px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.frame-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.frame-size-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.size-label {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
}

/* Start Camera Controls (always visible) */
.start-camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Camera Operation Controls (visible only when camera is running) */
.camera-operation-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.upload-divider {
    color: #7f8c8d;
    font-style: italic;
    padding: 0 0.5rem;
    font-size: 0.9rem;
}

/* Scanner info display */
.scanner-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.method-badge {
    background: #3498db;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.8rem;
}

.language-note {
    color: #27ae60;
    font-style: italic;
    font-weight: 500;
}

/* Processing Section */
.processing-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.progress {
    width: 100%;
    height: 20px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-bar {
    height: 100%;
    background: #3498db;
    width: 0;
    transition: width 0.3s ease;
}

/* Debug Section */
.debug-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 2px dashed #95a5a6;
}

.debug-section h3 {
    color: #7f8c8d;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.debug-section .debug-images {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Collection Section */
.collection-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.collection-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collection-dropdown {
    padding: 0.5rem 1rem;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.collection-dropdown:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.collection-dropdown:hover {
    border-color: #bdc3c7;
}

.collection-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: flex-end;
}

.card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.card-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
}

.card-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card-item img {
    width: 100%;
    height: auto;
}

.card-item-info {
    padding: 1rem;
}

.card-item-info h5 {
    font-size: 1rem;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.card-item-info p {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
}

.card-item-actions {
    display: flex;
    gap: 0.5rem;
}

.card-item-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Quantity controls in collection */
.card-quantity-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.quantity-label {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 600;
}

.quantity-controls-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-btn-small {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.quantity-btn-small.increase {
    background: #28a745;
    color: white;
}

.quantity-btn-small.increase:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.quantity-btn-small.decrease {
    background: #dc3545;
    color: white;
}

.quantity-btn-small.decrease:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.quantity-display-inline {
    font-size: 1rem;
    font-weight: bold;
    color: #495057;
    min-width: 30px;
    text-align: center;
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app {
        padding: 0.5rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .result-card {
        flex-direction: column;
        text-align: center;
    }

    #resultImage {
        width: 200px;
    }

    .start-camera-controls,
    .camera-operation-controls,
    .result-actions,
    .collection-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .card-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    /* Mobile optimizations for card items */
    .card-item-info {
        padding: 0.75rem;
    }
    
    .card-item-info h5 {
        font-size: 0.9rem;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }
    
    .card-item-info p {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
    
    /* Better spacing for quantity section on mobile */
    .card-quantity-section {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem 0.5rem;
        margin-bottom: 1rem;
    }
    
    .quantity-label {
        font-size: 0.8rem;
        text-align: center;
        margin-bottom: 0.25rem;
    }
    
    .quantity-controls-inline {
        justify-content: center;
        gap: 0.75rem;
    }
    
    /* Larger touch-friendly quantity buttons */
    .quantity-btn-small {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .quantity-display-inline {
        min-width: 40px;
        font-size: 0.95rem;
        padding: 0.4rem 0.6rem;
    }
    
    /* Stack action buttons vertically or make them smaller */
    .card-item-actions {
        flex-direction: column;
        gap: 0.25rem;
        align-items: stretch;
    }
    
    .card-item-actions .btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
        text-align: center;
    }

    .frame-border {
        /* Mobile uses smaller base size, still scaled by CSS variable */
        --mobile-frame-width: calc(140px * var(--frame-scale));
        --mobile-frame-height: calc(196px * var(--frame-scale));
        width: var(--mobile-frame-width);
        height: var(--mobile-frame-height);
    }
}

/* Debug Elements */
.debug-text {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.debug-images {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.debug-images h5 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.debug-buttons {
    margin-bottom: 1rem;
}

.debug-image-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.debug-image-display h6 {
    font-size: 0.9rem;
    color: #495057;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.debug-image-display img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    display: block;
    margin: 0 auto 1rem auto;
    background: white;
}

/* Image loading states */
.card-item img[data-loading="true"] {
    background: #f0f0f0;
    position: relative;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-item img[data-loading="true"]:after {
    content: "Loading...";
    position: absolute;
    color: #666;
    font-size: 0.8rem;
    text-align: center;
}

#resultImage {
    transition: opacity 0.3s ease;
}

#resultImage[data-loading="true"] {
    opacity: 0.5;
    background: #f0f0f0;
}

/* Loading animation for result image */
#resultImage.loading {
    opacity: 0.5;
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.btn.small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.notification {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transform: translateX(450px);
    opacity: 0;
    transition: all 0.3s ease;
    border-left: 4px solid #3498db;
    position: relative;
    min-height: 60px;
}

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

.notification.hide {
    transform: translateX(450px);
    opacity: 0;
}

/* Notification Types */
.notification.success {
    border-left-color: #27ae60;
    background: #f8fff9;
}

.notification.error {
    border-left-color: #e74c3c;
    background: #fff8f8;
}

.notification.warning {
    border-left-color: #f39c12;
    background: #fffcf5;
}

.notification.info {
    border-left-color: #3498db;
    background: #f8fcff;
}

/* Notification Content */
.notification-icon {
    font-size: 1.2rem;
    line-height: 1;
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.notification.success .notification-icon {
    color: #27ae60;
}

.notification.error .notification-icon {
    color: #e74c3c;
}

.notification.warning .notification-icon {
    color: #f39c12;
}

.notification.info .notification-icon {
    color: #3498db;
}

.notification-content {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #2c3e50;
}

.notification-close {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    margin-left: 0.5rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.notification-close:hover {
    color: #2c3e50;
}

/* Mobile responsiveness for notifications */
@media (max-width: 768px) {
    .notification-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }

    .notification {
        transform: translateY(-100px);
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .notification.show {
        transform: translateY(0);
    }

    .notification.hide {
        transform: translateY(-100px);
    }
}

/* Card Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay:not([hidden]) .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 1.5rem;
}

.modal-card-display {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.modal-card-image {
    width: 150px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    transition: opacity 0.3s ease;
}

.modal-card-image.loading {
    opacity: 0.5;
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

.modal-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-card-set {
    color: #6c757d;
    font-style: italic;
    margin: 0;
    font-size: 0.95rem;
}

.quantity-section {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.quantity-section h4 {
    margin: 0 0 0.75rem 0;
    color: #495057;
    font-size: 1rem;
    font-weight: 600;
}

.previous-quantity-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
}

.previous-quantity-label {
    color: #6c757d;
    font-weight: 500;
}

.previous-quantity-value {
    color: #495057;
    font-weight: bold;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    min-width: 1.5rem;
    text-align: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.quantity-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
}

.quantity-btn:hover:not(:disabled) {
    border-color: #3498db;
    color: #3498db;
    transform: scale(1.05);
}

.quantity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.quantity-btn.increase {
    border-color: #27ae60;
    color: #27ae60;
}

.quantity-btn.increase:hover:not(:disabled) {
    background: #27ae60;
    color: white;
}

.quantity-btn.decrease {
    border-color: #e74c3c;
    color: #e74c3c;
}

.quantity-btn.decrease:hover:not(:disabled) {
    background: #e74c3c;
    color: white;
}

.quantity-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    min-width: 2rem;
    text-align: center;
    padding: 0.5rem;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.modal-footer .btn {
    min-width: 150px;
    font-weight: 600;
}

/* Mobile responsiveness for modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
        margin: 1rem;
    }

    .modal-card-display {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .modal-card-image {
        width: 200px;
    }

    .modal-card-info {
        width: 100%;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .quantity-controls {
        gap: 1.5rem;
    }

    .quantity-btn {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
    }

    .quantity-display {
        font-size: 1.8rem;
        min-width: 3rem;
        padding: 0.75rem;
    }

    .previous-quantity-info {
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        text-align: left;
    }

    .previous-quantity-value {
        align-self: center;
        min-width: 2rem;
        padding: 0.5rem;
    }
}

/* Hidden state overrides for camera elements */
#cameraContainer[hidden],
#cameraOperationControls[hidden],
#frameSizeControls[hidden],
.camera-container[hidden],
.camera-operation-controls[hidden],
.frame-size-controls[hidden] {
    display: none !important;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}

/* Footer Styles */
.app-footer {
    background: white;
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
}

.footer-text {
    font-size: 0.95rem;
    color: #495057;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.github-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.github-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

.footer-actions {
    margin: 1rem 0;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.footer-subtitle {
    font-size: 0.85rem;
    color: #6c757d;
    font-style: italic;
    margin: 0;
}

.footer-disclaimer {
    font-size: 0.8rem;
    color: #856404;
    background: #fff3cd;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin: 0.75rem 0;
    border: 1px solid #ffeaa7;
    line-height: 1.4;
}

.footer-legal {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.legal-link {
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s ease;
}

.legal-link:hover {
    color: #3498db;
    text-decoration: underline;
}

.separator {
    color: #adb5bd;
}

/* Mobile footer adjustments */
@media (max-width: 768px) {
    .app-footer {
        margin-top: 1.5rem;
        padding: 1rem;
    }
    
    .footer-text {
        font-size: 0.9rem;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .footer-subtitle {
        font-size: 0.8rem;
    }
    
    .footer-legal {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .disclaimer {
        margin-top: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
    
    .disclaimer-text {
        font-size: 0.8rem;
    }
    
    .footer-disclaimer {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
        margin: 0.5rem 0;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .card-list {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .card-item {
        min-height: 280px;
    }
    
    .card-item-info {
        padding: 0.5rem;
    }
    
    .card-item-info h5 {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
    
    .card-item-info p {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    /* Compact quantity section for very small screens */
    .card-quantity-section {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .quantity-label {
        font-size: 0.75rem;
    }
    
    .quantity-btn-small {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .quantity-display-inline {
        min-width: 35px;
        font-size: 0.9rem;
        padding: 0.3rem 0.5rem;
    }
    
    .card-item-actions .btn {
        padding: 0.5rem;
        font-size: 1rem; /* Keep emoji size readable */
    }
    
    /* Alternative: Single column for very small screens */
    .card-list.compact {
        grid-template-columns: 1fr;
    }
}

/* Legal Pages Styling */
.legal-page {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.legal-page h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #ecf0f1;
    font-size: 1.5rem;
}

.legal-page h3 {
    color: #34495e;
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.2rem;
}

.legal-page p {
    margin-bottom: 1rem;
    color: #555;
    line-height: 1.7;
}

.legal-page ul {
    margin: 1rem 0 1rem 2rem;
    color: #555;
}

.legal-page li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.legal-page a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.2s ease;
}

.legal-page a:hover {
    color: #2980b9;
    text-decoration: underline;
}

.legal-page section {
    margin-bottom: 2rem;
}

.legal-page section:last-child {
    margin-bottom: 0;
}

.last-updated {
    border-top: 1px solid #ecf0f1;
    padding-top: 1rem;
    margin-top: 2rem;
    font-style: italic;
    color: #6c757d;
    text-align: center;
}

.legal-nav {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    text-align: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile adjustments for legal pages */
@media (max-width: 768px) {
    .legal-page {
        padding: 1.5rem;
        margin: 0 0 1.5rem 0;
        border-radius: 4px;
    }
    
    .legal-page h2 {
        font-size: 1.3rem;
    }
    
    .legal-page h3 {
        font-size: 1.1rem;
    }
    
    .legal-nav {
        padding: 1rem;
        margin-bottom: 1.5rem;
        flex-direction: column;
    }
    
    .legal-nav .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
}

/* Foil Card Modal Effects */
.modal-content.foil {
    position: relative;
    background: linear-gradient(
        45deg,
        #ffffff 0%,
        #f8f9ff 15%,
        #fff0f5 30%,
        #f0fff0 45%,
        #fff8dc 60%,
        #f0f8ff 75%,
        #fdf5e6 90%,
        #ffffff 100%
    );
    background-size: 400% 400%;
    animation: foil-shimmer 8s ease-in-out infinite;
}

/* Remove the sweep effect to maintain scrollability */

.modal-content.foil .modal-header,
.modal-content.foil .modal-body,
.modal-content.foil .modal-footer {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(1px);
}

.modal-content.foil .modal-header {
    background: rgba(248, 249, 250, 0.95);
    border-bottom: 1px solid rgba(233, 236, 239, 0.8);
}

.modal-content.foil .modal-footer {
    background: rgba(248, 249, 250, 0.95);
    border-top: 1px solid rgba(233, 236, 239, 0.8);
}

.modal-content.foil .modal-card-image {
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(255, 215, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

/* Foil animation keyframes */
@keyframes foil-shimmer {
    0% {
        background-position: 0% 50%;
    }
    25% {
        background-position: 100% 25%;
    }
    50% {
        background-position: 100% 75%;
    }
    75% {
        background-position: 0% 100%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* foil-sweep animation removed to preserve modal scrollability */

/* Foil text effects */
.modal-content.foil .modal-header h3 {
    background: linear-gradient(
        45deg,
        #2c3e50 0%,
        #3498db 25%,
        #9b59b6 50%,
        #e74c3c 75%,
        #2c3e50 100%
    );
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: foil-text-shine 4s ease-in-out infinite;
    font-weight: 700;
}

@keyframes foil-text-shine {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Foil indicator badge */
.foil-indicator {
    display: inline-block;
    background: linear-gradient(
        45deg,
        #ffd700 0%,
        #ffb347 25%,
        #ff69b4 50%,
        #87ceeb 75%,
        #ffd700 100%
    );
    background-size: 200% 200%;
    color: #2c3e50;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 0.5rem;
    animation: foil-indicator-shine 3s ease-in-out infinite;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

@keyframes foil-indicator-shine {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modal-content.foil,
    .modal-content.foil .modal-header h3,
    .foil-indicator {
        animation: none;
    }
    
    .modal-content.foil {
        background: linear-gradient(
            135deg,
            #f8f9ff 0%,
            #fff0f5 50%,
            #f0fff0 100%
        );
    }
}

/* Foil Toggle Button */
.foil-toggle-section {
    margin: 1rem 0;
    text-align: center;
}

.foil-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    color: #495057;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.foil-toggle-btn:hover {
    border-color: #3498db;
    color: #3498db;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.foil-toggle-btn:active {
    transform: translateY(0);
}

.foil-toggle-btn.foil {
    background: linear-gradient(
        45deg,
        #ffd700 0%,
        #ffb347 25%,
        #ff69b4 50%,
        #87ceeb 75%,
        #ffd700 100%
    );
    background-size: 200% 200%;
    color: #2c3e50;
    border-color: #ffd700;
    animation: foil-button-shine 3s ease-in-out infinite;
    box-shadow: 
        0 2px 8px rgba(255, 215, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.foil-toggle-btn.foil:hover {
    border-color: #ffb347;
    transform: translateY(-2px);
    box-shadow: 
        0 6px 12px rgba(255, 215, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.foil-toggle-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.foil-toggle-btn:hover .foil-toggle-icon {
    transform: scale(1.2) rotate(15deg);
}

.foil-toggle-btn.foil .foil-toggle-icon {
    animation: foil-icon-sparkle 2s ease-in-out infinite;
}

@keyframes foil-button-shine {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes foil-icon-sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: scale(1.2) rotate(10deg);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.1) rotate(-5deg);
        opacity: 1;
    }
    75% {
        transform: scale(1.3) rotate(15deg);
        opacity: 0.9;
    }
}

/* Reduced motion for toggle button */
@media (prefers-reduced-motion: reduce) {
    .foil-toggle-btn.foil,
    .foil-toggle-btn.foil .foil-toggle-icon {
        animation: none;
    }
    
    .foil-toggle-btn.foil {
        background: linear-gradient(
            135deg,
            #ffd700 0%,
            #ffb347 50%,
            #ff69b4 100%
        );
    }
}

/* Collection Management Modal */
.collection-modal {
    max-width: 700px;
    width: 95%;
}

.collection-create-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #e9ecef;
}

.collection-create-section h4 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-group input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.input-group .btn {
    white-space: nowrap;
    padding: 0.75rem 1.5rem;
}

.collections-list-section h4 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.collections-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.collection-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.collection-item:hover {
    background: #e9ecef;
    border-color: #bdc3c7;
}

.collection-item.active {
    background: #e3f2fd;
    border-color: #3498db;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
}

.collection-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.collection-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    margin: 0;
    flex: 1;
}

.collection-active-badge {
    background: #27ae60;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
}

.collection-metadata {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #6c757d;
}

.collection-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.collection-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.collection-actions .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Mobile responsive collection modal */
@media (max-width: 768px) {
    .collection-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .collection-selector {
        width: 100%;
    }
    
    .collection-dropdown {
        width: 100%;
        min-width: auto;
    }
    
    .collection-metadata {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .collection-item-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .collection-active-badge {
        align-self: flex-start;
    }
    
    .collection-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .collection-actions .btn {
        text-align: center;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .input-group .btn {
        padding: 0.75rem 1rem;
    }
}
