/**
 * Tag Interface CSS - Clean Individual Page Version
 * Optimized for gallery cards and individual image pages
 * All lightbox references removed - July 2025
 */

/* ==========================================================================
   Base Tag Styles
   ========================================================================== */

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
    min-height: 32px;
    align-items: flex-start;
    position: relative;
}

.tag {
    display: inline-flex;
    align-items: center;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    height: 28px;
    max-width: 160px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border: none;
    outline: none;
}

.tag-left {
    padding: 0 8px 0 12px;
    border-radius: 16px 0 0 16px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.tag-right {
    padding: 0 8px;
    border-radius: 0 16px 16px 0;
    display: flex;
    align-items: center;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 14px;
    font-weight: 600;
    opacity: 0.7;
    transition: all 0.2s ease;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.1);
}

.tag:hover .tag-right,
.tag.tag-hover .tag-right {
    opacity: 1;
    background: rgba(0, 0, 0, 0.2);
}

.tag:hover,
.tag.tag-hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tag:active {
    transform: translateY(0);
}

/* ==========================================================================
   Tag Categories - Color-coded
   ========================================================================== */

.tag-character { background-color: #007AFF; color: white; }
.tag-species { background-color: #34C759; color: white; }
.tag-book { background-color: #AF52DE; color: white; }
.tag-location { background-color: #FF9500; color: white; }
.tag-medium { background-color: #FF3B30; color: white; }
.tag-mood { background-color: #5AC8FA; color: white; }
.tag-style { background-color: #FF2D92; color: white; }
.tag-composition { background-color: #30D158; color: white; }
.tag-technique { background-color: #32D74B; color: white; }
.tag-wiki { background-color: #FF9500; color: white; }
.tag-other { background-color: #8E8E93; color: white; }
.tag-warning { background-color: #FF6B35; color: white; }

/* ==========================================================================
   Tag Overflow Management
   ========================================================================== */

.tag-more {
    background-color: #8E8E93;
    color: white;
    padding: 0 10px;
    border-radius: 16px;
    font-size: 11px;
    height: 28px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tag-more:hover {
    background-color: #6D6D70;
    transform: translateY(-1px);
}

/* Hide overflow tags (JavaScript controls this) */
.tag.overflow-hidden {
    display: none !important;
}

/* ==========================================================================
   Add Tag Interface
   ========================================================================== */

.add-tag-btn {
    background-color: #F2F2F7;
    color: #666;
    border: 1px dashed #8E8E93;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 12px;
    height: 28px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.add-tag-btn:hover {
    background-color: #E5E5EA;
    color: #333;
    border-color: #007AFF;
    transform: translateY(-1px);
}

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

.add-tag-dropdown {
    position: fixed;
    z-index: 2000;
    background: white;
    border: 2px solid #007AFF;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 16px;
    min-width: 280px;
    max-width: 320px;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.add-tag-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tag-input {
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    background-color: white;
    transition: border-color 0.2s ease;
    outline: none;
}

.tag-input:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.tag-input::placeholder {
    color: #8E8E93;
}

.category-select {
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    background-color: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.category-select:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.add-tag-buttons {
    display: flex;
    gap: 8px;
}

.add-tag-submit {
    background-color: #007AFF;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s ease;
}

.add-tag-submit:hover {
    background-color: #0056CC;
    transform: translateY(-1px);
}

.add-tag-cancel {
    background-color: #F2F2F7;
    color: #666;
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-tag-cancel:hover {
    background-color: #E5E5EA;
    color: #333;
}

/* ==========================================================================
   Autocomplete Interface
   ========================================================================== */

.autocomplete-results {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    background: white;
    margin-top: 4px;
}

.autocomplete-results:empty {
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #F2F2F7;
    transition: background-color 0.2s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: #F2F2F7;
}

/* ==========================================================================
   Filter Bar
   ========================================================================== */

.filter-bar {
    background-color: #F2F2F7;
    border: 1px solid #E5E5EA;
    border-radius: 12px;
    padding: 15px 20px;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    animation: slideDown 0.3s ease;
}

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

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.filter-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-tag {
    background-color: #007AFF;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-tag:hover {
    background-color: #0056CC;
    transform: translateY(-1px);
}

.filter-remove {
    font-size: 16px;
    font-weight: 600;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.filter-tag:hover .filter-remove {
    opacity: 1;
}

.clear-filters {
    background-color: #FF3B30;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-filters:hover {
    background-color: #D70015;
    transform: translateY(-1px);
}

/* ==========================================================================
   Tag Removal Confirmation
   ========================================================================== */

.tag-removal-tooltip {
    background: white;
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px;
    animation: fadeInScale 0.2s ease;
    z-index: 2000;
    position: fixed;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tooltip-content {
    font-size: 13px;
    color: #333;
    text-align: center;
}

.tooltip-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.confirm-remove {
    background-color: #FF3B30;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    transition: background-color 0.2s ease;
}

.confirm-remove:hover {
    background-color: #D70015;
}

.cancel-remove {
    background-color: #F2F2F7;
    color: #666;
    border: 1px solid #E5E5EA;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s ease;
}

.cancel-remove:hover {
    background-color: #E5E5EA;
    color: #333;
}

/* ==========================================================================
   Notifications
   ========================================================================== */

.tag-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tag-notification-success {
    background-color: #34C759;
    color: white;
}

.tag-notification-error {
    background-color: #FF3B30;
    color: white;
}

.tag-notification-info {
    background-color: #007AFF;
    color: white;
}

/* ==========================================================================
   Gallery Card Integration
   ========================================================================== */

.image-card {
    position: relative;
    overflow: hidden;
}

.image-card .image-info {
    position: relative;
}

.image-card .tag-container {
    margin-top: 8px;
    margin-bottom: 0;
    position: relative;
}

.image-card .tag {
    font-size: 11px;
    height: 24px;
}

.image-card .tag-left {
    padding: 0 6px 0 10px;
}

.image-card .tag-right {
    padding: 0 6px;
    font-size: 13px;
}

.image-card .tag-more {
    height: 24px;
    font-size: 10px;
    padding: 0 8px;
}

.image-card .add-tag-btn {
    height: 24px;
    font-size: 11px;
    padding: 0 8px;
}

/* ==========================================================================
   Individual Image Page Styles
   ========================================================================== */

.image-page .tag-container {
    margin: 16px 0;
    gap: 8px;
}

.image-page .tag {
    height: 32px;
    font-size: 13px;
    max-width: 200px;
}

.image-page .tag-left {
    padding: 0 10px 0 14px;
}

.image-page .tag-right {
    padding: 0 10px;
}

.image-page .add-tag-btn {
    height: 32px;
    font-size: 13px;
    padding: 0 14px;
}

.image-page .tag-more {
    height: 32px;
    font-size: 12px;
}

/* ==========================================================================
   Mobile Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .tag {
        height: 32px;
        font-size: 13px;
    }
    
    .tag-left {
        padding: 0 10px 0 14px;
    }
    
    .tag-right {
        padding: 0 10px;
        font-size: 16px;
    }
    
    .add-tag-btn {
        height: 32px;
        padding: 0 14px;
        font-size: 13px;
    }
    
    .tag-more {
        height: 32px;
        font-size: 12px;
    }
    
    .filter-bar {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .filter-tags {
        width: 100%;
    }
    
    .filter-tag {
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .add-tag-dropdown {
        min-width: calc(100% - 20px);
        max-width: calc(100% - 20px);
        left: 10px !important;
        right: 10px;
    }
    
    .tag-input,
    .category-select {
        font-size: 16px;
        padding: 12px;
    }
    
    .add-tag-buttons {
        flex-direction: column;
    }
    
    .add-tag-submit,
    .add-tag-cancel {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .tag-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .tag-container {
        gap: 4px;
    }
    
    .tag {
        max-width: 140px;
        font-size: 11px;
        height: 22px;
    }
    
    .filter-bar {
        margin: 0 -10px 15px -10px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .add-tag-dropdown {
        left: 5px !important;
        right: 5px;
        min-width: calc(100% - 10px);
        max-width: calc(100% - 10px);
    }
}

/* ==========================================================================
   Animation and Interaction States
   ========================================================================== */

.filtered-out {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tag.hiding {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}

.tag.showing {
    opacity: 1;
    transform: scale(1);
    transition: all 0.2s ease;
}

.tag-left:hover {
    text-decoration: underline;
}

.tag:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

.add-tag-btn:focus-visible,
.filter-tag:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.tags-loading {
    opacity: 0.6;
    pointer-events: none;
}

.tag-error {
    background-color: #FF3B30 !important;
    color: white !important;
}

.tag-success {
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.no-js .add-tag-btn,
.no-js .filter-bar {
    display: none;
}

/* ==========================================================================
   Enhanced Validation Styling
   ========================================================================== */

.tag-validation-feedback {
    margin: 8px 0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-validation-feedback.error {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c00;
}

.tag-validation-feedback.success {
    background-color: #efe;
    border: 1px solid #cfc;
    color: #060;
}

.tag-rules-help {
    margin: 12px 0 8px 0;
    padding: 10px;
    background-color: var(--panel-bg-color);
    border: 1px solid var(--panel-border-color);
    border-radius: 4px;
    font-size: 0.8rem;
}

.tag-rules-help .rules-content strong {
    color: var(--header-footer-bg);
    display: block;
    margin-bottom: 4px;
}

.tag-rules-help ul {
    margin: 4px 0 0 16px;
    padding: 0;
    color: var(--text-color-secondary);
}

.tag-rules-help li {
    margin: 2px 0;
}

.add-tag-submit.disabled {
    background-color: var(--panel-border-color) !important;
    color: var(--text-color-secondary) !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.add-tag-submit:not(.disabled):hover {
    background-color: var(--header-footer-bg) !important;
    transform: translateY(-1px);
}


/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .filter-bar,
    .add-tag-btn,
    .tag-right {
        display: none !important;
    }
    
    .tag {
        background-color: #F2F2F7 !important;
        color: #333 !important;
    }
}