/**
 * VeraCita Financial Audit - Workpaper Navigator Styles
 */

/* ============================================
   Layout
   ============================================ */

.workpaper-navigator {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--audit-text, #1e293b);
}

/* ============================================
   Sidebar
   ============================================ */

.wpn-sidebar {
    background: white;
    border-right: 1px solid var(--audit-border, #e2e8f0);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.wpn-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--audit-border, #e2e8f0);
}

.wpn-sidebar-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.wpn-sidebar-header h2 svg {
    width: 20px;
    height: 20px;
    color: var(--audit-primary, #1a56db);
}

.wpn-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--audit-border-light, #f1f5f9);
}

.wpn-search svg {
    width: 18px;
    height: 18px;
    color: var(--audit-text-muted, #64748b);
}

.wpn-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: none;
}

.wpn-filters {
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--audit-border-light, #f1f5f9);
    flex-wrap: wrap;
}

.wpn-filters .filter-btn {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
}

.wpn-filters .filter-btn:hover {
    background: var(--audit-bg-hover, #f1f5f9);
}

.wpn-filters .filter-btn.active {
    background: var(--audit-primary, #1a56db);
    color: white;
    border-color: var(--audit-primary, #1a56db);
}

/* ============================================
   Tree View
   ============================================ */

.wpn-tree {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.tree-item {
    user-select: none;
}

.tree-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.tree-item-header:hover {
    background: var(--audit-bg-hover, #f1f5f9);
}

.tree-item.workpaper.selected .tree-item-header {
    background: var(--audit-primary, #1a56db);
    color: white;
}

.tree-item.workpaper.selected .tree-status {
    color: white !important;
}

.tree-toggle,
.tree-toggle-placeholder {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
}

.tree-item-header.expanded .tree-toggle svg {
    transform: rotate(0deg);
}

.tree-icon {
    width: 18px;
    height: 18px;
    color: var(--audit-primary, #1a56db);
}

.tree-icon svg {
    width: 100%;
    height: 100%;
}

.tree-ref {
    font-size: 12px;
    font-weight: 600;
    color: var(--audit-text-muted, #64748b);
    min-width: 40px;
}

.tree-title {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-count {
    background: var(--audit-bg, #f8fafc);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    color: var(--audit-text-muted, #64748b);
}

.tree-status {
    width: 16px;
    height: 16px;
}

.tree-status svg {
    width: 100%;
    height: 100%;
}

.tree-children,
.tree-workpapers {
    padding-left: 20px;
}

/* ============================================
   Main Content
   ============================================ */

.wpn-main {
    background: var(--audit-bg, #f8fafc);
    overflow-y: auto;
    height: 100vh;
}

/* Welcome State */
.wpn-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    color: var(--audit-border, #e2e8f0);
    margin-bottom: 20px;
}

.welcome-icon svg {
    width: 100%;
    height: 100%;
}

.wpn-welcome h2 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: var(--audit-text, #1e293b);
}

.wpn-welcome p {
    color: var(--audit-text-muted, #64748b);
    margin-bottom: 24px;
}

/* ============================================
   Viewer
   ============================================ */

.wpn-viewer {
    padding: 24px 32px;
}

.wpn-viewer-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--audit-border, #e2e8f0);
}

.viewer-title {
    flex: 1;
}

.viewer-ref {
    display: inline-block;
    padding: 4px 10px;
    background: var(--audit-primary, #1a56db);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.viewer-title h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.viewer-status {
    margin-right: auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.status-badge svg {
    width: 14px;
    height: 14px;
}

.viewer-actions {
    display: flex;
    gap: 10px;
}

.wpn-viewer-content {
    background: white;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.viewer-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--audit-border-light, #f1f5f9);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.meta-item svg {
    width: 16px;
    height: 16px;
    color: var(--audit-text-muted, #64748b);
}

.meta-label {
    color: var(--audit-text-muted, #64748b);
}

.meta-value {
    font-weight: 500;
}

.viewer-section {
    margin-bottom: 24px;
}

.viewer-section:last-child {
    margin-bottom: 0;
}

.viewer-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--audit-text-muted, #64748b);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.viewer-section h3 svg {
    width: 16px;
    height: 16px;
}

.viewer-section p,
.content-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Cross References */
.xref-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.xref-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--audit-bg, #f8fafc);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.xref-item:hover {
    background: var(--audit-bg-hover, #f1f5f9);
}

.xref-ref {
    font-weight: 600;
    color: var(--audit-primary, #1a56db);
}

.xref-desc {
    color: var(--audit-text-muted, #64748b);
    font-size: 13px;
}

/* Attachments */
.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--audit-bg, #f8fafc);
    border-radius: 6px;
    margin-bottom: 8px;
}

.attachment-item svg {
    width: 18px;
    height: 18px;
    color: var(--audit-text-muted, #64748b);
}

/* ============================================
   Viewer Footer
   ============================================ */

.wpn-viewer-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
}

.comments-section {
    background: white;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 10px;
    padding: 20px;
}

.comments-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px 0;
    font-size: 15px;
}

.comments-section h3 svg {
    width: 18px;
    height: 18px;
}

.comment-count {
    background: var(--audit-warning, #f59e0b);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.comments-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.comment-item {
    padding: 12px;
    background: var(--audit-bg, #f8fafc);
    border-radius: 8px;
    margin-bottom: 10px;
}

.comment-item.resolved {
    opacity: 0.6;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
}

.comment-date {
    font-size: 12px;
    color: var(--audit-text-muted, #64748b);
}

.comment-header .btn-icon {
    margin-left: auto;
}

.resolved-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    font-size: 11px;
    color: var(--audit-success, #10b981);
}

.resolved-badge svg {
    width: 14px;
    height: 14px;
}

.comment-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.no-comments {
    text-align: center;
    color: var(--audit-text-muted, #64748b);
    padding: 20px;
}

.add-comment {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.add-comment textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
}

.workflow-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: flex-start;
}

/* ============================================
   Editor
   ============================================ */

.wpn-editor {
    padding: 24px 32px;
}

.wpn-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.wpn-editor-header h2 {
    margin: 0;
    font-size: 20px;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.wpn-editor-content {
    background: white;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 10px;
    padding: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
}

.form-group label.required::after {
    content: ' *';
    color: var(--audit-danger, #dc2626);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 6px;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--audit-primary, #1a56db);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.ref-input {
    display: flex;
    gap: 8px;
}

.ref-input select {
    flex: 2;
}

.ref-input input {
    flex: 1;
}

.form-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--audit-border-light, #f1f5f9);
}

.form-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px 0;
    font-size: 15px;
}

.form-section h3 svg {
    width: 18px;
    height: 18px;
    color: var(--audit-primary, #1a56db);
}

.xref-editor {
    margin-bottom: 12px;
}

.xref-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.xref-row input {
    padding: 8px 10px;
    border: 1px solid var(--audit-border, #e2e8f0);
    border-radius: 4px;
    font-size: 13px;
}

.xref-row .xref-ref {
    width: 120px;
}

.xref-row .xref-desc {
    flex: 1;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--audit-primary, #1a56db);
    color: white;
}

.btn-primary:hover {
    background: var(--audit-primary-dark, #1e40af);
}

.btn-secondary {
    background: white;
    color: var(--audit-text, #1e293b);
    border: 1px solid var(--audit-border, #e2e8f0);
}

.btn-secondary:hover {
    background: var(--audit-bg-hover, #f1f5f9);
}

.btn-success {
    background: var(--audit-success, #10b981);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--audit-danger, #dc2626);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--audit-text-muted, #64748b);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--audit-bg-hover, #f1f5f9);
    color: var(--audit-primary, #1a56db);
}

.btn-icon svg {
    width: 100%;
    height: 100%;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1024px) {
    .workpaper-navigator {
        grid-template-columns: 280px 1fr;
    }

    .wpn-viewer-footer {
        grid-template-columns: 1fr;
    }

    .workflow-actions {
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .workpaper-navigator {
        grid-template-columns: 1fr;
    }

    .wpn-sidebar {
        display: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}
