/* History CSS - Modern Card-based History Layout + Settings */
/* UPDATED: Removed word/char count badge styles */

.content-gallery {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.gallery-title h2 {
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.gallery-title p {
    color: #64748b;
    font-size: 0.95rem;
    margin: 0;
}

/* Gallery Actions Container */
.gallery-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Settings Button */
.settings-btn {
    background: var(--gray-500);
    color: white;
    border: none;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    box-shadow: var(--shadow-sm);
}

.settings-btn:hover {
    background: var(--gray-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.settings-btn svg {
    transition: transform var(--transition-normal);
}

.settings-btn:hover svg {
    transform: rotate(90deg);
}

/* Settings Dropdown */
.history-settings-dropdown {
    position: relative;
    margin-bottom: var(--space-4);
    z-index: 100;
}

.settings-panel {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 0;
    overflow: hidden;
    animation: slideDown 0.3s ease-out;
    max-width: 400px;
    margin-left: auto;
    margin-right: 0;
}

.settings-header {
    background: linear-gradient(135deg, var(--gray-25), var(--gray-50));
    border-bottom: 1px solid var(--gray-200);
    padding: var(--space-4) var(--space-6);
}

.settings-header h4 {
    color: var(--gray-900);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin: 0;
}

.settings-content {
    padding: var(--space-6);
}

.setting-group {
    margin-bottom: var(--space-4);
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    color: var(--gray-800);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-3);
}

/* Limit Controls */
.limit-controls {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-2);
}

.history-slider {
    flex: 1;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    outline: none;
    appearance: none;
    cursor: pointer;
}

.history-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--orange-500);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.history-slider::-webkit-slider-thumb:hover {
    background: var(--orange-600);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.history-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--orange-500);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.history-slider::-moz-range-track {
    height: 6px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
}

.history-input {
    width: 70px;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-align: center;
    background: white;
    transition: all var(--transition-normal);
}

.history-input:focus {
    outline: none;
    border-color: var(--orange-400);
    box-shadow: 0 0 0 3px rgba(238, 119, 35, 0.1);
    background: var(--orange-25, #fefaf8);
}

.limit-info {
    color: var(--gray-500);
    font-style: italic;
}

.limit-info small {
    font-size: var(--text-xs);
}

/* Settings Footer */
.settings-footer {
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    padding: var(--space-4) var(--space-6);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

.settings-apply-btn,
.settings-cancel-btn {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    min-width: 80px;
}

.settings-apply-btn {
    background: var(--orange-500);
    color: white;
    box-shadow: var(--shadow-sm);
}

.settings-apply-btn:hover {
    background: var(--orange-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.settings-cancel-btn {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.settings-cancel-btn:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
    transform: translateY(-1px);
}

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

/* History Grid Layout */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* History Cards - UPDATED: Removed word/char count related styles */
.history-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.history-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.15);
    transform: translateY(-4px);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: #64748b;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-meta-left {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.history-model {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.category-badge {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.template-name {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.history-date {
    font-style: italic;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-left: auto;
}

.history-preview {
    color: #1f2937;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* UPDATED: Simplified footer without stat badges */
.history-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

/* Clear History Button */
.clear-history-btn {
    background: var(--error-500);
    color: white;
    border: none;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.clear-history-btn:hover {
    background: var(--error-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* UPDATED: Use History Button - Enhanced styling */
.use-history-btn {
    background: var(--success-500);
    color: white;
    border: none;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-normal);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.use-history-btn:hover {
    background: var(--success-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Empty State */
.history-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: #94a3b8;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.history-empty h3 {
    color: #64748b;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.history-empty p {
    color: #94a3b8;
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Legacy history section compatibility */
.history-section {
    display: block;
}

.history-list {
    display: contents;
}

/* Mobile History Responsiveness */
@media (max-width: 768px) {
    .content-gallery {
        padding: 1.5rem;
        border-radius: 15px;
    }

    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    /* Mobile Gallery Actions */
    .gallery-actions {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
        width: 100%;
    }
    
    .settings-btn,
    .clear-history-btn {
        justify-content: center;
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-xs);
    }
    
    .settings-panel {
        max-width: none;
        margin: 0;
    }
    
    .settings-content {
        padding: var(--space-4);
    }
    
    .limit-controls {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .history-slider {
        order: 2;
    }
    
    .history-input {
        order: 1;
        width: 100px;
        align-self: center;
    }
    
    .settings-footer {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .settings-apply-btn,
    .settings-cancel-btn {
        width: 100%;
    }

    .history-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .history-item {
        padding: 1.25rem;
    }

    .history-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .history-meta-left {
        width: 100%;
    }

    .history-date {
        margin-left: 0;
        align-self: flex-end;
    }

    .history-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .use-history-btn {
        margin-left: 0;
        align-self: stretch;
        justify-content: center;
    }

    .empty-icon {
        font-size: 3rem;
    }

    .history-empty h3 {
        font-size: 1.25rem;
    }

    .history-empty p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .content-gallery {
        padding: 1rem;
    }

    .history-item {
        padding: 1rem;
    }

    .history-preview {
        font-size: 0.85rem;
        -webkit-line-clamp: 2;
    }

    .history-meta-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* Mobile Settings */
    .settings-header {
        padding: var(--space-3) var(--space-4);
    }
    
    .settings-content {
        padding: var(--space-3);
    }
    
    .settings-footer {
        padding: var(--space-3) var(--space-4);
    }
}