body {
    background-color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border-radius: 10px;
    border: none;
}

.card-header {
    background-color: #f1f3f5;
    font-weight: 600;
    border-bottom: 1px solid rgba(0,0,0,0.125);
    padding: 15px 20px;
    border-radius: 10px 10px 0 0 !important;
}

.card-body {
    padding: 20px;
}

#result {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    background-color: white;
    border-left: 4px solid #0d6efd;
}

#loading {
    margin-top: 20px;
    text-align: center;
    padding: 20px;
}

/* History Section Styles */
#history {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

#history::-webkit-scrollbar {
    width: 6px;
}

#history::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#history::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

#history::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    transition: background-color 0.2s;
    border-radius: 8px;
    margin-bottom: 5px;
}

.history-item:hover {
    background-color: #f8f9fa;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item-content {
    display: flex;
    gap: 15px;
    align-items: center;
}

.history-image-container {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.history-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.history-thumbnail:hover {
    transform: scale(1.15);
}

.no-image {
    font-size: 0.75em;
    color: #6c757d;
    text-align: center;
    width: 100%;
    padding: 5px;
    font-style: italic;
}

.history-details {
    flex: 1;
    min-width: 0;
}

.history-details .age-range {
    font-weight: 700;
    color: #0d6efd;
    font-size: 1.1em;
    display: block;
    margin-bottom: 4px;
}

.history-details .timestamp {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 4px;
}

/* Confidence Badge Styles */
.confidence {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.confidence-high {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.confidence-medium {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.confidence-low {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Button Group */
.btn-group {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.btn-group .btn {
    flex: 1;
    border-radius: 8px !important;
    padding: 10px;
    font-weight: 500;
}

/* Camera and Preview Styles */
#cameraContainer {
    margin-top: 15px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #dee2e6;
}

#video {
    width: 100%;
    background-color: #000;
}

#previewContainer {
    margin-top: 15px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #dee2e6;
}

#preview {
    width: 100%;
    display: block;
}

/* Result Display Enhancement */
.result-details {
    margin-top: 10px;
}

.result-item {
    margin-bottom: 8px;
    padding: 5px 0;
}

.result-label {
    font-weight: 600;
    color: #495057;
    margin-right: 10px;
}

.result-value {
    color: #212529;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    border: 3px solid white;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 45px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.image-modal-close:hover {
    color: #ff4444;
    background-color: rgba(255,255,255,0.2);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #dee2e6;
}

/* History Actions */
.history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-delete {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 18px;
    cursor: pointer;
    padding: 0 5px;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-delete:hover {
    background-color: #dc3545;
    color: white;
    transform: scale(1.1);
}

.btn-delete i {
    font-size: 14px;
}

/* Clear All Button */
.clear-all-container {
    padding: 10px;
    text-align: right;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 10px;
}

.clear-all-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-all-btn:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

.clear-all-btn i {
    margin-right: 5px;
}

/* Reasoning Text */
.reasoning-text {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 4px;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Small Text */
.small-text {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 2px;
}

/* Delete Animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Camera Error Styles */
.camera-error {
    font-size: 0.9rem;
    padding: 12px;
}

.camera-error ul {
    padding-left: 20px;
    margin-bottom: 10px;
}

.camera-error li {
    margin-bottom: 5px;
}

/* Mobile Camera Styles */
@media (max-width: 768px) {
    .history-item-content {
        gap: 10px;
    }
    
    .history-image-container {
        width: 50px;
        height: 50px;
    }
    
    .history-details .age-range {
        font-size: 1em;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .image-modal-close {
        top: 10px;
        right: 20px;
        font-size: 35px;
    }
    
    #startCamera, #capturePhoto {
        width: 100%;
        margin-bottom: 10px;
        padding: 12px;
        font-size: 1rem;
    }
    
    #cameraContainer {
        margin: 10px 0;
    }
    
    #video {
        width: 100%;
        height: auto;
        border-radius: 8px;
    }
    
    .btn-group .btn {
        width: 100%;
        margin: 0;
    }
}

/* Animation for loading */
@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

#loading .spinner-border {
    animation: spinner-border 0.75s linear infinite;
}

#loading p {
    margin-top: 10px;
    color: #0d6efd;
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Success Animation for Result */
@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#result {
    animation: slideIn 0.3s ease-out;
}