/* ========================================
   METADATA SECTION STYLES
   ======================================== */

/* Metadata Section Container */
.metadata-section {
    margin: 1rem 0;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Toggle Button */
.metadata-toggle-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
    font-size: 0.95rem;
    color: var(--text-color);
    position: relative;
    z-index: 10;
}

.metadata-toggle-btn:hover {
    background: var(--button-hover);
    color: white;
}

.metadata-toggle-btn:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.metadata-icon {
    margin-right: 0.5rem;
}

.metadata-label {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

.metadata-arrow {
    transition: transform 0.2s ease;
    font-size: 0.8rem;
}

/* Content Area - Hidden by default */
.metadata-content {
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    display: none; /* Hidden by default */
}

/* Metadata Header with File Path */
.metadata-header {
    padding: 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.metadata-file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.file-path-label {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    font-size: 0.9rem;
}

.file-path {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--link-color);
    flex: 1;
    min-width: 200px;
    word-break: break-all;
    user-select: all;
}

.copy-path-btn {
    background: var(--link-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.copy-path-btn:hover {
    background: var(--link-hover);
    transform: translateY(-1px);
}

.copy-path-btn:active {
    transform: scale(0.95);
}

.copy-path-btn.copied {
    background: #4CAF50;
    transform: scale(1.05);
}

/* Tip Icon with Hover Tooltip */
.tip-icon {
    cursor: help;
    font-size: 1.2rem;
    position: relative;
    display: inline-block;
    margin-left: 0.25rem;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.tip-icon:hover {
    opacity: 1;
}

/* Custom tooltip for tip icon */
.tip-icon::after {
    content: attr(title);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: normal;
    width: 280px;
    text-align: left;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
    font-weight: normal;
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

/* Tooltip arrow */
.tip-icon::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1001;
}

.tip-icon:hover::after,
.tip-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Grid Layout */
.metadata-grid {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem 1.5rem; /* Increased gaps to prevent overlapping */
}

/* Metadata Items */
.metadata-item {
    display: flex;
    flex-direction: column; /* Stack key and value vertically to prevent overlap */
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    word-wrap: break-word; /* Ensure long text wraps */
    overflow-wrap: break-word; /* Additional word wrapping */
}

.metadata-key {
    font-weight: 600;
    color: var(--link-color);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.metadata-value {
    color: var(--text-color);
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9rem;
}

/* LaTeX content styling */
.latex-content {
    color: var(--text-color);
    line-height: 1.6;
    font-family: 'Times New Roman', serif;
}

/* Simple list items - proper list formatting */
.metadata-list {
    color: var(--text-color);
    line-height: 1.4;
    margin: 0;
    padding-left: 1.2rem;
    list-style-type: disc; /* Add bullet points */
}

.metadata-list li {
    margin: 0.25rem 0;
    padding: 0;
    color: var(--text-color);
}

/* YAML-style formatting for metadata */
.metadata-yaml-list {
  margin: 0.5rem 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--card-bg);
  padding: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.yaml-list-item {
  color: var(--text-color);
  margin: 0.25rem 0;
  padding-left: 0;
  text-indent: 0;
}

.metadata-yaml-object {
  margin: 0.5rem 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--card-bg);
  padding: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.yaml-object-item {
  margin: 0.5rem 0;
}

.yaml-key {
  color: var(--link-color);
  font-weight: 600;
}

.yaml-value {
  color: var(--text-color);
  margin-left: 0.5rem;
}

.yaml-nested-list {
  margin: 0.25rem 0 0 1.5rem;
  border-left: 2px solid var(--border-color);
  padding-left: 0.8rem;
}

.yaml-nested-item {
  color: var(--text-color);
  margin: 0.2rem 0;
  padding-left: 0;
}

.yaml-nested-object {
  margin: 0.25rem 0 0 1.5rem;
  border-left: 2px solid var(--border-color);
  padding-left: 0.8rem;
}

/* Remove the blue box styling for tags */
.metadata-tag {
    display: inline;
    background: none;
    color: var(--text-color);
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    white-space: normal;
}

/* Simplified nested metadata */
.metadata-nested {
    background: none;
    padding: 0;
    border-radius: 0;
    border-left: none;
    color: var(--text-color);
}

.metadata-nested-item {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

/* Long text handling */
.metadata-expand {
    background: none;
    border: none;
    color: var(--link-color);
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    margin-left: 0.5rem;
    font-size: 0.85rem;
}

.metadata-expand:hover {
    color: var(--link-hover);
}

/* Links */
.metadata-value a {
    color: var(--link-color);
    text-decoration: none;
}

.metadata-value a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .metadata-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .metadata-item {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .metadata-key {
        white-space: normal;
    }
    
    .metadata-file-info {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .file-path {
        min-width: auto;
    }
}
