/* Captcha Challenge Styles */
.captcha-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    position: relative;
    min-height: 100vh;
}

.captcha-instructions {
    margin-bottom: 30px;
    font-size: 18px;
    line-height: 1.4;
}

.captcha-instructions h2 {
    color: #333;
    margin-bottom: 10px;
}

.captcha-instructions p {
    color: #666;
    font-size: 16px;
}

.captcha-controls {
    margin-top: 20px;
    text-align: center;
    display: none;
}

.captcha-shuffle-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.captcha-shuffle-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.captcha-shuffle-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.captcha-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 30px 0;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.captcha-image {
    border: 3px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    background: #f8f9fa;
}

.captcha-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

/* Ensure images maintain size when absolutely positioned */
.captcha-image[style*="position: fixed"], .captcha-image[style*="position: absolute"] {
    width: 200px !important;
    height: 200px !important;
    position: fixed !important;
    z-index: 100 !important;
}

.captcha-image[style*="position: fixed"] img, .captcha-image[style*="position: absolute"] img {
    width: 200px !important;
    height: 200px !important;
    object-fit: cover;
}

.captcha-image:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

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

/* Disable hover effects after captcha is completed */
.captcha-completed .captcha-image:hover {
    border-color: #ddd;
    transform: none;
    box-shadow: none;
}

.captcha-completed .captcha-image:hover img {
    transform: none;
}

.captcha-image.selected {
    border-color: #28a745;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.4);
    transform: translateY(-2px);
}

.captcha-image.selected img {
    transform: scale(1.05);
}

.captcha-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.captcha-image:hover::after {
    opacity: 1;
}

.captcha-image.selected::after {
    background: rgba(40, 167, 69, 0.2);
    opacity: 1;
}

/* Combined author and pet name overlay */
.captcha-image div[id^="author_"] {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.5);
    color: black;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    line-height: 1.2;
    opacity: 0;
    transform: translateY(100%);
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

/* Show combined label when it has content */
.captcha-image div[id^="author_"]:not(:empty) {
    opacity: 1;
    transform: translateY(0);
}

/* Visual feedback for clicked images */
.captcha-image.captcha-checking::after {
    background: rgba(255, 255, 0, 0.3);
    opacity: 1;
}

.captcha-image.captcha-correct::after {
    background: rgba(40, 167, 69, 0.4);
    opacity: 1;
}

.captcha-image.captcha-incorrect::after {
    background: rgba(220, 53, 69, 0.4);
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .captcha-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .captcha-container {
        padding: 15px;
    }
    
    .captcha-instructions {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .captcha-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* Loading state */
.captcha-loading {
    opacity: 0.6;
    pointer-events: none;
}

.captcha-loading .captcha-image {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Result display */
.captcha-result {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    max-width: 400px;
    width: 90%;
    border-radius: 12px;
    animation: captchaResultSlideIn 0.3s ease-out;
}

@keyframes captchaResultSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Backdrop overlay for centered result */
.captcha-result::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    animation: captchaBackdropFadeIn 0.3s ease-out;
}

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

.captcha-success {
    color: #28a745;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

.captcha-error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

.captcha-loading {
    color: #007bff;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

/* Action buttons */
.captcha-actions {
    margin-top: 15px;
    text-align: center;
}

.captcha-continue-btn,
.captcha-try-again-btn {
    display: inline-block;
    padding: 10px 20px;
    margin: 0 10px;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.captcha-continue-btn {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.captcha-continue-btn:hover {
    background: #218838;
    border-color: #1e7e34;
    color: white;
    text-decoration: none;
}

.captcha-try-again-btn {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.captcha-try-again-btn:hover {
    background: #c82333;
    border-color: #bd2130;
    color: white;
    text-decoration: none;
}

/* Labels display */
.captcha-labels {
    margin-top: 30px;
    text-align: center;
}

.captcha-labels-content {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px auto;
    max-width: 800px;
}

.captcha-image-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    text-align: left;
}

.captcha-label {
    padding: 10px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.4;
}

.captcha-label strong {
    color: #495057;
    display: block;
    margin-bottom: 2px;
}

.captcha-label em {
    color: #6c757d;
    font-style: italic;
}

/* Responsive labels */
@media (max-width: 768px) {
    .captcha-image-labels {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .captcha-image-labels {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .captcha-label {
        font-size: 13px;
        padding: 8px;
    }
}
