/* ========================================================================
   documents.css - Two-Panel Layout, Document List, Preview, Filters
   ======================================================================== */

/* ========================================================================
   TWO-PANEL LAYOUT
   ======================================================================== */
.panels-container {
    display: flex;
    flex: 1;
    min-height: 0;
    margin-top: 8px;
    gap: 0;
}

.panel-left {
    width: 40%;
    min-width: 280px;
    background: white;
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-left-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--gray-200);
    background: white;
    flex-shrink: 0;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 11px;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 2px 0;
}

.btn-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.toolbar-divider {
    color: var(--gray-300);
    font-size: 11px;
}

.panel-left-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.panel-right {
    width: 60%;
    min-width: 320px;
    background: white;
    border: 1px solid var(--gray-200);
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================================================
   FILTER DROPDOWNS (Header)
   ======================================================================== */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-group label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
}

.filter-group select {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--gray-700);
    background: white;
    min-width: 130px;
    cursor: pointer;
}

.filter-group input[type="date"] {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--gray-700);
    background: white;
    height: 26px;
}

.filter-group input[type="date"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Searchable project dropdown */
.searchable-select {
    position: relative;
}

.searchable-select .search-input {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--gray-700);
    background: white;
    min-width: 220px;
    width: 100%;
}

.searchable-select .search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.searchable-select .hidden-select {
    display: none;
}

.search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-top: none;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
}

.search-dropdown.active {
    display: block;
}

.search-dropdown-item {
    padding: 4px 8px;
    font-size: var(--font-size-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-dropdown-item:hover {
    background: var(--primary-light);
}

.search-dropdown-item.selected {
    background: var(--primary-bg);
    font-weight: 600;
}

.search-dropdown-item .doc-count-badge {
    font-size: var(--font-size-xs);
    color: var(--gray-400);
    font-weight: 400;
}

/* ========================================================================
   FOLDER HEADERS (Collapsible)
   ======================================================================== */
.folder-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.folder-header:hover {
    background: var(--gray-100);
}

.folder-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
    color: var(--gray-500);
}

.folder-chevron.collapsed {
    transform: rotate(-90deg);
}

.folder-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--warning);
}

.folder-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    flex: 1;
}

.folder-count {
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 500;
}

.folder-contents {
    overflow: hidden;
}

.folder-contents.collapsed {
    display: none;
}

.folder-loading {
    padding: 8px 12px 8px 36px;
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
}

/* ========================================================================
   PER-FOLDER FILTER BAR
   ======================================================================== */
.folder-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 36px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

.folder-filter-bar .filter-field {
    display: flex;
    align-items: center;
    gap: 3px;
}

.folder-filter-bar .filter-field label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    white-space: nowrap;
}

.folder-filter-bar input,
.folder-filter-bar select {
    padding: 2px 6px;
    border: 1px solid var(--gray-300);
    border-radius: 0;
    font-size: 11px;
    font-family: var(--font-family);
    color: var(--gray-700);
    background: white;
    height: 22px;
}

.folder-filter-bar input:focus,
.folder-filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}

.folder-filter-bar input[type="text"] {
    width: 100px;
}

.folder-filter-bar input[type="date"] {
    width: 110px;
}

.folder-filter-bar select {
    min-width: 90px;
    max-width: 150px;
    cursor: pointer;
}

.folder-filter-bar .filter-search {
    position: relative;
}

.folder-filter-bar .filter-search input {
    width: 120px;
    padding-left: 20px;
}

.folder-filter-bar .filter-search-icon {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    color: var(--gray-400);
    pointer-events: none;
}

.folder-filter-bar .filter-clear {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 10px;
    cursor: pointer;
    padding: 2px 4px;
    font-family: var(--font-family);
}

.folder-filter-bar .filter-clear:hover {
    color: var(--danger);
}

.folder-filter-bar .filter-separator {
    width: 1px;
    height: 14px;
    background: var(--gray-300);
    margin: 0 2px;
}

/* Autocomplete dropdown for folder filters */
.filter-autocomplete {
    position: relative;
}

.filter-autocomplete input {
    width: 120px;
}

.filter-autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid var(--gray-300);
    border-top: none;
    min-width: 100%;
    max-height: 160px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.filter-autocomplete-list.open {
    display: block;
}

.filter-autocomplete-item {
    padding: 3px 6px;
    font-size: 11px;
    color: var(--gray-700);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.filter-autocomplete-item:hover,
.filter-autocomplete-item.highlighted {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.filter-autocomplete-item .match {
    font-weight: 700;
}


/* ========================================================================
   DOCUMENT ROWS
   ======================================================================== */
.doc-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 36px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: var(--transition);
}

.doc-row:hover {
    background: var(--gray-50);
}

.doc-row.selected {
    background: var(--primary-light);
}

.doc-row-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.doc-row-name {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-row-date {
    font-size: 10px;
    color: var(--gray-500);
    white-space: nowrap;
    flex-shrink: 0;
}

.doc-row-size {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-size: 10px;
    color: var(--gray-500);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 50px;
}

/* ========================================================================
   PREVIEW PANEL
   ======================================================================== */
.preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
}

.preview-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.preview-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Placeholder state */
.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--gray-400);
    padding: 24px;
    text-align: center;
}

.preview-placeholder-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
    color: var(--gray-300);
}

.preview-placeholder h3 {
    font-size: var(--font-size-md);
    color: var(--gray-500);
    margin-bottom: 4px;
    font-weight: 500;
}

.preview-placeholder p {
    font-size: var(--font-size-sm);
    color: var(--gray-400);
}

/* Generic file preview (non-previewable types) */
.preview-generic {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 24px;
    text-align: center;
    gap: 12px;
}

.preview-generic-icon {
    width: 64px;
    height: 64px;
    color: var(--gray-400);
}

.preview-generic-name {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--gray-700);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.preview-generic-size {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

.preview-generic-message {
    font-size: var(--font-size-sm);
    color: var(--gray-400);
    margin-top: 4px;
}

/* Metadata bar below preview */
.preview-metadata {
    padding: 8px 12px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.metadata-left {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.metadata-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
}

.metadata-value {
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.metadata-value.numeric {
    font-variant-numeric: tabular-nums;
}

.btn-download {
    padding: 5px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font-family);
    flex-shrink: 0;
}

.btn-download:hover {
    background: var(--primary-dark);
}

/* Error state for preview */
.preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 24px;
    text-align: center;
    color: var(--gray-500);
}

.preview-error p {
    font-size: var(--font-size-sm);
    margin-top: 8px;
}

/* ========================================================================
   NOTES ICON ON DOCUMENT ROWS
   ======================================================================== */
.doc-row-notes-btn {
    display: flex;
    align-items: center;
    gap: 2px;
    color: var(--gray-300);
    cursor: pointer;
    padding: 2px 4px;
    flex-shrink: 0;
    transition: var(--transition);
}

.doc-row-notes-btn.has-notes {
    color: var(--gray-500);
}

.doc-row-notes-btn:hover {
    color: var(--primary);
}

.doc-row-notes-btn svg {
    width: 14px;
    height: 14px;
}

.doc-row-notes-count {
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
}

/* ========================================================================
   PREVIEW NOTES SECTION
   ======================================================================== */
.preview-notes {
    max-height: 200px;
    border-top: 1px solid var(--gray-200);
    background: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.preview-notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    cursor: pointer;
    user-select: none;
    background: var(--gray-50);
}

.preview-notes-header:hover {
    background: var(--gray-100);
}

.preview-notes-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}

.preview-notes-chevron {
    width: 12px;
    height: 12px;
    color: var(--gray-400);
    transition: transform 0.15s ease;
}

.preview-notes-chevron.collapsed {
    transform: rotate(-90deg);
}

.preview-notes-list {
    overflow-y: auto;
    max-height: 150px;
}

.preview-notes-list.collapsed {
    display: none;
}

.preview-notes-empty {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
}

.preview-note-item {
    padding: 4px 12px;
    border-bottom: 1px solid var(--gray-100);
}

.preview-note-item:last-child {
    border-bottom: none;
}

.preview-note-meta {
    font-size: 10px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.preview-note-text {
    font-size: 11px;
    color: var(--gray-700);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-top: 2px;
}

/* ========================================================================
   EMAIL SENT BADGES
   ======================================================================== */
.note-sent-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 500;
    color: var(--info);
    background: var(--info-light);
    cursor: default;
}

.note-sent-badge svg {
    flex-shrink: 0;
}

.note-sent-badge-small {
    display: inline-flex;
    align-items: center;
    color: var(--info);
    cursor: default;
}

/* ========================================================================
   NOTES MODAL
   ======================================================================== */
.notes-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.notes-modal.active {
    display: flex;
}

.notes-modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-300);
}

.notes-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    flex-shrink: 0;
}

.notes-modal-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 40px);
}

.notes-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    font-family: var(--font-family);
}

.notes-modal-close:hover {
    color: var(--gray-700);
}

.notes-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
}

.notes-modal-add-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.notes-modal-add-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}

.notes-modal-add-form textarea {
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--gray-700);
    resize: vertical;
    min-height: 60px;
}

.notes-modal-add-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.notes-modal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.notes-modal-actions .btn {
    padding: 5px 14px;
    font-size: var(--font-size-sm);
}

.notes-modal-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================================================
   EMAIL SECTION IN NOTES MODAL
   ======================================================================== */
.notes-email-section {
    margin-top: 4px;
}

.notes-email-toggle {
    cursor: pointer;
    user-select: none;
}

.notes-email-toggle-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    transition: var(--transition);
}

.notes-email-toggle-header:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.notes-email-toggle-header svg {
    flex-shrink: 0;
}

.notes-email-chevron {
    width: 12px;
    height: 12px;
    margin-left: auto;
    transition: transform 0.15s ease;
    transform: rotate(-90deg);
}

.notes-email-chevron.expanded {
    transform: rotate(0deg);
}

.notes-email-recipients {
    border: 1px solid var(--gray-200);
    border-top: none;
    padding: 8px 10px;
    background: white;
}

.notes-email-project-select {
    margin-bottom: 8px;
}

.notes-email-field-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 3px;
}

.notes-email-project-select select {
    padding: 3px 6px;
    border: 1px solid var(--gray-300);
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--gray-700);
    background: white;
    width: 100%;
}

.notes-email-project-select select:focus {
    outline: none;
    border-color: var(--primary);
}

.notes-email-recipient {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    cursor: pointer;
    font-size: 11px;
    color: var(--gray-700);
}

.notes-email-recipient:hover {
    color: var(--gray-900);
}

.notes-email-recipient input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

.notes-email-recipient-text {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    min-width: 0;
}

.notes-email-role-label {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 10px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.notes-email-recipient-name {
    font-weight: 500;
}

.notes-email-recipient-email {
    color: var(--gray-400);
    font-size: 10px;
}

.notes-email-members-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 6px 0;
}

.notes-email-members-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.notes-email-error {
    font-size: 11px;
    color: var(--danger);
    padding: 4px 0;
    font-style: italic;
}

.notes-modal-divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 10px 0;
}

.notes-modal-list {
    flex: 1;
    overflow-y: auto;
}

.notes-modal-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.notes-modal-item:last-child {
    border-bottom: none;
}

.notes-modal-item-header {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.notes-modal-item-author {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
}

.notes-modal-item-dot {
    font-size: 11px;
    color: var(--gray-400);
}

.notes-modal-item-date {
    font-size: 10px;
    color: var(--gray-400);
}

.notes-modal-item-body {
    font-size: 11px;
    color: var(--gray-700);
    line-height: 1.4;
    margin-top: 3px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.notes-modal-empty {
    padding: 16px 0;
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--gray-400);
    font-style: italic;
}

/* ========================================================================
   DOCID FLASH ANIMATION
   ======================================================================== */
@keyframes docRowFlash {
    0% { background: var(--primary-light); }
    100% { background: transparent; }
}

.doc-row-flash {
    animation: docRowFlash 1.5s ease-out;
}

.doc-row-flash.selected {
    animation: none;
    background: var(--primary-light);
}
