/* ==================== IMAGE ANNOTATOR - COMPLETE STYLES ==================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* ==================== MAIN CONTAINER ==================== */
.img-annotate-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.img-annotate-wrapper {
    max-width: 100%;
    margin: 0 auto;
}

/* ==================== HEADER SECTION ==================== */
.img-annotate-title {
    font-size: 3rem;
    font-weight: 800;
    font-family: 'Poppins', sans-serif;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.img-annotate-icon {
    font-size: 2.8rem;
    display: inline-block;
    animation: imgAnnotateFloat 3s infinite;
}

@keyframes imgAnnotateFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.img-annotate-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-family: 'Poppins', sans-serif;
}

/* ==================== MAIN CARD ==================== */
.img-annotate-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* ==================== LAYOUT ==================== */
.img-annotate-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
}

/* ==================== CONTROLS ==================== */
.img-annotate-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 800px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.img-annotate-controls::-webkit-scrollbar { width: 6px; }
.img-annotate-controls::-webkit-scrollbar-track { background: var(--bg); border-radius: 10px; }
.img-annotate-controls::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.img-annotate-section {
    background: var(--bg);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border);
}

.img-annotate-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.8rem;
}

.img-annotate-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin: 0.4rem 0 0.2rem;
    line-height: 1.4;
}

/* ==================== HISTORY BAR ==================== */
.img-annotate-history-bar {
    display: flex;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    padding-bottom: 0.2rem;
}

.img-annotate-history-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.img-annotate-history-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ==================== UPLOAD ==================== */
.img-annotate-upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.img-annotate-upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.img-annotate-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.img-annotate-upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.img-annotate-upload-content p {
    margin: 0.5rem 0;
    color: var(--text);
    font-size: 0.95rem;
}

.img-annotate-upload-content small {
    color: var(--text-light);
    font-size: 0.8rem;
}

.img-annotate-upload-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.img-annotate-upload-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    display: block;
}

.img-annotate-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.img-annotate-remove-btn:hover {
    background: var(--error);
    transform: scale(1.1);
}

/* ==================== TABS ==================== */
.img-annotate-tab-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.img-annotate-tab {
    padding: 0.5rem 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.72rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s;
    text-align: center;
}

.img-annotate-tab:hover { border-color: var(--primary); }

.img-annotate-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ==================== PICKER GRIDS ==================== */
.img-annotate-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}

.img-annotate-pick-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    padding: 0.3rem;
    color: var(--text);
}

.img-annotate-pick-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    transform: scale(1.06);
}

.img-annotate-emoji-grid {
    grid-template-columns: repeat(8, 1fr);
    max-height: 220px;
    overflow-y: auto;
}

.img-annotate-emoji-grid .img-annotate-pick-btn {
    font-size: 1.3rem;
}

/* ==================== BADGE ROW ==================== */
.img-annotate-badge-row {
    display: flex;
    gap: 0.5rem;
}

.img-annotate-badge-row .img-annotate-input {
    width: 70px;
    flex-shrink: 0;
}

/* ==================== TOGGLE GROUP ==================== */
.img-annotate-toggle-group {
    display: flex;
    gap: 0.5rem;
}

.img-annotate-toggle-btn {
    flex: 1;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s;
}

.img-annotate-toggle-btn:hover { border-color: var(--primary); }

.img-annotate-toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ==================== CONTROLS ==================== */
.img-annotate-control-group { margin-bottom: 0.8rem; }
.img-annotate-control-group:last-child { margin-bottom: 0; }

.img-annotate-control-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.3rem;
}

.img-annotate-control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.img-annotate-input {
    width: 100%;
    padding: 0.5rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
}

.img-annotate-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.img-annotate-select {
    width: 100%;
    padding: 0.5rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
}

.img-annotate-color {
    width: 100%;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--surface);
}

.img-annotate-range {
    width: calc(100% - 50px);
    vertical-align: middle;
    accent-color: var(--primary);
}

.img-annotate-range + span {
    display: inline-block;
    width: 45px;
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ==================== BUTTONS ==================== */
.img-annotate-primary-btn {
    padding: 0.7rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
}

.img-annotate-primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.img-annotate-action-btn {
    padding: 0.6rem 1.1rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    white-space: nowrap;
}

.img-annotate-action-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.img-annotate-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    background: transparent !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.img-annotate-full-btn {
    width: 100%;
    text-align: center;
    margin-top: 0.3rem;
}

/* ==================== LAYERS ==================== */
.img-annotate-layers {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.img-annotate-layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.6rem;
    background: var(--surface);
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.4rem;
}

.img-annotate-layer-item:hover { border-color: var(--border); }

.img-annotate-layer-item.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
}

.img-annotate-layer-label {
    font-size: 0.8rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.img-annotate-layer-actions {
    display: flex;
    gap: 0.1rem;
    flex-shrink: 0;
}

.img-annotate-layer-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.img-annotate-layer-actions button:hover {
    background: rgba(99, 102, 241, 0.12);
}

.img-annotate-layer-actions .layer-delete:hover {
    background: rgba(220, 38, 38, 0.12);
}

/* ==================== PREVIEW ==================== */
.img-annotate-preview {
    background: var(--bg);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.img-annotate-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.img-annotate-preview-header h3 { font-size: 1rem; color: var(--text); }

.img-annotate-preview-actions { display: flex; gap: 0.5rem; }

.img-annotate-preview-btn {
    padding: 0.3rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
}

.img-annotate-preview-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.img-annotate-preview-container {
    flex: 1;
    background: var(--surface);
    border-radius: 12px;
    overflow: auto;
    min-height: 400px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

.img-annotate-preview-container canvas {
    max-width: 100%;
    max-height: 600px;
    object-fit: contain;
    cursor: move;
}

.img-annotate-preview-info {
    margin-top: 0.8rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ==================== FOOTER NOTE ==================== */
.img-annotate-footer-note {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
}

.img-annotate-footer-note p { margin: 0.3rem 0; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .img-annotate-layout { grid-template-columns: 1fr; }
    .img-annotate-controls { max-height: none; overflow-y: visible; }
    .img-annotate-preview-container { min-height: 300px; }
    .img-annotate-history-bar { position: static; }
}

@media (max-width: 768px) {
    .img-annotate-container { padding: 0 1rem; }
    .img-annotate-title { font-size: 2rem; }
    .img-annotate-card { padding: 1rem; }
    .img-annotate-control-row { grid-template-columns: 1fr; }
    .img-annotate-preview-container { min-height: 250px; }
    .img-annotate-preview-container canvas { max-height: 400px; }
    .img-annotate-picker-grid { grid-template-columns: repeat(5, 1fr); }
    .img-annotate-emoji-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 480px) {
    .img-annotate-title { font-size: 1.5rem; }
    .img-annotate-preview-header { flex-direction: column; align-items: stretch; }
    .img-annotate-preview-actions { justify-content: center; }
    .img-annotate-tab-group { grid-template-columns: repeat(2, 1fr); }
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.img-annotate-input:focus-visible,
.img-annotate-select:focus-visible,
.img-annotate-primary-btn:focus-visible,
.img-annotate-action-btn:focus-visible,
.img-annotate-tab:focus-visible,
.img-annotate-toggle-btn:focus-visible,
.img-annotate-pick-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }