/* Global Modal Styles for Dynbrew */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
    position: relative;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    cursor: move;
    cursor: grab;
    user-select: none;
}

.modal-header:active {
    cursor: grabbing;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #7f8c8d;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #e0e0e0;
    color: #2c3e50;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 2px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.modal-loading {
    text-align: center;
    color: #7f8c8d;
    padding: 2rem;
}

.modal-error {
    color: #e74c3c;
    background: #fee;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #e74c3c;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-field {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 3px solid #3498db;
}

.field-label {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.field-value {
    font-size: 1.1rem;
    color: #2c3e50;
    font-weight: 600;
}

.modal-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.modal-section h4 {
    color: #2c3e50;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.modal-section p {
    color: #555;
    line-height: 1.6;
    margin: 0;
}

/* Clickable table rows */
.clickable-row {
    cursor: pointer;
    transition: background 0.15s;
}

.clickable-row:hover {
    background: #f0f8ff !important;
}

.clickable-row:active {
    background: #e3f2fd !important;
}

/* JSON Accordion */
.json-accordion {
    margin-top: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.json-accordion-header {
    width: 100%;
    background: #f8f9fa;
    border: none;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    transition: background 0.2s;
}

.json-accordion-header:hover {
    background: #e9ecef;
}

.json-accordion-header .accordion-icon {
    transition: transform 0.3s;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.json-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.json-accordion-content.open {
    max-height: 500px;
    overflow-y: auto;
}

.json-accordion-content.open~.json-accordion-header .accordion-icon {
    transform: rotate(180deg);
}

.json-accordion-content pre {
    margin: 0;
    padding: 1rem 1.25rem;
    background: #2c3e50;
    color: #ecf0f1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
}

.json-accordion-content code {
    color: #ecf0f1;
}

/* Post Modal Styles */
.modal-post {
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
}

.modal-post .modal-body {
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.post-modal-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.post-modal-content {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.post-modal-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.comment-count-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.post-modal-comments {
    margin-top: 1.5rem;
}

.post-modal-comments h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
    color: var(--text-primary);
}

#comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.comment-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 6px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    flex-wrap: wrap;
}

.comment-user {
    font-weight: 600;
    color: var(--text-primary);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.comment-text {
    color: var(--text-primary);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.comment-actions {
    margin-top: 0.5rem;
}

.comment-reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.comment-reaction-btn:hover {
    background: rgba(52, 152, 219, 0.05);
    border-color: var(--primary);
}

.comment-reaction-btn.active {
    background: rgba(52, 152, 219, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.comment-reaction-btn .reaction-count {
    font-weight: 600;
}

.no-comments {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

.comments-error {
    text-align: center;
    padding: 1rem;
    color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
}

#comments-loading {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
}

#load-more-comments {
    width: 100%;
    margin-top: 1rem;
}

.post-modal-add-comment {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.post-modal-add-comment textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9375rem;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 0.75rem;
}

.post-modal-add-comment textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.post-modal-add-comment button {
    float: right;
}

.post-modal-loading,
.post-modal-error {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.post-modal-error {
    color: var(--danger);
}