:root {
    --primary-color: #1a73e8;
    --secondary-color: #5f6368;
    --success-color: #1e8e3e;
    --danger-color: #d93025;
    --warning-color: #f9ab00;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --hover-background: #f1f3f4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-text {
    text-align: left;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

header p {
    color: var(--text-secondary);
    margin: 0;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.language-selector label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.language-selector select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.language-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.phase {
    background-color: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--hover-background);
    border-radius: 4px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.criteria-counter {
    text-align: center;
    margin-bottom: 2rem;
}

.criteria-counter h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.criteria-counter span {
    color: var(--primary-color);
    font-size: 2rem;
}

.question-card {
    background-color: var(--hover-background);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.question-card h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.question-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.option-btn {
    flex: 1;
    min-width: 120px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    background-color: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.option-btn:hover {
    border-color: var(--primary-color);
    background-color: var(--hover-background);
}

.option-btn.selected {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    color: white;
}

.navigation {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1557b0;
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--hover-background);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #0d652d;
}

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

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.test-info {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
}

.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--surface);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background-color: var(--hover-background);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.criteria-list {
    max-height: 600px;
    overflow-y: auto;
    margin-bottom: 2rem;
}

.criterion-item {
    background-color: var(--hover-background);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.criterion-item.pass {
    border-color: var(--success-color);
}

.criterion-item.fail {
    border-color: var(--danger-color);
}

.criterion-item.na {
    border-color: var(--warning-color);
}

.criterion-item.selected {
    border-color: var(--primary-color);
    background-color: #e8f0fe;
    cursor: pointer;
}

.criterion-item:hover {
    cursor: pointer;
    background-color: #e8f0fe;
}

.selected-indicator {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
    margin-left: 0.5rem;
}

.criterion-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.criterion-id {
    font-weight: bold;
    color: var(--primary-color);
}

.criterion-level {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.level-A {
    background-color: #e8f0fe;
    color: #1967d2;
}

.level-AA {
    background-color: #fce8e6;
    color: #c5221f;
}

.criterion-description {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.criterion-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.status-btn:hover {
    background-color: var(--hover-background);
}

.status-btn.active.pass {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.status-btn.active.fail {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.status-btn.active.na {
    background-color: var(--warning-color);
    color: white;
    border-color: var(--warning-color);
}

.test-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.saved-results {
    margin-top: 2rem;
    background-color: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.saved-test-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--hover-background);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.saved-test-info {
    flex: 1;
}

.saved-test-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.saved-test-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.saved-test-actions {
    display: flex;
    gap: 0.5rem;
}

.saved-test-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.removed-criteria-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.removed-criteria-section h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.removed-criteria-section #removedCount {
    font-weight: normal;
    color: var(--text-secondary);
}

.removed-list {
    margin-top: 1rem;
}

.criterion-item.removed {
    background-color: #f5f5f5;
    border-color: #ddd;
}

.criterion-item.removed .criterion-description {
    color: var(--text-secondary);
    opacity: 0.7;
}

.criterion-item.removed h4 {
    opacity: 0.7;
}

.criterion-item.removed .criterion-id,
.criterion-item.removed .criterion-level {
    opacity: 0.7;
}

/* Keep the Add Back button fully visible and active */
.criterion-item.removed .add-back-btn {
    opacity: 1 !important;
}

.add-back-btn {
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    outline: none;
}

.add-back-btn:hover {
    background-color: #1557b0 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(26, 115, 232, 0.3);
}

.add-back-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(26, 115, 232, 0.3);
}

.skip-info {
    background-color: #fef7e0;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #5f6368;
}

/* Screenshot functionality */
.screenshot-section {
    margin: 1rem 0;
}

.screenshot-drop-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background-color: var(--hover-background);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screenshot-drop-area:hover {
    border-color: var(--primary-color);
    background-color: #e8f0fe;
}

.screenshot-drop-area.dragover {
    border-color: var(--primary-color);
    background-color: #e8f0fe;
    transform: scale(1.02);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.drop-icon {
    font-size: 2rem;
    opacity: 0.7;
}

.drop-text {
    font-weight: 500;
    color: var(--text-primary);
}

.drop-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.screenshot-preview {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    max-width: 300px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.screenshot-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.screenshot-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.screenshot-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.screenshot-preview:hover .screenshot-overlay {
    opacity: 1;
}

.screenshot-preview.removed {
    opacity: 0.6;
    cursor: default;
}

.screenshot-preview.removed:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.screenshot-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.screenshot-gallery .screenshot-preview {
    max-width: 200px;
    flex: 0 0 auto;
}

.screenshot-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.screenshot-preview:hover .screenshot-delete {
    display: flex;
}

.screenshot-delete:hover {
    background: #dc3545;
    transform: scale(1.1);
}

/* Lightbox for screenshot annotation */
.screenshot-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
}

.lightbox-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    /* Don't let header grow too much */
    flex-shrink: 0;
    min-height: 60px;
}

.lightbox-title {
    font-weight: 500;
    margin: 0;
}

.lightbox-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 4px;
}

.lightbox-close:hover {
    background: var(--hover-background);
}

.lightbox-toolbar {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 1.5rem;
    align-items: center;
    background: #fafafa;
    /* Keep toolbar compact */
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 70px;
}

.annotation-tool {
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.125rem;
    min-width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.annotation-tool:hover {
    background: var(--hover-background);
}

.annotation-tool.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.color-picker {
    display: flex;
    gap: 0.5rem;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text-primary);
}

.color-red { background-color: #d93025; }
.color-orange { background-color: #f9ab00; }
.color-blue { background-color: #1a73e8; }

.lightbox-canvas-container {
    position: relative;
    flex: 1;
    overflow: auto;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    min-height: 300px;
    /* Ensure space for buttons by limiting max height */
    max-height: calc(100vh - 220px);
}

.lightbox-canvas {
    cursor: crosshair;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border-radius: 4px;
}

.lightbox-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    background: var(--surface);
    /* Always keep buttons visible */
    flex-shrink: 0;
    min-height: 60px;
}

@media (max-width: 768px) {
    .screenshot-drop-area {
        padding: 1rem;
        min-height: 80px;
    }
    
    .drop-content {
        gap: 0.25rem;
    }
    
    .drop-icon {
        font-size: 1.5rem;
    }
    
    .screenshot-preview {
        max-width: 100%;
    }
    
    .screenshot-gallery {
        flex-direction: column;
    }
    
    .screenshot-gallery .screenshot-preview {
        max-width: 100%;
    }
    
    .lightbox-content {
        max-width: 98vw;
        max-height: 98vh;
        width: 95vw;
        height: 95vh;
    }
    
    .lightbox-canvas-container {
        min-height: 250px;
        max-height: calc(100vh - 300px);
        padding: 0.5rem;
    }
    
    .lightbox-header {
        padding: 0.75rem 1rem;
        min-height: 50px;
    }
    
    .lightbox-toolbar {
        padding: 0.75rem 1rem;
        gap: 1rem;
        min-height: 60px;
    }
    
    .lightbox-actions {
        padding: 0.75rem 1rem;
        min-height: 50px;
        /* Stack buttons on very small screens */
        flex-wrap: wrap;
    }
    
    .lightbox-actions .btn {
        min-width: 80px;
    }
    
    .lightbox-toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .lightbox-actions {
        flex-direction: column;
    }
    
    .lightbox-actions .btn {
        width: 100%;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .phase {
        padding: 1rem;
    }
    
    .navigation {
        flex-direction: column;
    }
    
    .navigation button {
        width: 100%;
    }
    
    .test-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .test-actions {
        flex-direction: column;
    }
    
    .test-actions .btn {
        width: 100%;
    }
}

@media (max-height: 600px) {
    /* Special handling for very short screens */
    .lightbox-content {
        height: 98vh;
        max-height: 98vh;
    }
    
    .lightbox-canvas-container {
        min-height: 200px;
        max-height: calc(100vh - 250px);
    }
    
    .lightbox-header,
    .lightbox-toolbar,
    .lightbox-actions {
        padding: 0.5rem 1rem;
    }
    
    .lightbox-header {
        min-height: 45px;
    }
    
    .lightbox-toolbar {
        min-height: 50px;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .lightbox-actions {
        min-height: 45px;
        flex-wrap: wrap;
    }
    
    .lightbox-actions .btn {
        min-width: 70px;
        padding: 0.5rem 1rem;
    }
}