/* Additional custom styles */

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Smooth transitions for token counts */
#originalTokens,
#translatedTokens,
#tokenDiff,
#percentDiff,
#moreEfficient {
    transition: all 0.3s ease;
}

/* Character counter warning */
#charCount.warning {
    color: #f59e0b;
    font-weight: 600;
}

#charCount.danger {
    color: #ef4444;
    font-weight: 700;
}

/* Translated text area */
#translatedText {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

#translatedText.has-content {
    color: #1f2937;
    background-color: white;
}

/* Pulse animation for loading */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Token count highlight when updated */
@keyframes highlight {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.token-update {
    animation: highlight 0.3s ease;
}

/* Scrollbar styling for textarea */
#translatedText::-webkit-scrollbar {
    width: 8px;
}

#translatedText::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#translatedText::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#translatedText::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Status indicators */
.status-success {
    color: #10b981;
}

.status-error {
    color: #ef4444;
}

/* Token visualization */
.token-display {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: white;
    border-radius: 4px;
    line-height: 2;
}

.token-box {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    margin: 2px;
    border: 1px solid;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    cursor: help;
    transition: transform 0.1s ease;
    vertical-align: bottom;
    min-height: 24px;
}

.token-box:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    position: relative;
}

/* Token display scrollbar */
.token-display::-webkit-scrollbar {
    width: 6px;
}

.token-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.token-display::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.token-display::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Word grouping styles */
.word-group {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    position: relative;
    margin: 2px 4px;
    vertical-align: bottom;
}

/* Token count badge - tab style */
.token-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 16px;
    padding: 0 5px;
    color: white;
    border-radius: 4px 4px 0 0;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
    margin-bottom: -1px;
    z-index: 1;
    position: relative;
}

/* Badge color variants */
.badge-blue { background: #3b82f6; }
.badge-green { background: #10b981; }
.badge-purple { background: #a855f7; }
.badge-pink { background: #ec4899; }
.badge-yellow { background: #f59e0b; }
.badge-indigo { background: #6366f1; }

/* Invisible badge for single-token alignment */
.badge-invisible {
    opacity: 0;
    pointer-events: none;
}

.tokens-container {
    display: inline-flex;
    align-items: center;
    border-radius: 6px 0 6px 6px;
    padding: 2px 4px;
    background: rgba(255, 255, 255, 0.5);
    border-width: 1.5px;
    border-style: solid;
    min-height: 24px;
}

/* Border color variants */
.border-blue { border-color: #93c5fd; }
.border-green { border-color: #6ee7b7; }
.border-purple { border-color: #d8b4fe; }
.border-pink { border-color: #f9a8d4; }
.border-yellow { border-color: #fcd34d; }
.border-indigo { border-color: #a5b4fc; }

/* Invisible border for single-token alignment */
.border-invisible {
    border-color: transparent;
}

.grouped-token {
    margin: 0 0.5px !important;
    border-radius: 3px !important;
    border-width: 1px;
}

.grouped-token.first-token {
    margin-left: 0 !important;
}

.grouped-token.last-token {
    margin-right: 0 !important;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .token-box {
        font-size: 0.75rem;
        padding: 1px 4px;
    }

    .word-group {
        margin: 6px 4px;
    }

    .tokens-container {
        padding: 3px 4px;
    }

    .token-count-badge {
        min-width: 20px;
        height: 18px;
        font-size: 0.65rem;
    }
}
