/* Mobile-first CSS for bee validation interface */

:root {
    /* Light mode colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9f9f9;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
}

body.dark-mode {
    /* Dark mode colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #aaaaaa;
    --border-color: #444444;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    padding: 10px;
    touch-action: manipulation; /* Prevent zoom on double-tap */
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: background-color 0.3s ease;
}

/* Header */
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* User bar (below header) */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 8px;
}

.user-bar #user-info {
    color: var(--text-secondary);
    font-weight: 500;
}

.user-bar #user-info.trusted {
    color: #4CAF50;
}

.user-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-actions a {
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.user-actions button {
    padding: 6px 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.user-actions button:hover {
    background: #d32f2f;
}

/* Tutorial button */
.tutorial-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    text-align: center;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
    transition: all 0.2s;
}

.tutorial-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

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

header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin: 0;
    transition: color 0.3s ease;
}

/* Filter select dropdown */
.filter-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 140px;
}

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

.filter-select:focus {
    outline: 2px solid #9C27B0;
    outline-offset: 2px;
}

.dark-mode-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 20px;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
    background: var(--border-color);
}

.dark-mode-toggle:active {
    transform: scale(0.95);
}

/* Session stats */
.session-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

@media (max-width: 480px) {
    .session-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-item {
    text-align: center;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-item.mite-count {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border-color: #388E3C;
}

body.dark-mode .stat-item.mite-count {
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
}

.stat-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.stat-item.mite-count .stat-label {
    color: rgba(255, 255, 255, 0.9);
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.stat-item.mite-count .stat-value {
    color: white;
    font-size: 24px;
}

/* Break notification */
.break-notification {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 0.4s ease-out;
    box-shadow: 0 3px 10px rgba(255, 152, 0, 0.3);
}

.dismiss-break-btn {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.dismiss-break-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.dismiss-break-btn:active {
    transform: scale(0.95);
}

/* Progress bar */
.progress-bar {
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
    transition: background-color 0.3s ease;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s ease;
    width: 0%;
}

#progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

/* Crop display */
#crop-container {
    text-align: center;
    margin: 20px 0;
    min-height: 200px;
}

#image-wrapper {
    position: relative;
    display: inline-block;
    cursor: zoom-in;
    overflow: visible;
}

#image-wrapper.zoomed {
    cursor: zoom-out;
}

#crop-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow-strong);
    max-height: 50vh;
    object-fit: contain;
    transition: transform 0.3s ease, max-height 0.3s ease, box-shadow 0.3s ease;
    transform-origin: center center;
    background: white; /* Keep crops on white background for consistency */
}

#image-wrapper.zoomed #crop-image {
    max-height: 80vh;
    z-index: 100;
}

/* Zoom indicator badge */
.zoom-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: none;
    z-index: 101;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease-in;
}

/* Filter indicator badge */
.filter-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(156, 39, 176, 0.85);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 101;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease-in;
}

/* Image enhancement filters (CSS only - does not modify original images) */
.crop-filter-none {
    filter: none;
}

.crop-filter-contrast {
    filter: contrast(1.5) brightness(1.1);
}

.crop-filter-brown-boost {
    filter: sepia(0.3) saturate(1.4) contrast(1.3);
}

.crop-filter-edge {
    filter: contrast(2) grayscale(0.5) brightness(1.2);
}

.crop-filter-sharpen {
    filter: contrast(1.3) brightness(1.05) saturate(1.2);
}

#crop-info {
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.6;
    transition: color 0.3s ease;
}

.predicted-class {
    font-size: 16px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    background: #e3f2fd;
    color: #1976d2;
}

body.dark-mode .predicted-class {
    background: #1e3a5f;
    color: #64b5f6;
}

.help-text {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
    font-style: italic;
    transition: color 0.3s ease;
}

/* Button grid */
#button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.class-btn {
    padding: 20px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.class-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

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

/* Action buttons container */
#action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* Undo button container */
#undo-container {
    margin-bottom: 20px;
}

.undo-btn {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, #9C27B0 0%, #7B1FA2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(156, 39, 176, 0.3);
}

.undo-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.undo-btn:active:not(:disabled) {
    transform: translateY(0);
}

.undo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #9E9E9E;
    box-shadow: none;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    animation: toastSlideUp 0.3s ease-out;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Skip button */
.secondary-btn {
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    background: #9E9E9E;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.secondary-btn:active {
    transform: scale(0.98);
}

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

/* Invalid button */
.invalid-btn {
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.invalid-btn:active {
    transform: scale(0.98);
}

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

/* Stats section */
#stats-section {
    margin-top: 20px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

summary {
    cursor: pointer;
    font-weight: bold;
    padding: 10px;
    user-select: none;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

details[open] summary::before {
    transform: rotate(90deg);
}

#stats {
    padding: 10px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

#stats p {
    padding: 5px 10px;
    font-size: 14px;
    margin: 5px 0;
}

#class-dist {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#class-dist p {
    margin: 3px 0;
}

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

/* Overlay */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.overlay-content {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 80%;
    transition: background-color 0.3s ease;
}

#overlay-message {
    font-size: 16px;
    color: var(--text-primary);
    transition: color 0.3s ease;
    white-space: pre-line;
    line-height: 1.6;
}

/* Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

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

/* Touch feedback */
.class-btn:active::after,
.secondary-btn:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    to {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    #app {
        padding: 15px;
    }

    header h1 {
        font-size: 20px;
    }

    .class-btn {
        font-size: 16px;
        padding: 15px;
        min-height: 70px;
    }

    #crop-image {
        max-height: 40vh;
    }
}

/* Landscape mode */
@media (orientation: landscape) and (max-height: 600px) {
    #crop-image {
        max-height: 30vh;
    }

    .class-btn {
        min-height: 60px;
        padding: 12px;
    }
}

/* Training notification banner */
.training-notification {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-icon {
    font-size: 32px;
    line-height: 1;
}

.notification-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-text strong {
    font-size: 16px;
    display: block;
    margin-bottom: 4px;
}

.dismiss-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dismiss-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

.notification-actions {
    margin-top: 8px;
}

.training-cmd-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.training-cmd-btn:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.training-cmd-btn:active {
    transform: translateY(0);
}

/* Training command overlay */
.training-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

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

.training-modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
    transition: background-color 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.training-modal h3 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 20px;
    transition: color 0.3s ease;
}

.training-modal p {
    margin: 10px 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    transition: color 0.3s ease;
}

.code-block {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    overflow-x: auto;
    position: relative;
}

.code-block code {
    display: block;
    line-height: 1.6;
}

.copy-btn {
    width: 100%;
    padding: 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

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

.copy-btn.copied {
    background: #667eea;
}

.help-text {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
}
