/* History Page Styles */

.history-section {
    padding: 80px 0;
    min-height: calc(100vh - 200px);
    background: #f8f9fa;
}

.history-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-title {
    font-size: 36px;
    font-weight: 700;
    color: #000000;
    margin-bottom: 10px;
    text-align: center;
}

.history-notice {
    font-size: 14px;
    color: #666666;
    text-align: center;
    margin-bottom: 40px;
    font-style: italic;
}

.history-content {
    margin-top: 20px;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.history-item {
    position: relative;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.history-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #ffa500;
}

.history-item-image {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
}

.history-item-info {
    padding: 16px;
}

.history-item-prompt {
    font-size: 14px;
    color: #333333;
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666666;
    margin-bottom: 12px;
}

.history-item-date {
    font-size: 12px;
    color: #999999;
}

.history-item-model {
    font-size: 12px;
    color: #ffa500;
    font-weight: 600;
}

.history-item-actions {
    display: flex;
    gap: 8px;
}

.history-download-btn {
    flex: 1;
    padding: 8px 16px;
    background: #ffa500;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.history-download-btn:hover {
    background: #ff8c00;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(255, 165, 0, 0.3);
}

.history-download-btn svg {
    width: 16px;
    height: 16px;
}

/* Клик по кнопке «Скачать» на карточке не открывает модалку */
.history-item-actions,
.history-item-actions a {
    cursor: pointer;
}
.history-item-actions a {
    pointer-events: auto;
}

/* Модальное окно просмотра генерации */
.history-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.history-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.history-modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.65);
    cursor: pointer;
}

.history-modal-box {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    width: 560px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.history-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.history-modal-close:hover {
    background: rgba(0, 0, 0, 0.75);
}

.history-modal-image-wrap {
    flex: 0 0 auto;
    max-height: 60vh;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-modal-image {
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.history-modal-prompt-wrap {
    flex: 0 0 auto;
    padding: 20px 24px 16px;
    border-top: 1px solid #eee;
    max-height: 25vh;
    overflow-y: auto;
}

.history-modal-prompt-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.history-modal-prompt {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.history-modal-download {
    margin: 0 24px 24px;
    flex: 0 0 auto;
    text-align: center;
}

.history-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666666;
}

.history-empty p {
    font-size: 18px;
    margin-bottom: 24px;
}

.loading-container {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ffa500;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.not-authenticated {
    text-align: center;
    padding: 60px 20px;
}

.not-authenticated p {
    font-size: 18px;
    color: #666666;
    margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .history-section {
        padding: 40px 0;
    }
    
    .history-container {
        padding: 20px;
        margin: 0 15px;
    }
    
    .history-title {
        font-size: 28px;
    }
    
    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
    
    .history-item-image {
        height: 200px;
    }
}
