/* ==========================================================================
   Issue View Styles
   ========================================================================== */

/* Issue Header */
.issue-header {
    padding: 0.5rem 0 0.25rem;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 0.25rem;
}

.back-link {
    display: inline-block;
    color: var(--color-text-light);
    text-decoration: none;
    margin-bottom: 0.1rem;
    transition: var(--transition);
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--color-primary);
    transform: translateX(-5px);
}

.issue-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.1rem;
}

.issue-title-row h1 {
    margin-bottom: 0;
    font-size: 1.5rem;
    flex: 1;
    min-width: 0;
}

.issue-date-group {
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 0.4em;
}

.issue-meta-month,
.issue-meta {
    font-family: var(--font-primary);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary);
    font-style: normal;
    letter-spacing: 0.04em;
    margin-bottom: 0;
}

.issue-ads-summary {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-bottom: 0.25rem;
}

.issue-ads-summary .analyzed-count {
    font-weight: 600;
    color: var(--color-accent);
}

.issue-context {
    max-width: 800px;
    margin-top: 0.15rem;
}

.issue-context p {
    color: var(--color-text-light);
    line-height: 1.4;
    font-size: 1rem;
    margin: 0;
}

/* Ads Section */
.section-header {
    margin-bottom: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.section-header h2 {
    margin: 0 0 0.25rem 0;
    color: var(--color-primary);
}

.filter-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Uniform filter buttons */
.favorites-filter,
.excluded-filter,
.unanalyzed-filter,
.rescan-filter {
    display: flex;
    align-items: center;
}

.favorites-filter-label,
.excluded-filter-label,
.unanalyzed-filter-label,
.rescan-filter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 400;
    color: #333;
    padding: 0.4rem 0.65rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    transition: var(--transition);
}

.favorites-filter-label:hover,
.excluded-filter-label:hover,
.unanalyzed-filter-label:hover,
.rescan-filter-label:hover {
    border-color: #666;
}

.favorites-filter-label input[type="checkbox"],
.excluded-filter-label input[type="checkbox"],
.unanalyzed-filter-label input[type="checkbox"],
.rescan-filter-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.ads-section {
    padding: 0.25rem 0;
}

.ad-count-display {
    text-align: center;
    color: var(--color-text-light);
    margin-top: 0;
}

.analyzed-count-display {
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.analyzed-count-display .analyzed-count {
    font-weight: 600;
    color: var(--color-accent);
}

.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.ad-item {
    background: var(--color-surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.ad-item.unanalyzed-highlight {
    border-color: #e53e3e;
}

.ad-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    border-color: var(--color-accent);
}

.ad-thumbnail {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--color-background);
}

.ad-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: var(--transition);
}

.favorite-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.favorite-badge-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    width: 48px; /* Increased from 36px */
    height: 48px; /* Increased from 36px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem; /* Increased from 1.4rem */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 3;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.favorite-badge-toggle:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.favorite-badge-toggle .star-icon {
    color: #999; /* Darker gray for better visibility */
    font-size: 1.6rem; /* Increased from 1.2rem */
    transition: all 0.2s;
}

.favorite-badge-toggle .star-icon.favorited {
    color: #d4a574; /* Gold for favorited */
}

/* Exclude badge - top left */
.exclude-badge-toggle {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    width: 48px; /* Increased from 36px */
    height: 48px; /* Increased from 36px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem; /* Increased from 1.4rem */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 3;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.exclude-badge-toggle:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.exclude-badge-toggle .exclude-icon {
    color: #ccc;
    font-size: 1.6rem; /* Increased from default */
    transition: all 0.2s;
}

.exclude-badge-toggle .exclude-icon.excluded {
    color: #dc3545; /* Red */
}

.ad-item:hover .ad-thumbnail img {
    transform: scale(1.05);
}

.ad-hover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(44, 62, 80, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
    z-index: 1;
}

.ad-item:hover .ad-hover-overlay {
    opacity: 1;
}

.view-text {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-item-info {
    padding: var(--space-sm) var(--space-md);
}

.ad-item-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ad-item-status {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* ==========================================================================
   Lightbox Modal
   ========================================================================== */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    padding: var(--space-md);
    overflow: auto;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-close {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1001;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lightbox-close:hover {
    background: white;
    transform: rotate(90deg);
}

.lightbox-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    max-width: 1400px;
    width: 100%;
    max-height: 90vh;
    background: var(--color-surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Navigation Arrows */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 3rem;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 10002;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lightbox-nav:disabled:hover {
    transform: translateY(-50%);
}

/* Mobile: stack vertically */
@media (max-width: 768px) {
    .lightbox-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        max-height: 95vh;
    }
    
    .lightbox-image-panel {
        max-height: 40vh;
    }
    
    .lightbox-image-panel img {
        max-height: 35vh;
    }
}

.lightbox-image-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: var(--color-background);
    padding: var(--space-md);
    overflow: auto;
    max-height: 90vh;
}

.lightbox-image-panel img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: var(--space-md);
}

.ai-analysis-display {
    width: 100%;
    max-width: 600px;
    padding: var(--space-md);
    background: white;
    border-radius: 8px;
    border: 2px solid var(--color-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.analysis-display-title {
    margin: 0 0 var(--space-sm) 0;
    font-size: 1.1rem;
    color: var(--color-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.analysis-display-text {
    color: var(--color-text);
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

.lightbox-analysis-panel {
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    max-height: 90vh;
}

.analysis-header {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 2px solid var(--color-border);
    background: var(--color-background);
    flex-shrink: 0;
}

.analysis-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

/* Metadata Form in Panel */
.metadata-form-container {
    padding: var(--space-sm);
    overflow-y: auto;
    flex: 1;
}

.analysis-content {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.metadata-form-actions {
    margin-bottom: 0.3rem;
    padding: 0.2rem;
    border-bottom: none;
    display: flex;
    justify-content: flex-end;
    background: white;
    position: relative;
    z-index: 100;
}

.metadata-section-title {
    margin: 0 0 0.4rem 0;
    padding: 0.2rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
}

.metadata-form-group {
    margin-bottom: 0.3rem;
}

.metadata-form-group label {
    display: block;
    margin-bottom: 0.1rem;
    color: var(--color-text);
    font-weight: 500;
    font-size: 0.8rem;
}

.metadata-form-group input[type="text"],
.metadata-form-group textarea {
    width: 100%;
    padding: 0.35rem;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--color-bg-light);
    color: var(--color-text);
    transition: var(--transition);
    box-sizing: border-box;
}

.metadata-form-group input[type="text"]:focus,
.metadata-form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.metadata-form-group textarea {
    min-height: 50px;
    resize: vertical;
}

.metadata-form-group.checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-direction: row;
}

.metadata-form-group.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.metadata-form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.favorite-star {
    font-size: 1.5rem;
    vertical-align: middle;
    color: #d4a574;
}

.exclude-star {
    font-size: 1.5rem;
    vertical-align: middle;
    color: #dc3545;
}

.metadata-form-info {
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-style: italic;
    margin-top: 0.25rem;
}

.metadata-btn {
    padding: 0.3rem 0.6rem;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.metadata-btn-save {
    background: var(--color-primary);
    color: white;
}

.metadata-btn-save:hover {
    background: var(--color-primary-dark);
    opacity: 0.9;
}

.metadata-btn-ocr {
    background: var(--color-accent);
    color: white;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.metadata-btn-ocr:hover {
    background: #c49564;
    transform: translateY(-1px);
}

.metadata-btn-ocr:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.metadata-btn-expand {
    background: var(--color-secondary);
    color: white;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.metadata-btn-expand:hover {
    background: #7a6a4f;
    transform: translateY(-1px);
}

/* Save Message */
.save-message {
    background: #4caf50;
    color: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: 4px;
    margin-bottom: var(--space-md);
    text-align: center;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.save-message.error {
    background: #f44336;
}

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

/* OCR Expand Modal */
.ocr-expand-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10003;
    padding: var(--space-md);
}

.ocr-expand-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ocr-expand-content {
    background: var(--color-bg);
    border-radius: 8px;
    max-width: 900px;
    width: 100%;
    height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.ocr-expand-header {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 2px solid var(--color-border);
    background: var(--color-bg-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ocr-expand-header h3 {
    margin: 0;
    color: var(--color-text);
}

.ocr-expand-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.ocr-expand-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text);
}

.ocr-expand-body {
    padding: var(--space-md);
    flex: 1;
    overflow: auto;
}

.ocr-expand-body textarea {
    width: 100%;
    height: 100%;
    padding: var(--space-sm);
    border: 2px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    background: white;
    color: var(--color-text);
    resize: none;
    box-sizing: border-box;
}

.ocr-expand-body textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ocr-expand-footer {
    padding: var(--space-sm) var(--space-md);
    border-top: 2px solid var(--color-border);
    background: var(--color-bg-light);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}


.analysis-content {
    padding: var(--space-md);
    flex: 1;
    overflow: auto;
}

.analysis-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-xl);
    min-height: 400px;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.analysis-placeholder h3 {
    margin-bottom: var(--space-sm);
    color: var(--color-primary);
}

.analysis-placeholder p {
    color: var(--color-text-light);
    margin-bottom: var(--space-md);
    max-width: 400px;
}

/* Analysis Content Sections */
.analysis-section {
    margin-bottom: var(--space-md);
}

.analysis-section h3 {
    color: var(--color-secondary);
    font-size: 1.2rem;
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--color-border);
}

.analysis-section p {
    color: var(--color-text);
    line-height: 1.7;
    margin-bottom: var(--space-sm);
}

.analysis-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.tag {
    background: var(--color-background);
    color: var(--color-text);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
}

/* Responsive Lightbox */
@media (max-width: 1024px) {
    .lightbox-content {
        grid-template-columns: 1fr;
        max-height: none;
    }
    
    .lightbox-image-panel {
        max-height: 50vh;
    }
}

@media (max-width: 768px) {
    .ads-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .lightbox {
        padding: 0;
    }
    
    .lightbox-content {
        border-radius: 0;
        max-height: 100vh;
    }
    
    .lightbox-close {
        top: var(--space-sm);
        right: var(--space-sm);
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}

/* Batch AI Button */
.batch-ai-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-left: 15px;
}

.batch-ai-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.batch-ai-button:active {
    transform: translateY(0);
}

/* Modal for Batch AI */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Batch AI Button */
.batch-ai-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.batch-ai-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.batch-ai-button:active {
    transform: translateY(0);
}

/* Batch AI Modal - reuse lightbox styling but customize */
#batch-ai-modal .lightbox-content {
    max-width: 700px;
    max-height: 80vh;
}

#batch-ai-modal .modal-header h2 {
    color: #667eea;
}

#batch-log div {
    padding: 2px 0;
    font-size: 0.85em;
    line-height: 1.4;
}
