/* Import Excel Toolbar styles */
@import '../shared/toolbar/excel-toolbar.css';
@import '../shared/managers/layout/group-by-manager.css';

/* ============================================================================
   DOCUMENT MANAGEMENT MODULE STYLES
   Follows rfis.css pattern — all z-index overrides included
   ============================================================================ */

/* ═══════════════════════════════════════════════════════════════════════════════
   GRID MODALS & OVERLAYS — z-index !important overrides
   All ExcelGridBase modals render inside .documents-container which has overflow:hidden.
   Without position:fixed + high z-index, they clip or render behind the grid.
   ═════════════════════���═══════════════════════════���═════════════════════════════ */

/* Column Menu (3-dot dropdown) */
.documents-container .column-menu,
.documents-container .egb-column-menu {
    z-index: 99999 !important;
    position: fixed !important;
}

/* Advanced Filter Modal (funnel icon click) — keep stacking/positioning but DO NOT
   force display/visibility/opacity. The manager toggles display between 'none' and
   'block' inline; forcing those to always-visible made the modal appear on grid mount.
   See docs/PHASE-2.5-SHEET-SET-IMPORT-PLAN.md §28.10 / 2026-04-17 hotfix. */
.documents-container .advanced-filter-modal,
.advanced-filter-modal {
    z-index: 99999 !important;
    position: fixed !important;
}

/* Context Menu (right-click) */
.documents-container .context-menu,
.documents-container .egb-context-menu {
    z-index: 99999 !important;
    position: fixed !important;
}

/* Column Visibility Modal */
.documents-container .column-visibility-modal,
.documents-container .egb-column-visibility-modal {
    z-index: 99999 !important;
}

/* Conditional Format Modal */
.documents-container .conditional-format-modal {
    z-index: 99999 !important;
}

/* Column Group Modal */
.documents-container .column-group-modal {
    z-index: 99999 !important;
}

/* Search highlight overlay */
.documents-container .search-highlight {
    z-index: 5 !important;
}

/* ── Filter Row — funnel icon positioning ──────────────────────────────────── */
.documents-container .filter-row th {
    position: relative !important;
}

.documents-container .filter-row .advanced-filter-trigger {
    position: absolute !important;
    right: 6px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10 !important;
    cursor: pointer !important;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.documents-container .filter-row .advanced-filter-trigger:hover {
    opacity: 1 !important;
    color: #2563eb !important;
}

.documents-container .filter-row .advanced-filter-trigger.active {
    opacity: 1 !important;
    color: #1a73e8 !important;
    background: #e8f0fe !important;
    border-radius: 3px;
}

.documents-container .filter-row .column-filter {
    padding-right: 28px !important;
}

.documents-container .filter-row th.has-active-filter .column-filter {
    background: #e8f0fe !important;
    border-color: #1a73e8 !important;
}

/* --- Toolbar Container (Excel Toolbar) --- */
.documents-container .toolbar-container {
    display: block;
    width: 100%;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    z-index: 10000 !important;
}

.documents-header .toolbar-container .excel-toolbar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
}

/* CRITICAL: Override SearchManager's display:none rule */
.documents-header .toolbar-container .toolbar-group .search-box {
    display: flex !important;
    align-items: center !important;
    position: relative !important;
    width: auto !important;
    min-width: auto !important;
    top: auto !important;
    right: auto !important;
    z-index: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.documents-header .toolbar-container .search-box input {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 180px !important;
    height: auto !important;
    padding: 8px 12px 8px 32px !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    background: white !important;
    color: #495057 !important;
    line-height: normal !important;
    box-sizing: border-box !important;
}

.documents-header .toolbar-container .search-box i {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    left: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #6c757d !important;
    font-size: 13px !important;
    pointer-events: none !important;
}

/* --- Main Documents Container --- */
.documents-container {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
    background: #f8f9fa;
    overflow: hidden;
}

/* --- Documents Header --- */
.documents-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    background: white;
    border-bottom: 2px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
}

.documents-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #e9ecef;
}

.documents-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.documents-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.documents-actions button {
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.documents-actions .btn-primary {
    background: #2563eb;
    color: #fff;
    border: none;
}

.documents-actions .btn-primary:hover {
    background: #1d4ed8;
}

.documents-actions .doc-upload-btn,
.documents-actions .doc-export-btn,
.documents-actions .doc-settings-btn {
    background: #fff;
    border: 1px solid #dee2e6;
    color: #495057;
}

.documents-actions .doc-upload-btn:hover,
.documents-actions .doc-export-btn:hover,
.documents-actions .doc-settings-btn:hover {
    background: #f8f9fa;
    border-color: #2563eb;
    color: #2563eb;
}

/* --- View Filter Bar (pill buttons, same as RFI) --- */
.documents-view-bar {
    display: flex; gap: 2px; padding: 6px 16px; background: #fff;
    border-bottom: 1px solid #e9ecef; flex-wrap: wrap;
}
.documents-view-btn {
    padding: 5px 12px; border: 1px solid #e5e7eb; border-radius: 6px;
    background: #fff; color: #6b7280; font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 5px;
}
.documents-view-btn:hover { background: #f3f4f6; border-color: #d1d5db; color: #374151; }
.documents-view-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.documents-view-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; border-radius: 9px; font-size: 10px;
    font-weight: 700; padding: 0 4px; background: rgba(0,0,0,0.1);
}
.documents-view-btn.active .documents-view-count { background: rgba(255,255,255,0.25); }

/* --- Content Area --- */
.documents-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.documents-grid-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.documents-detail-wrapper {
    display: none;
    flex: 1;
    overflow: auto;
}

/* ============================================================================
   STATUS BADGES
   ============================================================================ */

.documents-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.documents-status-draft {
    background: #e9ecef;
    color: #495057;
}

.documents-status-inreview {
    background: #fff3cd;
    color: #856404;
}

.documents-status-approved {
    background: #d1fae5;
    color: #065f46;
}

.documents-status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.documents-status-superseded {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ============================================================================
   PAGINATION
   ============================================================================ */

.documents-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
    font-size: 12px;
    color: #495057;
}

.documents-pagination-info {
    font-size: 11px;
    color: #6c757d;
}

.documents-pagination-btns {
    display: flex;
    gap: 6px;
}

.documents-pagination-btns button {
    padding: 4px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    color: #495057;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.documents-pagination-btns button:hover:not(:disabled) {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.documents-pagination-btns button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================================
   MODAL — Create Document / Upload
   ============================================================================ */

.documents-modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,0.45) !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    z-index: 99999 !important;
    padding-top: 30px !important;
    overflow: auto !important;
}

.documents-modal-dialog {
    background: #fff !important;
    border-radius: 10px;
    padding: 20px;
    width: 580px;
    max-width: 96vw;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    z-index: 100000 !important;
    position: relative !important;
}

.documents-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.documents-modal-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #212529;
}

.documents-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.documents-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
}

/* --- Buttons --- */
.documents-btn-primary {
    padding: 6px 14px;
    border: none;
    border-radius: 5px;
    background: #2563eb;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.documents-btn-primary:hover {
    background: #1d4ed8;
}

.documents-btn-secondary {
    padding: 6px 14px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background: #fff;
    font-size: 11px;
    color: #495057;
    cursor: pointer;
}

.documents-btn-secondary:hover {
    background: #f8f9fa;
}

/* --- Form Fields --- */
.documents-form-label {
    display: block;
    font-size: 9.5px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.documents-form-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 11.5px;
    margin-bottom: 8px;
    color: #212529;
}

.documents-form-input:focus,
.documents-form-textarea:focus,
.documents-form-select:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.documents-form-textarea {
    width: 100%;
    height: 60px;
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 11.5px;
    resize: vertical;
    margin-bottom: 8px;
    color: #212529;
}

.documents-form-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 11.5px;
    margin-bottom: 8px;
    color: #212529;
    background: #fff;
}

.documents-form-row {
    display: flex;
    gap: 6px;
}

.documents-form-half {
    flex: 1;
}

/* ============================================================================
   DETAIL VIEW
   ============================================================================ */

.doc-detail-panel {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.doc-detail-info {
    width: 240px;
    flex-shrink: 0;
    padding: 12px;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    font-size: 11px;
}

.doc-detail-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.doc-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
}

.doc-detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.doc-detail-tab {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.doc-detail-tab:hover {
    color: #495057;
}

.doc-detail-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

.doc-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Info field rows */
.doc-info-field {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #e9ecef;
}

.doc-info-label {
    color: #6c757d;
}

.doc-info-value {
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

/* Per-row action icon buttons (SVG outline) */
.doc-row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}
.doc-row-action:hover { background: #e2e8f0; }
.doc-row-file svg { color: #2563eb; }
.doc-row-file:hover { background: #dbeafe; }
.doc-row-view svg { color: #6b7280; }
.doc-row-view:hover { background: #e5e7eb; }
.doc-row-delete svg { color: #dc2626; }
.doc-row-delete:hover { background: #fee2e2; }

/* Revision cards */
.doc-revision-card {
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-bottom: 6px;
    background: #fafafa;
}

.doc-revision-current {
    border: 1.5px solid #2563eb;
    background: #dbeafe;
}
