.cards-component {
    display: grid;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.cards-auto {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.cards-center-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 400px));
    justify-content: center;
    max-width: 900px;
}

.cards-2x2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 800px;
}

.cards-3x2 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
}

.cards-2x3 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 800px;
}

.card {
    background: var(--color-bg-primary);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: 0;
    cursor: pointer;
    transition: all var(--transition-cubic);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
}

.card:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.card-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.card:hover .card-image img {
    transform: scale(1.05);
}

.card-expand-btn {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-cubic);
    z-index: 2;
    font-size: 16px;
    line-height: 1;
}

.card-image:hover .card-expand-btn,
.card-expand-btn:focus {
    opacity: 1;
}

.card-expand-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.card-expand-btn:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.expand-icon {
    font-size: 14px;
    font-weight: bold;
}

.card-content {
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
    line-height: 1.3;
    text-align: center;
}

.card-text {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    text-align: center;
    flex: 1;
}

.card-selection-indicator {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-bg-primary);
    border: 2px solid var(--color-border-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-cubic);
    opacity: 0.7;
}

.selection-icon {
    font-size: 16px;
    font-weight: bold;
    color: var(--color-success);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card.selected {
    border-color: var(--color-success);
    background: var(--gradient-success-subtle);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card.selected .card-selection-indicator {
    background: var(--color-success);
    border-color: var(--color-success);
    opacity: 1;
}

.card.selected .selection-icon {
    opacity: 1;
    color: white;
}

.card.selected .card-title {
    color: var(--color-success-darker);
    font-weight: 700;
}

@media (max-width: 1024px) {
    .cards-3x2 {
        grid-template-columns: repeat(2, 1fr);
        max-width: 800px;
    }

    .cards-component {
        gap: var(--spacing-md);
        padding: var(--spacing-md);
    }
}

@media (max-width: 768px) {
    .cards-component {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
        padding: var(--spacing-sm);
    }

    .cards-2x2,
    .cards-3x2,
    .cards-2x3,
    .cards-center-2 {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .card {
        min-height: 160px;
    }

    .card-image {
        height: 100px;
    }

    .card-content {
        padding: var(--spacing-md);
    }

    .card-title {
        font-size: 16px;
    }

    .card-text {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .cards-component {
        padding: var(--spacing-xs);
        gap: var(--spacing-sm);
    }

    .card {
        min-height: 140px;
    }

    .card-image {
        height: 80px;
    }

    .card-selection-indicator {
        width: 28px;
        height: 28px;
        top: var(--spacing-sm);
        right: var(--spacing-sm);
    }

    .selection-icon {
        font-size: 14px;
    }
}

.dark-mode .card {
    background: var(--color-bg-tertiary);
    border-color: var(--color-border-medium);
    box-shadow: var(--shadow-md);
}

.dark-mode .card:hover {
    box-shadow: var(--shadow-xl);
    border-color: var(--color-primary);
}

.dark-mode .card-image {
    background: var(--color-bg-secondary);
}

.dark-mode .card-selection-indicator {
    background: var(--color-bg-tertiary);
    border-color: var(--color-border-dark);
}

.dark-mode .card.selected {
    background: var(--gradient-success);
    border-color: var(--color-success);
}

.dark-mode .card.selected .card-title {
    color: var(--color-text-light);
}

.dark-mode .card.selected .card-text {
    color: var(--color-text-light);
    opacity: 0.9;
}

@media (prefers-color-scheme: dark) {
    html:not(.dark-mode) .card {
        background: var(--color-bg-tertiary);
        border-color: var(--color-border-medium);
        box-shadow: var(--shadow-md);
    }

    html:not(.dark-mode) .card:hover {
        box-shadow: var(--shadow-xl);
        border-color: var(--color-primary);
    }

    html:not(.dark-mode) .card-image {
        background: var(--color-bg-secondary);
    }

    html:not(.dark-mode) .card-selection-indicator {
        background: var(--color-bg-tertiary);
        border-color: var(--color-border-dark);
    }

    html:not(.dark-mode) .card.selected {
        background: var(--gradient-success);
        border-color: var(--color-success);
    }

    html:not(.dark-mode) .card.selected .card-title {
        color: var(--color-text-light);
    }

    html:not(.dark-mode) .card.selected .card-text {
        color: var(--color-text-light);
        opacity: 0.9;
    }
}

@media (prefers-contrast: high) {
    .card {
        border-width: 3px;
    }

    .card.selected {
        border-width: 4px;
    }

    .card-selection-indicator {
        border-width: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card,
    .card-image img,
    .card-selection-indicator,
    .selection-icon {
        transition: none;
    }

    .card:hover {
        transform: none;
    }

    .card:hover .card-image img {
        transform: none;
    }
}

.card:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

@media print {
    .cards-component {
        display: block;
    }

    .card {
        break-inside: avoid;
        margin-bottom: var(--spacing-lg);
        box-shadow: none;
        border: 2px solid var(--color-border-dark);
    }

    .card-selection-indicator,
    .card-expand-btn,
    .card-image-modal {
        display: none;
    }
}

.card-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn var(--transition-slow) ease-out;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    transition: all var(--transition-base);
    z-index: 2;
}

.modal-close:hover {
    background: white;
    transform: scale(1.1);
}

.modal-close:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.modal-image {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-title {
    margin-top: var(--spacing-lg);
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .card-image-modal .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }

    .card-image-modal .modal-close {
        top: -40px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .card-image-modal .modal-image {
        max-height: calc(95vh - 50px);
    }

    .card-image-modal .modal-title {
        font-size: 16px;
        margin-top: var(--spacing-md);
    }
}

@media (prefers-reduced-motion: reduce) {
    .card-image-modal {
        animation: none;
    }

    @keyframes modalFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}