/* ========== history.css — History page styles ========== */

html, body {
    min-height: 100vh;
    background: var(--bg-right);
}

/* ========== Navbar ========== */
.navbar-history {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: var(--border-thick);
    background: #fff;
}

.navbar-history .brand { color: #111; }

.nav-links {
    display: flex;
    gap: 12px;
    align-items: center;
}

.nav-links .btn-outline {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ========== Header ========== */
.history-header {
    padding: 40px 40px 0;
    max-width: 1400px;
    margin: 0 auto;
}

.history-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 3vw, 42px);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -1px;
    color: #111;
    margin-bottom: 8px;
}

.history-subtitle {
    font-family: var(--font-body);
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

.history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: var(--border-thin);
    margin-bottom: 32px;
}

.history-count {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: #111;
    background: var(--bg-left);
    border: var(--border-thin);
    padding: 4px 12px;
}

.btn-clear {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: var(--border-thin);
    padding: 6px 14px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    color: var(--accent-red);
    transition: all 0.15s;
}

.btn-clear:hover {
    background: var(--accent-red);
    color: #fff;
}

/* ========== History List ========== */
.history-list {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px 60px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* ========== History Entry ========== */
.history-entry {
    border: var(--border-thick);
    box-shadow: var(--shadow-sharp);
    background: #fff;
    overflow: hidden;
}

.entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #111;
    color: #fff;
    border-bottom: var(--border-thick);
}

.entry-topic {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 16px;
}

.entry-date {
    font-family: var(--font-mono);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.entry-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 200px;
}

/* Left side - Original (Before) */
.entry-before {
    padding: 24px;
    background: rgba(239, 68, 68, 0.06);
    border-right: var(--border-thick);
    position: relative;
}

/* Right side - Rewritten (After) */
.entry-after {
    padding: 24px;
    background: rgba(16, 185, 129, 0.06);
    position: relative;
}

.comparison-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 10px;
    border: var(--border-thin);
    margin-bottom: 16px;
}

.label-before {
    background: var(--accent-red);
    color: #fff;
}

.label-after {
    background: var(--accent-green);
    color: #fff;
}

.comparison-text {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
    color: #333;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.comparison-text::-webkit-scrollbar { width: 6px; }
.comparison-text::-webkit-scrollbar-thumb { background: #ccc; }

/* ========== Empty State ========== */
.history-empty {
    max-width: 500px;
    margin: 80px auto;
    text-align: center;
    padding: 60px 40px;
    border: var(--border-thick);
    box-shadow: var(--shadow-sharp);
    background: #fff;
}

.empty-icon {
    margin-bottom: 24px;
    color: #ccc;
}

.history-empty h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.history-empty p {
    font-size: 16px;
    color: #666;
    margin-bottom: 32px;
}

.btn-go-rewrite {
    display: inline-flex;
    background: var(--accent-blue);
    color: #fff;
    border: var(--border-thick);
    box-shadow: var(--shadow-sharp-sm);
    padding: 14px 32px;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    text-decoration: none;
    gap: 8px;
    cursor: pointer;
    transition: all 0.1s;
}

.btn-go-rewrite:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-sharp);
}

/* ========== Reply Button (per entry) ========== */
.btn-got-reply {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-purple);
    color: #fff;
    border: var(--border-thin);
    padding: 8px 16px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 12px;
}

.btn-got-reply:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-sharp-sm);
}

.btn-got-reply.analyzed {
    background: var(--accent-green);
    cursor: pointer;
}

.entry-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 24px;
    border-top: var(--border-thin);
    background: #FAFAF8;
}

/* ========== Reply Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: #fff;
    border: var(--border-thick);
    box-shadow: 8px 8px 0px #111;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
}

.reply-modal-card {
    max-width: 600px;
}

.reply-results-card {
    max-width: 720px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    text-transform: uppercase;
}

.modal-close {
    background: none;
    border: var(--border-thin);
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: #111;
    color: #fff;
}

.modal-desc {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.reply-context-preview {
    background: #F8F8F5;
    border: var(--border-thin);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #666;
    max-height: 80px;
    overflow: hidden;
    white-space: pre-wrap;
    position: relative;
}

.reply-context-preview::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 30px;
    background: linear-gradient(transparent, #F8F8F5);
}

.reply-label {
    display: block;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-purple);
    margin-bottom: 8px;
}

.reply-textarea {
    width: 100%;
    border: var(--border-thick);
    padding: 16px;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
    min-height: 140px;
    background: #fff;
}

.reply-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-purple);
}

.reply-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-reply-cancel {
    background: transparent;
    border: var(--border-thin);
    padding: 10px 20px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-reply-cancel:hover {
    background: #eee;
}

.btn-reply-submit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-purple);
    color: #fff;
    border: var(--border-thick);
    padding: 10px 24px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--shadow-sharp-sm);
    transition: all 0.15s;
}

.btn-reply-submit:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-sharp);
}

.btn-reply-submit.processing {
    opacity: 0.7;
    pointer-events: none;
}

/* ========== Reply Results ========== */
.reply-sentiment-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: var(--border-thick);
    margin-bottom: 20px;
}

.sentiment-emoji {
    font-size: 32px;
    flex-shrink: 0;
}

.sentiment-info {
    flex: 1;
}

.sentiment-label {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.sentiment-meter {
    width: 100%;
    height: 10px;
    background: #eee;
    border: 1px solid #111;
    position: relative;
}

.sentiment-meter-fill {
    height: 100%;
    transition: width 0.6s ease;
}

.reply-result-section {
    margin-bottom: 16px;
    border: var(--border-thin);
    overflow: hidden;
}

.reply-result-header {
    padding: 10px 16px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    border-bottom: var(--border-thin);
}

.reply-result-header.analysis { background: #DBEAFE; color: #1E40AF; }
.reply-result-header.strategy { background: #FEF9C3; color: #92400E; }
.reply-result-header.email    { background: #D1FAE5; color: #065F46; }

.reply-result-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
    color: #333;
}

.reply-result-body ul {
    margin: 8px 0;
    padding-left: 20px;
}

.reply-result-body li {
    margin-bottom: 6px;
}

.reply-result-body strong {
    color: #111;
}

.reply-email-preview {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
}

.reply-results-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-reply-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: var(--border-thin);
    padding: 10px 18px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-reply-copy:hover {
    background: #111;
    color: #fff;
}

.btn-reply-done {
    background: var(--accent-green);
    color: #fff;
    border: var(--border-thick);
    padding: 10px 24px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--shadow-sharp-sm);
    transition: all 0.15s;
}

.btn-reply-done:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-sharp);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .navbar-history { padding: 16px 20px; }
    .history-header { padding: 24px 20px 0; }
    .history-list { padding: 0 20px 40px; }
    
    .entry-comparison {
        grid-template-columns: 1fr;
    }
    
    .entry-before {
        border-right: none;
        border-bottom: var(--border-thick);
    }
    
    .history-meta { flex-direction: column; gap: 12px; align-items: flex-start; }
    .history-title { font-size: 28px; }
}
