/**
 * Document Generator Modal Styles
 * Styles for the document generation modal and preview
 */

/* Modal Container */
#document-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Modal Content */
.document-modal-content {
    background: var(--cream);
    border-radius: 8px;
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Modal Header */
.document-modal-header {
    padding: 20px 30px;
    background: var(--dark-gray);
    color: var(--cream);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--medium-gray);
    gap: 20px;
}

.document-modal-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.document-modal-title .material-symbols-outlined {
    font-size: 24px;
}

.document-modal-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.document-root-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.document-root-select {
    padding: 6px 12px;
    border: 1px solid var(--medium-gray);
    border-radius: 4px;
    background: var(--cream);
    color: var(--dark-gray);
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
    max-width: 400px;
}

.document-root-select:hover {
    border-color: var(--blue);
}

.document-root-select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.document-modal-actions {
    display: flex;
    gap: 10px;
}

.document-modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.document-modal-btn .material-symbols-outlined {
    font-size: 18px;
}

.document-modal-btn-primary {
    background: var(--blue);
    color: white;
}

.document-modal-btn-primary:hover {
    background: #1e40af;
}

.document-modal-btn-secondary {
    background: var(--medium-gray);
    color: var(--cream);
}

.document-modal-btn-secondary:hover {
    background: var(--dark-gray);
}

.document-modal-btn-close {
    background: transparent;
    color: var(--cream);
    padding: 8px;
}

.document-modal-btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Modal Body - Preview Container */
.document-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: white;
}

#document-preview {
    max-width: 1200px;
    margin: 0 auto;
}

/* Document Preview Styles */
#document-preview .document-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--dark-gray);
}

#document-preview .document-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--dark-gray);
}

#document-preview .document-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #666;
}

#document-preview .document-date {
    font-weight: 500;
}

#document-preview .document-filters {
    font-style: italic;
    color: var(--blue);
}

/* Statistics */
#document-preview .document-stats {
    margin-bottom: 30px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

#document-preview .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

#document-preview .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e5e5e5;
}

#document-preview .stat-label {
    font-weight: 500;
    color: #555;
}

#document-preview .stat-value {
    font-weight: 700;
    color: var(--dark-gray);
}

#document-preview .stat-new {
    color: #888;
}

#document-preview .stat-open {
    color: var(--blue);
}

#document-preview .stat-closed {
    color: #000;
}

/* Table of Contents */
#document-preview .document-toc {
    margin-bottom: 40px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

#document-preview .document-toc h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--dark-gray);
}

#document-preview .toc-list {
    list-style: none;
    margin-left: 0;
}

#document-preview .toc-item {
    margin: 5px 0;
}

#document-preview .toc-level-1 { margin-left: 0; }
#document-preview .toc-level-2 { margin-left: 20px; }
#document-preview .toc-level-3 { margin-left: 40px; }
#document-preview .toc-level-4 { margin-left: 60px; }
#document-preview .toc-level-5 { margin-left: 80px; }

#document-preview .toc-link {
    color: var(--blue);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
    transition: color 0.2s;
}

#document-preview .toc-link:hover {
    color: #1e40af;
    text-decoration: underline;
}

#document-preview .toc-empty {
    color: #999;
    font-style: italic;
}

/* Content - Google Docs Style */
#document-preview .document-content {
    margin-bottom: 40px;
}

/* Numbered Lists */
#document-preview .doc-list {
    list-style: none;
    counter-reset: item;
    padding-left: 0;
    margin: 0;
}

#document-preview .doc-list-root {
    padding-left: 0;
}

#document-preview .doc-list .doc-list {
    padding-left: 30px;
    margin-top: 8px;
}

/* List Items */
#document-preview .doc-item {
    margin-bottom: 16px;
}

#document-preview .doc-item:target {
    background: #fffbeb;
    padding: 8px;
    margin-left: -8px;
    margin-right: -8px;
    border-radius: 4px;
}

/* Item Wrapper - Number + Content */
#document-preview .doc-item-wrapper {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#document-preview .doc-number {
    color: #5f6368;
    font-weight: 500;
    flex-shrink: 0;
    line-height: 1.4;
}

#document-preview .doc-item-content {
    flex: 1;
    min-width: 0;
}

/* Headings - Google Docs style hierarchy */
#document-preview .doc-heading {
    margin: 0 0 8px 0;
    color: #202124;
    font-weight: 400;
    line-height: 1.4;
}

#document-preview .doc-level-1 .doc-number {
    font-size: 28px;
}

#document-preview .doc-level-1 .doc-heading {
    font-size: 28px;
    font-weight: 500;
    margin-top: 24px;
    margin-bottom: 12px;
}

#document-preview .doc-level-2 .doc-number {
    font-size: 24px;
}

#document-preview .doc-level-2 .doc-heading {
    font-size: 24px;
    font-weight: 500;
    margin-top: 20px;
    margin-bottom: 10px;
}

#document-preview .doc-level-3 .doc-number {
    font-size: 20px;
}

#document-preview .doc-level-3 .doc-heading {
    font-size: 20px;
    font-weight: 500;
    margin-top: 16px;
    margin-bottom: 8px;
}

#document-preview .doc-level-4 .doc-number {
    font-size: 18px;
}

#document-preview .doc-level-4 .doc-heading {
    font-size: 18px;
    font-weight: 500;
    margin-top: 14px;
    margin-bottom: 6px;
}

#document-preview .doc-level-5 .doc-number {
    font-size: 16px;
}

#document-preview .doc-level-5 .doc-heading {
    font-size: 16px;
    font-weight: 500;
    margin-top: 12px;
    margin-bottom: 6px;
}

#document-preview .doc-level-6 .doc-number {
    font-size: 14px;
}

#document-preview .doc-level-6 .doc-heading {
    font-size: 14px;
    font-weight: 500;
    margin-top: 10px;
    margin-bottom: 6px;
}

/* Task Paragraphs */
#document-preview .doc-task {
    margin: 0 0 8px 0;
    color: #202124;
    font-size: 16px;
    line-height: 1.6;
}

#document-preview .doc-task strong {
    font-weight: 600;
}

/* Task number inherits from parent level, fallback to 16px */
#document-preview .doc-item-task .doc-number {
    font-size: 16px;
}

/* Description - Regular paragraph style */
#document-preview .doc-description {
    font-size: 14px;
    line-height: 1.6;
    color: #3c4043;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

/* Tags */
#document-preview .doc-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

#document-preview .doc-tag {
    padding: 3px 10px;
    background: var(--blue);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Status Circles (like canvas) */
#document-preview .status-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    margin-right: 6px;
    flex-shrink: 0;
    line-height: 1;
}

#document-preview .status-new {
    background: #e5e5e5;
    color: #666;
    border: 1px solid #ccc;
}

#document-preview .status-open {
    background: #2563eb;
    color: #fff;
    border: 1px solid #1e40af;
}

#document-preview .status-closed {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

#document-preview .content-empty {
    color: #999;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

/* Connections */
#document-preview .document-connections {
    margin-bottom: 40px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

#document-preview .document-connections h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--dark-gray);
}

#document-preview .connections-list {
    list-style: none;
}

#document-preview .connection-item {
    margin: 8px 0;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 10px;
}

#document-preview .connection-number {
    font-weight: 600;
    color: #666;
    min-width: 30px;
}

#document-preview .connection-link {
    color: var(--blue);
    text-decoration: none;
}

#document-preview .connection-link:hover {
    text-decoration: underline;
}

#document-preview .connection-arrow {
    color: #999;
    font-weight: 700;
}

/* Scrollbar Styling */
.document-modal-body::-webkit-scrollbar {
    width: 12px;
}

.document-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.document-modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.document-modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .document-modal-content {
        width: 95%;
        height: 95vh;
    }

    .document-modal-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .document-modal-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .document-root-select {
        width: 100%;
        max-width: none;
    }

    .document-modal-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .document-modal-body {
        padding: 20px;
    }

    #document-preview .document-title {
        font-size: 24px;
    }

    #document-preview .stats-grid {
        grid-template-columns: 1fr;
    }

    #document-preview .content-level-2,
    #document-preview .content-level-3,
    #document-preview .content-level-4,
    #document-preview .content-level-5 {
        margin-left: 10px;
    }

    #document-preview .detail-row {
        flex-direction: column;
        gap: 5px;
    }

    #document-preview .detail-label {
        min-width: auto;
    }
}

/* Print Styles */
@media print {
    #document-modal {
        background: white;
        padding: 0;
    }

    .document-modal-header,
    .document-modal-btn {
        display: none !important;
    }

    .document-modal-content {
        width: 100%;
        height: auto;
        max-width: none;
        box-shadow: none;
    }

    .document-modal-body {
        padding: 0;
    }

    #document-preview .content-node {
        page-break-inside: avoid;
    }
}
