@import '../../shared/css/universal.css';

/* ==========================================================================
   POS TAGGER SPECIFIC STYLES (tools.chfmath.com/tagger)
   ========================================================================== */

/* ================================
   Layout
================================ */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: var(--spacing-lg) 0;
    position: relative;
}

/* ================================
   Main Content
================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

/* ================================
   Input Section
================================ */
.input-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: 4rem;
}

.input-wrapper {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
}

#sentenceInput {
    flex: 1;
    padding: var(--spacing-md);
    font-size: 1.1rem;
    font-family: var(--font-family);
    background: rgba(0, 17, 34, 0.6);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
    color: var(--text-color);
    resize: vertical;
    min-height: 100px;
    transition: all var(--transition-fast);
}

#sentenceInput:focus {
    outline: none;
    background: rgba(0, 17, 34, 0.9);
    box-shadow: 0 0 15px rgba(0, 102, 255, 0.3);
}

#sentenceInput::placeholder {
    color: var(--text-muted);
}

/* ================================
   Buttons
================================ */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1rem;
    font-size: 1rem;
    font-weight: bold;
    font-family: var(--font-family);
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background-color: var(--secondary-color);
    color: var(--other-text-color);
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: bold;
    font-family: var(--font-family);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: var(--spacing-xs);
    transition: color var(--transition-fast);
}

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

.btn-icon-only {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-color);
    transition: all var(--transition-fast);
}

.btn-icon-only:hover {
    background: var(--primary-color);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color var(--transition-fast);
}

.btn-close:hover {
    color: var(--text-primary);
}

/* ================================
   Controls
================================ */
.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.toggle-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: bold;
}

.toggle-switch {
    position: relative;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    padding: 3px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.toggle-option {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.toggle-option.active {
    background: var(--primary-color);
    color: var(--text-color);
}

/* ================================
   Output Section
================================ */
.output-section {
    background: rgba(0, 30, 60, 0.5);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 4rem;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.output-header h2 {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
}

/* ================================
   Legend
================================ */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm) var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    animation: slideDown var(--transition-normal);
}

.legend.hidden {
    display: none;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: bold;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-color.noun {
    background: var(--pos-noun);
}

.legend-color.verb {
    background: var(--pos-verb);
}

.legend-color.adjective {
    background: var(--pos-adjective);
}

.legend-color.adverb {
    background: var(--pos-adverb);
}

.legend-color.pronoun {
    background: var(--pos-pronoun);
}

.legend-color.preposition {
    background: var(--pos-preposition);
}

.legend-color.conjunction {
    background: var(--pos-conjunction);
}

.legend-color.determiner {
    background: var(--pos-determiner);
}

.legend-color.other {
    background: var(--pos-other);
}

/* ================================
   Tagged Output
================================ */
.tagged-output {
    min-height: 100px;
    line-height: 2.5;
    font-size: 1.4rem;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.1rem;
}

.error-text {
    color: var(--pos-verb);
    font-weight: bold;
}

.tagged-word {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    margin: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    border-bottom: 3px solid transparent;
}

.tagged-word:hover {
    transform: translateY(-2px);
    background-color: rgba(255, 255, 255, 0.1);
}

.tagged-word .tag-label {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 6px;
    border-radius: 3px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 5;
}

.tagged-word:hover .tag-label {
    opacity: 1;
}

/* POS Word Colors */
.tagged-word.noun {
    color: var(--pos-noun);
    border-color: var(--pos-noun);
}

.tagged-word.verb {
    color: var(--pos-verb);
    border-color: var(--pos-verb);
}

.tagged-word.adjective {
    color: var(--pos-adjective);
    border-color: var(--pos-adjective);
}

.tagged-word.adverb {
    color: var(--pos-adverb);
    border-color: var(--pos-adverb);
}

.tagged-word.pronoun {
    color: var(--pos-pronoun);
    border-color: var(--pos-pronoun);
}

.tagged-word.preposition {
    color: var(--pos-preposition);
    border-color: var(--pos-preposition);
}

.tagged-word.conjunction {
    color: var(--pos-conjunction);
    border-color: var(--pos-conjunction);
}

.tagged-word.determiner {
    color: var(--pos-determiner);
    border-color: var(--pos-determiner);
}

.tagged-word.other {
    color: var(--pos-other);
    border-color: var(--pos-other);
}

/* ================================
   History Sidebar
================================ */
.history-sidebar {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: var(--background-color);
    border: 2px solid var(--primary-color);
    border-right: none;
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    display: flex;
    transition: all var(--transition-normal);
    z-index: 100;
    max-height: 80vh;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
}

.history-sidebar.collapsed .history-content {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.history-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    background: var(--primary-color);
    border: none;
    border-radius: 0.8rem 0 0 0.8rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-toggle:hover {
    background: var(--secondary-color);
    color: var(--other-text-color);
}

.toggle-icon {
    font-size: 1.3rem;
}

.history-content {
    width: 280px;
    padding: var(--spacing-md);
    overflow-y: auto;
    transition: all var(--transition-normal);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--primary-color);
}

.history-header h3 {
    font-size: 1rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.history-item {
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 102, 255, 0.1);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    border-color: var(--secondary-color);
    background: rgba(255, 255, 255, 0.05);
}

.history-text {
    font-size: 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-secondary);
}

.history-timestamp {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* Context Menu / Dropdown */
.tag-dropdown {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 500;
    min-width: 160px;
    opacity: 0;
    transform: scale(0.95);
    transition: all var(--transition-fast);
    pointer-events: none;
}

.tag-dropdown.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.dropdown-header {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.8rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-color);
    color: var(--text-color);
    border-radius: 0.6rem 0.6rem 0 0;
}

#dropdownWord {
    font-weight: bold;
}

.dropdown-options {
    list-style: none;
    padding: var(--spacing-sm) 0;
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-color);
    font-weight: bold;
}

.dropdown-option:hover {
    background: rgba(255, 231, 76, 0.2);
}

.dropdown-option.current {
    background: rgba(0, 148, 115, 0.3);
    color: var(--accent-color);
}

.dropdown-option .option-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.dropdown-option .option-color.noun {
    background: var(--pos-noun);
}

.dropdown-option .option-color.verb {
    background: var(--pos-verb);
}

.dropdown-option .option-color.adjective {
    background: var(--pos-adjective);
}

.dropdown-option .option-color.adverb {
    background: var(--pos-adverb);
}

.dropdown-option .option-color.pronoun {
    background: var(--pos-pronoun);
}

.dropdown-option .option-color.preposition {
    background: var(--pos-preposition);
}

.dropdown-option .option-color.conjunction {
    background: var(--pos-conjunction);
}

.dropdown-option .option-color.determiner {
    background: var(--pos-determiner);
}

.dropdown-option .option-color.other {
    background: var(--pos-other);
}

/* ================================
   Responsive
================================ */
@media (max-width: 768px) {
    body {
        width: 80%;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .btn-primary {
        width: 100%;
    }

    .controls {
        flex-wrap: wrap;
    }

    .history-sidebar {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        transform: none;
        flex-direction: column;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        border: 2px solid var(--primary-color);
        border-bottom: none;
        max-height: 50vh;
    }

    .history-sidebar.collapsed .history-content {
        width: 100%;
        height: 0;
        padding: 0;
        overflow: hidden;
    }

    .history-toggle {
        width: 100%;
        height: 48px;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        border-bottom: 1px solid var(--primary-color);
    }

    .history-content {
        width: 100%;
    }
}
