/**
 * JBA Admin Dashboard - Advanced Component Styles
 *
 * Styles for modal, data-table, form-field, and other advanced components
 */

/* ============================================================================
   Modal Component
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-dialog {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s ease;
    width: 100%;
}

.modal-dialog.show {
    transform: scale(1);
    opacity: 1;
}

/* Modal Sizes */
.modal-small {
    max-width: 400px;
}

.modal-medium {
    max-width: 600px;
}

.modal-large {
    max-width: 900px;
}

.modal-full {
    max-width: 95vw;
    max-height: 95vh;
}

.modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Modal Error Display */
.modal-error {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.modal-error.show {
    max-height: 100px;
    opacity: 1;
}

.modal-error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: var(--danger-bg, #fef2f2);
    border-bottom: 1px solid var(--danger-border, #fecaca);
    color: var(--danger-text, #991b1b);
    font-size: 0.875rem;
}

.modal-error-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: currentColor;
}

.modal-error-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: var(--danger-text, #991b1b);
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0;
}

.modal-error-dismiss:hover {
    opacity: 1;
}

/* Modal Button Loading State */
.modal-footer .btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.modal-footer .btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.modal-btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: modal-spinner 0.75s linear infinite;
}

.modal-btn-text {
    display: inline-block;
}

@keyframes modal-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Modal Shake Animation for Errors */
.modal-dialog.shake {
    animation: modal-shake 0.5s ease;
}

@keyframes modal-shake {
    0%, 100% { transform: translateX(0) scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px) scale(1); }
    20%, 40%, 60%, 80% { transform: translateX(5px) scale(1); }
}

/* Modal Close Button Disabled State */
.modal-close:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================================
   Data Table Component
   ============================================================================ */

.data-table-container {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.table-search {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.table-search input {
    width: 100%;
}

.table-bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-search-spacer {
    flex: 1;
}

/* Export Dropdown */
.table-export-dropdown {
    position: relative;
}

.export-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600);
    background: transparent;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.export-dropdown-toggle:hover {
    color: var(--gray-700);
    border-color: var(--gray-400);
    background: var(--gray-50);
}

.export-dropdown-toggle .dropdown-arrow {
    width: 10px;
    height: 10px;
    transition: transform 0.2s;
}

.export-dropdown-toggle .spinner-sm {
    width: 12px;
    height: 12px;
    border: 1.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.export-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 120px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.export-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.export-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: none;
    font-size: 0.75rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.export-dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.export-dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.export-dropdown-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.export-dropdown-item svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--gray-400);
}

.export-dropdown-item:hover svg {
    color: var(--primary);
}

/* Dark mode support */
[data-theme="dark"] .export-dropdown-toggle {
    color: var(--gray-400);
    border-color: var(--gray-600);
}

[data-theme="dark"] .export-dropdown-toggle:hover {
    color: var(--gray-300);
    border-color: var(--gray-500);
    background: var(--gray-800);
}

[data-theme="dark"] .export-dropdown-menu {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] .export-dropdown-item {
    color: var(--gray-300);
}

[data-theme="dark"] .export-dropdown-item:hover {
    background: var(--gray-700);
    color: var(--gray-100);
}

[data-theme="dark"] .export-dropdown-item svg {
    color: var(--gray-500);
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--border-color);
}

.table-header-cell {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table-header-cell.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.table-header-cell.sortable:hover {
    background: var(--gray-100);
}

.table-header-cell .sort-icon {
    color: var(--text-light);
    margin-left: 0.25rem;
    font-size: 0.75rem;
}

.table-header-cell .sort-icon.active {
    color: var(--primary-color);
}

.table-cell-checkbox {
    width: 40px;
    text-align: center;
    padding: 0.75rem 0.5rem;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr.selected {
    background: var(--danger-light);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

.table-cell {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-light);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.page-size-selector select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
}

.pagination-buttons {
    display: flex;
    gap: 0.25rem;
}

/* Data Table Mobile Responsive */
@media (max-width: 768px) {
    .table-search {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .table-pagination {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    /* Card layout for data tables */
    .data-table-container:not([data-no-card]) {
        overflow: visible;
    }

    .data-table-container:not([data-no-card]) .table-wrapper {
        overflow: visible;
    }

    .data-table-container:not([data-no-card]) .data-table {
        display: block;
        width: 100%;
    }

    .data-table-container:not([data-no-card]) .data-table thead {
        display: none;
    }

    .data-table-container:not([data-no-card]) .data-table tbody {
        display: block;
    }

    .data-table-container:not([data-no-card]) .data-table tbody tr {
        display: block;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 12px 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        position: relative;
        overflow: visible;
        background: var(--card-bg, var(--bg-primary, #fff));
    }

    .data-table-container:not([data-no-card]) .data-table tbody tr:hover {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    }

    .data-table-container:not([data-no-card]) .table-cell {
        display: block;
        padding: 4px 0;
        text-align: left !important;
        border: none;
    }

    .data-table-container:not([data-no-card]) .table-cell::before {
        content: attr(data-label);
        display: inline-block;
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        color: var(--text-secondary, #6b7280);
        min-width: 120px;
        margin-right: 8px;
    }

    .data-table-container:not([data-no-card]) .table-cell[data-label=""]::before,
    .data-table-container:not([data-no-card]) .table-cell:not([data-label])::before {
        display: none;
    }

    .data-table-container:not([data-no-card]) .table-cell-checkbox {
        position: absolute;
        top: 12px;
        right: 12px;
        padding: 0;
        border: none;
    }

    .data-table-container:not([data-no-card]) .table-cell-checkbox::before {
        display: none;
    }

    .data-table-container:not([data-no-card]) .table-cell .action-buttons,
    .data-table-container:not([data-no-card]) .table-cell[data-key="actions"] {
        padding-top: 8px;
        border-top: 1px solid var(--border-color);
        margin-top: 4px;
    }

    .data-table-container:not([data-no-card]) .table-cell[data-key="actions"]::before {
        display: none;
    }

    .data-table-container:not([data-no-card]) .table-cell .action-buttons {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .data-table-container:not([data-no-card]) .dropdown-container {
        position: static !important;
    }

    .data-table-container:not([data-no-card]) .dropdown-menu {
        right: 12px;
        left: auto;
    }
}

/* ============================================================================
   Form Field Component
   ============================================================================ */

.form-field {
    margin-bottom: 1rem;
}

.form-field.has-error .form-input,
.form-field.has-error .form-select,
.form-field.has-error .form-textarea {
    border-color: var(--danger);
}

.form-field.has-error .form-label {
    color: var(--danger);
}

.form-field.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.form-input,
.form-control,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-dark);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

.form-input:focus,
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--sidebar-item-active-bg);
}

.form-input.error,
.form-control.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger);
}

.form-input::placeholder,
.form-control::placeholder {
    color: var(--text-light);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-checkbox,
.form-radio {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-dark);
    cursor: pointer;
    user-select: none;
}

.checkbox-label:hover,
.radio-label:hover {
    color: var(--text-dark);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-help-text {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.field-error {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 500;
}

/* ============================================================================
   Toast Notifications (Enhanced)
   ============================================================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid;
    transform: translateX(calc(100% + 2rem));
    transition: all 0.3s ease;
    animation: slideInRight 0.3s ease forwards;
}

@keyframes slideInRight {
    to {
        transform: translateX(0);
    }
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: #f59e0b;
}

.toast-info {
    border-left-color: #3b82f6;
}

.toast-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-dark);
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.toast-close:hover {
    color: var(--text-dark);
}

/* ============================================================================
   Loading Spinner (Enhanced)
   ============================================================================ */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-100);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* ============================================================================
   View Component Styles (Reset padding for all views)
   ============================================================================ */

.members-view,
.newsletters-view,
.tickets-view,
.settings-view,
.users-view,
.volunteers-view,
.reports-view,
.documents-view,
.forms-view,
.pending-approvals-view,
.guests-view,
.library-dashboard,
.library-books,
.library-loans,
.library-book-detail,
.library-book-form,
.library-checkin,
.library-checkout,
.library-settings {
    padding: 0 !important;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.page-header p {
    margin: 0.25rem 0 0;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-card-clickable {
    cursor: pointer;
    position: relative;
}

.stat-card-clickable:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.stat-card-clickable:active {
    transform: translateY(0);
}

.stat-card-clickable.stat-card-active {
    border-color: var(--primary-color);
    border-width: 2px;
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--gray-50) 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card-clickable.stat-card-active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: bold;
}

/* Dashboard stat card links */
.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.stat-card-link:active {
    transform: translateY(0);
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* View Header */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.view-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0 0;
}

.view-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .view-header {
        flex-direction: column;
        align-items: stretch;
    }

    .view-actions {
        flex-direction: column;
    }

    .view-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .view-title {
        font-size: 1.375rem;
    }
}

/* Stats Grid (Forms View) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.stats-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stats-card-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--border-radius-md);
}

.stats-card-content {
    flex: 1;
}

.stats-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.stats-card-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.filters-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

/* Flexbox utilities */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

/* Grid utilities */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Spacing utilities */
.space-y-4 > * + * {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mr-auto {
    margin-right: auto;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.font-mono {
    font-family: ui-monospace, monospace;
}

/* Color utilities */
.text-gray-500 {
    color: var(--text-light);
}

.text-gray-600 {
    color: var(--text-dark);
}

.text-gray-700 {
    color: var(--text-dark);
}

.text-gray-900 {
    color: var(--text-dark);
}

.text-red-500 {
    color: var(--danger);
}

.text-red-600 {
    color: #dc2626;
}

.text-red-900 {
    color: #7f1d1d;
}

.text-green-600 {
    color: #16a34a;
}

.text-green-800 {
    color: #166534;
}

.text-blue-600 {
    color: #2563eb;
}

.text-yellow-800 {
    color: #854d0e;
}

.text-purple-600 {
    color: #9333ea;
}

/* Background utilities */
.bg-green-100 {
    background-color: #dcfce7;
}

.bg-red-50 {
    background-color: #fef2f2;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.bg-yellow-100 {
    background-color: #fef3c7;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

/* Border utilities */
.border {
    border-width: 1px;
}

.border-red-200 {
    border-color: #fecaca;
}

.rounded {
    border-radius: 0.25rem;
}

.rounded-text {
    border-radius: 0.125rem;
}

/* Layout utilities */
.p-3 {
    padding: 0.75rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* Responsive utilities */
@media (min-width: 768px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .modal-dialog {
        margin: 1rem;
    }

    .modal-large,
    .modal-full {
        max-width: 100%;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .table-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-controls {
        flex-direction: column;
    }

    .pagination-buttons {
        flex-wrap: wrap;
    }
}

/* ============================================================================
   Button Variants (Enhanced)
   ============================================================================ */

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1.125rem;
}

.btn-outline-primary {
    background: var(--card-bg);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
}

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

.btn-warning {
    background: var(--warning);
    color: white;
    border: none;
}

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

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
}

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

/* ============================================================================
   Dropdown Menu
   ============================================================================ */

.dropdown-container {
    position: relative;
    display: inline-block;
}

/* Action button (three dots) */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--gray-500);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    color: var(--gray-700);
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.action-btn:active {
    background: var(--gray-200);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 130px;
    margin-top: 4px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.75rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s;
}

.dropdown-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.dropdown-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--gray-400);
}

.dropdown-item:hover svg {
    color: var(--primary);
}

.dropdown-item-danger {
    color: var(--danger);
}

.dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.dropdown-item-danger svg {
    color: var(--danger);
}

/* Dark mode for dropdowns */
[data-theme="dark"] .action-btn {
    color: var(--gray-400);
}

[data-theme="dark"] .action-btn:hover {
    color: var(--gray-300);
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] .dropdown-item {
    color: var(--gray-300);
}

[data-theme="dark"] .dropdown-item:hover {
    background: var(--gray-700);
    color: var(--gray-100);
}

[data-theme="dark"] .dropdown-item svg {
    color: var(--gray-500);
}

/* ============================================================================
   Dark Mode Support (Optional)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}

/* ============================================================================
   Form Builder Styles
   ============================================================================ */

.form-builder-view {
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
}

.builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.builder-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.builder-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.builder-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-dark);
}

.builder-content {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    gap: 0;
    overflow: hidden;
}

/* Field Palette */
.field-palette {
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
}

.palette-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--text-dark);
}

.palette-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1.5rem 0;
}

.palette-category {
    margin-bottom: 1.5rem;
}

.palette-category-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.75rem 0;
}

.palette-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-type-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.field-type-btn:hover {
    background: var(--gray-100);
    border-color: var(--primary-color);
}

.field-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    color: var(--text-muted);
}

.field-type-icon svg {
    width: 18px;
    height: 18px;
}

.field-type-label {
    font-size: 0.875rem;
    color: var(--text-dark);
}

/* Form Canvas Container */
.form-canvas-container {
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
    overflow: hidden;
}

.canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.canvas-tabs {
    display: flex;
    gap: 0.5rem;
}

.canvas-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.canvas-tab:hover {
    background: var(--gray-100);
    color: var(--text-dark);
}

.canvas-tab.active {
    background: var(--primary-color);
    color: white;
}

.canvas-actions {
    display: flex;
    gap: 0.5rem;
}

/* Form Canvas */
.form-canvas {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 300px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    align-content: start;
}

/* Field Width Classes - Builder Canvas (6-column grid) */
/* Default: all field cards span full width */
.field-card {
    grid-column: span 6;
}

.field-card.width-full {
    grid-column: span 6;
}

.field-card.width-two-thirds {
    grid-column: span 4;
}

.field-card.width-half {
    grid-column: span 3;
}

.field-card.width-third {
    grid-column: span 2;
}

/* Width indicator badge */
.field-width-badge {
    font-size: 0.625rem;
    color: var(--text-muted);
    background: var(--gray-200);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-width-badge.two-thirds {
    background: var(--info-bg);
    color: var(--info);
}

.field-width-badge.half {
    background: var(--primary-bg);
    color: var(--primary-color);
}

.field-width-badge.third {
    background: var(--success-bg);
    color: var(--success);
}

@media (max-width: 900px) {
    .form-canvas {
        grid-template-columns: repeat(2, 1fr);
    }

    .field-card.width-full,
    .field-card.width-two-thirds {
        grid-column: span 2;
    }

    .field-card.width-half,
    .field-card.width-third {
        grid-column: span 1;
    }
}

@media (max-width: 600px) {
    .form-canvas {
        grid-template-columns: 1fr;
    }

    .field-card.width-full,
    .field-card.width-two-thirds,
    .field-card.width-half,
    .field-card.width-third {
        grid-column: span 1;
    }
}

.canvas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
    color: var(--text-muted);
    grid-column: span 6;
}

.canvas-empty .empty-icon {
    margin-bottom: 1rem;
    line-height: 0;
}

.canvas-empty h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.canvas-empty p {
    margin: 0;
}

/* Field Card */
.field-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: var(--border-radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.field-card:hover {
    border-color: var(--border-color);
}

.field-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--sidebar-item-active-bg);
}

.field-card.field-ghost {
    opacity: 0.4;
    background: var(--gray-100);
}

.field-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 0.5rem;
    font-size: 1.2rem;
    letter-spacing: -3px;
    user-select: none;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.field-handle:hover {
    opacity: 1;
    color: var(--primary);
}

.field-handle:active {
    cursor: grabbing;
}

.field-content {
    flex: 1;
}

.field-label {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.required-badge {
    color: var(--danger);
    margin-left: 0.25rem;
}

.field-type-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--gray-100);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.field-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.field-delete-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all 0.15s ease;
}

.field-delete-btn:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Config Panel */
.config-panel {
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
}

.config-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
    color: var(--text-dark);
}

.config-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    color: var(--text-muted);
}

.config-empty .empty-icon {
    margin-bottom: 1rem;
    line-height: 0;
}

.config-empty h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
    font-size: 1rem;
}

.config-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.config-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.config-section:last-child {
    border-bottom: none;
}

.config-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
}

.config-actions {
    margin-top: 1rem;
}

/* Option Rows */
.option-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.option-input {
    flex: 1;
}

/* Config Panel Header & Toggle */
.config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--gray-50);
    margin: -1rem -1rem 1rem -1rem;
}

.config-header-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
}

.config-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--border-radius-md);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.config-toggle-btn:hover {
    background: var(--gray-200);
    color: var(--text-dark);
    border-color: var(--gray-300);
}

.config-toggle-btn svg {
    flex-shrink: 0;
}

.config-panel {
    position: relative;
}

.config-panel-collapsed {
    width: 48px !important;
    min-width: 48px !important;
    padding: 0.75rem 0.5rem !important;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.config-panel-collapsed .config-toggle-btn {
    width: 32px;
    height: 32px;
}

/* Adjust grid when config panel is collapsed */
.builder-content:has(.config-panel-collapsed) {
    grid-template-columns: 260px 1fr 48px;
}

/* Settings Panel */
.form-settings-panel {
    padding: 1.5rem;
    overflow-y: auto;
}

.settings-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.settings-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.settings-section .section-header h2,
.settings-section .section-header h3 {
    margin: 0;
}

.settings-section .section-header p {
    margin: 0.25rem 0 0 0;
}

.settings-section .section-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.settings-section--narrow {
    max-width: 600px;
}

.settings-section--medium {
    max-width: 800px;
}

.settings-section data-table {
    overflow-x: auto;
}

.settings-section table {
    min-width: 0;
}

.settings-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--text-dark);
}

@media (max-width: 768px) {
    .settings-section {
        padding: 1rem;
    }

    .settings-section--narrow,
    .settings-section--medium {
        max-width: none;
    }

    .settings-section .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-section .section-header .btn {
        align-self: flex-start;
    }

    .settings-section .section-header-actions {
        flex-wrap: wrap;
    }

    .settings-section .fee-types-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .settings-section {
        padding: 0.75rem;
        border-radius: var(--border-radius);
    }

    .settings-section .section-header .btn,
    .settings-section .section-header-actions .btn {
        width: 100%;
    }

    .settings-section .section-header-actions {
        flex-direction: column;
        width: 100%;
    }
}

.settings-actions {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

/* Bilingual Input Styles */
.bilingual-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bilingual-input {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.bilingual-input .lang-label {
    flex-shrink: 0;
    width: 28px;
    padding: 8px 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.bilingual-input .form-input {
    flex: 1;
}

.bilingual-input.ja-input .form-input {
    font-family: 'Noto Sans JP', sans-serif;
}

.bilingual-toggle {
    background: rgba(var(--primary-rgb), 0.05);
    padding: 12px;
    border-radius: var(--border-radius-md);
    margin-bottom: 16px;
    border: 1px solid rgba(var(--primary-rgb), 0.1);
}

.bilingual-toggle .checkbox-label {
    font-weight: 500;
}

.bilingual-toggle .form-help {
    margin-left: 24px;
    margin-top: 4px;
}

/* Options Editor - Bilingual */
.options-header {
    display: grid;
    grid-template-columns: 1fr 1fr 32px;
    gap: 8px;
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.options-col-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.option-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.option-row.bilingual {
    display: grid;
    grid-template-columns: 1fr 1fr 32px;
}

.option-row .option-input,
.option-row .option-input-ja {
    flex: 1;
}

.option-row .option-input-ja {
    font-family: 'Noto Sans JP', sans-serif;
}

/* Preview Panel */
.form-preview-panel {
    padding: 1.5rem;
    overflow-y: auto;
}

.preview-container {
    max-width: 640px;
    margin: 0 auto;
}

.preview-form {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
}

/* Preview Fields Grid (6-column grid) */
.preview-fields-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0 1.25rem;
}

/* Field Width Classes - Preview */
/* Default: all preview fields span full width */
.preview-field,
.preview-section,
.preview-paragraph {
    grid-column: span 6;
}

.preview-field.width-full,
.preview-section.width-full,
.preview-paragraph.width-full {
    grid-column: span 6;
}

.preview-field.width-two-thirds,
.preview-section.width-two-thirds,
.preview-paragraph.width-two-thirds {
    grid-column: span 4;
}

.preview-field.width-half,
.preview-section.width-half,
.preview-paragraph.width-half {
    grid-column: span 3;
}

.preview-field.width-third,
.preview-section.width-third,
.preview-paragraph.width-third {
    grid-column: span 2;
}

@media (max-width: 600px) {
    .preview-fields-grid {
        grid-template-columns: 1fr;
    }

    .preview-field.width-full,
    .preview-field.width-two-thirds,
    .preview-field.width-half,
    .preview-field.width-third,
    .preview-section.width-full,
    .preview-section.width-two-thirds,
    .preview-section.width-half,
    .preview-section.width-third,
    .preview-paragraph.width-full,
    .preview-paragraph.width-two-thirds,
    .preview-paragraph.width-half,
    .preview-paragraph.width-third {
        grid-column: span 1;
    }
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.preview-description {
    color: var(--text-muted);
    margin: 0 0 2rem 0;
}

.preview-field {
    margin-bottom: 1.5rem;
}

.preview-section {
    margin: 2rem 0 1rem 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.preview-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.preview-paragraph {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.preview-submit {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Signature Pad */
.signature-pad-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--white);
    overflow: hidden;
}

.signature-canvas {
    display: block;
    width: 100%;
    height: 150px;
    cursor: crosshair;
    touch-action: none;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--border-color);
}

/* Rating Stars */
.rating-stars {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rating-stars .star {
    font-size: 1.75rem;
    color: var(--gray-300);
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
    user-select: none;
}

.rating-stars .star:hover,
.rating-stars .star.hover {
    color: #fbbf24;
    transform: scale(1.1);
}

.rating-stars .star.active {
    color: #f59e0b;
}

.rating-stars .star.active:hover,
.rating-stars .star.active.hover {
    color: #d97706;
}

/* Address Field */
.address-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.address-row {
    display: flex;
    gap: 0.5rem;
}

.address-row input {
    flex: 1;
}

.address-row-split input {
    flex: 1;
}

/* Checkbox and Radio Labels */
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0;
}

.checkbox-label input,
.radio-label input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1200px) {
    .builder-content {
        grid-template-columns: 220px 1fr 280px;
    }
}

@media (max-width: 992px) {
    .builder-content {
        grid-template-columns: 1fr;
    }

    .field-palette,
    .config-panel {
        display: none;
    }
}

/* ============================================================================
   Ticket Attachment Styles
   ============================================================================ */

/* Message attachments section */
.message-attachments {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.attachments-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.attachments-header svg {
    stroke: var(--text-light);
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-100);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.attachment-item:hover {
    background: var(--gray-200);
    text-decoration: none;
    color: var(--text-dark);
}

.attachment-icon svg {
    stroke: var(--text-light);
}

.attachment-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    color: var(--text-light);
    font-size: 0.75rem;
}

/* Source badge in ticket list */
.source-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.25rem;
    font-size: 0.75rem;
    vertical-align: middle;
}

.source-badge.email {
    color: var(--primary);
}

/* External sender styling in ticket detail */
.member-card.external-sender {
    border-left: 3px solid var(--warning);
    padding-left: 0.75rem;
}

.sender-badge.external {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--warning-bg);
    color: var(--warning);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Source badge in ticket detail sidebar */
.member-card .source-badge.email {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.member-card .source-badge.email svg {
    stroke: var(--primary);
}

/* External member info in ticket list */
.member-info.external .external-email {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Helpdesk email banner on tickets page */
.helpdesk-email-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--info-bg, #e0f2fe);
    border: 1px solid var(--info-border, #7dd3fc);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.helpdesk-email-banner svg {
    color: var(--info, #0284c7);
    flex-shrink: 0;
}

.helpdesk-email-banner strong {
    color: var(--info, #0284c7);
}

.helpdesk-email-banner .copy-btn {
    margin-left: auto;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--info-border, #7dd3fc);
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--info, #0284c7);
    transition: background 0.15s;
}

.helpdesk-email-banner .copy-btn:hover {
    background: var(--info-border, #7dd3fc);
}

/* Message external sender style */
.message.message-external {
    background: var(--warning-bg);
}

.message.message-external .message-header {
    border-color: var(--warning);
}

/* ============================================================================
   Member Movement Section (Reports)
   ============================================================================ */

.member-movement-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.member-movement-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.member-movement-section .section-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
}

.member-movement-section .date-range-filter {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.member-movement-section .date-range-filter .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.member-movement-section .date-range-filter label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-light);
}

.member-movement-section .date-range-filter input[type="date"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--input-bg);
    color: var(--text-dark);
}

.member-movement-section .movement-summary {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.member-movement-section .summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    background: var(--gray-50);
}

.member-movement-section .summary-item.joined {
    background: var(--success-bg);
}

.member-movement-section .summary-item.joined .count {
    color: var(--success);
}

.member-movement-section .summary-item.left {
    background: var(--danger-bg);
}

.member-movement-section .summary-item.left .count {
    color: var(--danger);
}

.member-movement-section .summary-item .count {
    font-size: 1.5rem;
    font-weight: 700;
}

.member-movement-section .summary-item .label {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
    .member-movement-section .section-header {
        flex-direction: column;
    }

    .member-movement-section .date-range-filter {
        width: 100%;
    }

    .member-movement-section .movement-summary {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ============================================================================
   File Preview Styles (Form Submissions)
   ============================================================================ */

.file-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.file-preview-image {
    flex-direction: column;
    align-items: flex-start;
}

.file-preview-image .file-image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    object-fit: contain;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    background: white;
}

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

.file-preview-document {
    padding: 1rem;
}

.file-preview-document .file-icon {
    flex-shrink: 0;
}

.file-preview-document .file-icon svg {
    display: block;
}

.file-preview .file-info {
    flex: 1;
    min-width: 0;
}

.file-preview .file-name {
    font-weight: 500;
    color: var(--text-dark);
    word-break: break-word;
}

.file-preview .file-size {
    font-size: 0.875rem;
    color: var(--text-light);
}

.file-preview .file-download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    color: var(--primary);
    transition: var(--transition-base);
}

.file-preview .file-download-link:hover {
    color: var(--primary-dark);
}

.file-preview .file-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

.file-preview .file-download-btn svg {
    flex-shrink: 0;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .file-preview {
        background: var(--bg-dark-hover);
    }

    .file-preview-image .file-image-preview {
        background: var(--bg-dark);
    }
}

/* Data item file styling */
.data-item-file {
    grid-column: span 2;
}

.data-item-file .data-value {
    width: 100%;
}


/* ============================================================================
   FILE BROWSER
   ============================================================================ */

.file-browser {
    display: flex;
    height: calc(100vh - 130px);
    background: var(--card-bg, #fff);
    border-radius: var(--border-radius, 8px);
    border: 1px solid var(--border-color, #e2e8f0);
    overflow: hidden;
}

/* --- Sidebar / Folder Tree --- */

.file-browser-sidebar {
    width: 240px;
    min-width: 200px;
    border-right: 1px solid var(--border-color, #e2e8f0);
    overflow-y: auto;
    padding: 8px 0;
    background: var(--sidebar-bg, var(--card-bg, #fff));
    flex-shrink: 0;
    transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar-toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 2px 12px;
    min-height: 32px;
}

.sidebar-toggle-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-toggle-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle-btn:hover {
    background: var(--hover-bg, #f1f5f9);
    color: var(--text-color, #334155);
}

.sidebar-toggle-btn.collapsed svg line {
    opacity: 0.35;
}

.sidebar-toggle-btn svg {
    display: block;
}

/* Collapsed sidebar */
.filetree-collapsed .file-browser-sidebar {
    width: 40px;
    min-width: 40px;
    overflow: hidden;
}

.filetree-collapsed .sidebar-toggle-header {
    justify-content: center;
    padding: 4px;
}

.sidebar-section {
    padding: 4px 0;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color, #e2e8f0);
    margin: 8px 12px;
}

.folder-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-color, #334155);
    border-radius: 4px;
    margin: 1px 4px;
    transition: background 0.15s;
    user-select: none;
}

.folder-tree-item:hover {
    background: var(--hover-bg, #f1f5f9);
}

.folder-tree-item.active {
    background: var(--primary-light, #eff6ff);
    color: var(--primary-color, #3b82f6);
    font-weight: 500;
}

.folder-tree-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    color: var(--text-muted, #94a3b8);
}

.folder-tree-icon svg {
    width: 16px;
    height: 16px;
}

.folder-tree-item.active .folder-tree-icon {
    color: var(--primary-color, #3b82f6);
}

.folder-tree-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-tree-count {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-muted, #f1f5f9);
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.share-indicator {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    color: var(--text-muted, #94a3b8);
}

.share-indicator svg {
    width: 12px;
    height: 12px;
}

/* --- Main Content --- */

.file-browser-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.file-browser-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    gap: 12px;
    flex-wrap: wrap;
}

.file-toolbar-left,
.file-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-search input {
    width: 200px;
}

.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-muted, #f1f5f9);
    border-radius: 6px;
    padding: 2px;
}

.view-toggle .btn-icon.active {
    background: var(--card-bg, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* --- Breadcrumbs --- */

.file-browser-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    flex-wrap: wrap;
}

.breadcrumb-item {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.breadcrumb-item:hover {
    background: var(--hover-bg, #f1f5f9);
    color: var(--text-color, #334155);
}

.breadcrumb-item.active {
    color: var(--text-color, #334155);
    font-weight: 500;
    cursor: default;
}

.breadcrumb-sep {
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
}

/* --- Bulk Action Bar --- */

.file-bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--primary-light, #eff6ff);
    border-bottom: 1px solid var(--primary-color, #3b82f6);
    font-size: 13px;
    color: var(--primary-color, #3b82f6);
}

/* --- File Content Area --- */

.file-browser-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.file-browser-content.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Grid View --- */

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.file-card {
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    background: var(--card-bg, #fff);
    position: relative;
    user-select: none;
}

.file-card:hover {
    border-color: var(--border-color, #e2e8f0);
    background: var(--hover-bg, #f8fafc);
}

.file-card.selected {
    border-color: var(--primary-color, #3b82f6);
    background: var(--primary-light, #eff6ff);
}

.file-card-icon {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #94a3b8);
}

.file-card-icon svg {
    width: 40px;
    height: 40px;
}

.folder-card .file-card-icon {
    color: var(--warning-color, #f59e0b);
}

.file-card-thumb {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--bg-muted, #f1f5f9);
}

.file-card-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.file-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color, #334155);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-card-meta {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 4px;
}

/* --- File Checkbox --- */

.file-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

.file-card:hover .file-checkbox,
.file-card.selected .file-checkbox,
.file-checkbox:focus-within {
    opacity: 1;
}

/* In list view, always show checkboxes */
.file-list-table .file-checkbox {
    position: static;
    opacity: 1;
}

.file-checkbox-header {
    position: static;
    opacity: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color, #cbd5e1);
    border-radius: 4px;
    background: var(--card-bg, #fff);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    margin: 0;
}

.file-checkbox input[type="checkbox"]:hover {
    border-color: var(--primary-color, #3b82f6);
}

.file-checkbox input[type="checkbox"]:checked {
    background: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
}

.file-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.file-checkbox input[type="checkbox"]:indeterminate {
    background: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
}

.file-checkbox input[type="checkbox"]:indeterminate::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 6px;
    width: 8px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

.file-checkbox-mark {
    display: none;
}

/* When any item is selected, show all checkboxes in grid */
.file-browser-content:has(.file-card.selected) .file-checkbox {
    opacity: 1;
}

.file-card-share-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    align-items: center;
    color: var(--primary-color, #3b82f6);
}

.file-card-share-badge svg {
    width: 14px;
    height: 14px;
}

/* --- List View --- */

.file-list-table {
    width: 100%;
}

.file-list-row {
    cursor: pointer;
    user-select: none;
}

.file-list-row:hover {
    background: var(--hover-bg, #f8fafc);
}

.file-list-row.selected {
    background: var(--primary-light, #eff6ff);
}

.file-list-row td {
    padding: 8px 12px;
    vertical-align: middle;
}

.file-list-row td:first-child {
    color: var(--text-muted, #94a3b8);
}

.file-list-row td:first-child svg {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.file-list-row[data-type="folder"] td:first-child {
    color: var(--warning-color, #f59e0b);
}

.file-list-row td:last-child .btn-icon svg {
    width: 16px;
    height: 16px;
}

.file-list-name {
    font-weight: 500;
}

.file-list-thumb {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    object-fit: cover;
    vertical-align: middle;
}

.share-indicator-inline {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 4px;
    color: var(--primary-color, #3b82f6);
}

.share-indicator-inline svg {
    width: 12px;
    height: 12px;
}

/* --- Context Menu --- */

.file-context-menu {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 180px;
    padding: 4px;
    z-index: 10000;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-color, #334155);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: var(--hover-bg, #f1f5f9);
}

.context-menu-item.danger {
    color: var(--danger-color, #ef4444);
}

.context-menu-item.danger:hover {
    background: #fef2f2;
}

.context-menu-icon {
    width: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.context-menu-icon svg {
    width: 16px;
    height: 16px;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color, #e2e8f0);
    margin: 4px 8px;
}

/* --- Preview Panel --- */

.resize-handle {
    width: 5px;
    cursor: col-resize;
    flex-shrink: 0;
    background: transparent;
    position: relative;
    z-index: 5;
    transition: background 0.15s;
}

.resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 32px;
    border-radius: 2px;
    background: var(--border-color, #e2e8f0);
    transition: background 0.15s, height 0.15s;
}

.resize-handle:hover {
    background: var(--primary-light, #eff6ff);
}

.resize-handle:hover::after {
    background: var(--primary-color, #3b82f6);
    height: 48px;
}

.file-browser-preview {
    width: 320px;
    border-left: 1px solid var(--border-color, #e2e8f0);
    overflow-y: auto;
    position: relative;
    flex-shrink: 0;
}

.preview-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-muted, #94a3b8);
    z-index: 5;
}

.preview-close-btn:hover {
    background: var(--hover-bg, #f1f5f9);
    color: var(--text-color, #334155);
}

.file-preview-panel {
    padding: 16px;
}

.file-preview-header h4 {
    font-size: 14px;
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-meta {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 12px;
}

.file-preview-content {
    margin-bottom: 12px;
}

.preview-image {
    width: 100%;
    border-radius: 6px;
    max-height: 400px;
    object-fit: contain;
    background: var(--bg-muted, #f1f5f9);
}

.preview-pdf {
    width: 100%;
    height: 400px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
}

.preview-text {
    background: var(--bg-muted, #f1f5f9);
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.preview-video,
.preview-audio {
    width: 100%;
    border-radius: 6px;
}

.preview-unsupported {
    text-align: center;
    padding: 24px;
    color: var(--text-muted, #94a3b8);
}

/* --- PDF.js Viewer --- */

.pdf-viewer {
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    overflow: hidden;
}

.pdf-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-muted, #f1f5f9);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    flex-wrap: wrap;
}

.pdf-page-info,
.pdf-zoom-info {
    font-size: 12px;
    color: var(--text-color, #334155);
    min-width: 40px;
    text-align: center;
    user-select: none;
}

.pdf-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border-color, #e2e8f0);
    margin: 0 2px;
}

.pdf-canvas-wrap {
    overflow: auto;
    max-height: 500px;
    background: var(--bg-muted, #f8fafc);
    padding: 8px;
    position: relative;
}

.pdf-canvas {
    display: block;
}

.pdf-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
    background: var(--bg-muted, #f8fafc);
}

.file-preview-actions {
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e2e8f0);
}

/* --- Share Dialog --- */

.share-search-section {
    margin-bottom: 16px;
}

.share-search-results {
    display: none;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
    background: var(--card-bg, #fff);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.search-result-item:hover {
    background: var(--hover-bg, #f1f5f9);
}

.search-result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-result-name {
    font-size: 13px;
    font-weight: 500;
}

.search-result-email {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.share-divider {
    height: 1px;
    background: var(--border-color, #e2e8f0);
    margin: 16px 0;
}

.shares-list {
    max-height: 250px;
    overflow-y: auto;
}

.share-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    gap: 8px;
}

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

.share-item.expired {
    opacity: 0.5;
}

.share-item-info {
    flex: 1;
    min-width: 0;
}

.share-item-name {
    font-size: 13px;
    font-weight: 500;
    display: block;
}

.share-item-email {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.share-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.share-perm-select {
    width: 110px;
    font-size: 12px;
    padding: 4px 8px;
}

/* --- Activity Log --- */

.activity-log-panel {
    padding: 16px;
}

.activity-log-header h4 {
    font-size: 14px;
    margin: 0 0 2px;
}

.activity-log-subtitle {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 16px;
}

.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.activity-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color-light, #f1f5f9);
}

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

.activity-item-icon {
    flex-shrink: 0;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2px;
}

.activity-item-icon svg {
    width: 16px;
    height: 16px;
}

.activity-item-content {
    flex: 1;
    min-width: 0;
}

.activity-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.activity-item-type {
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.activity-item-time {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    flex-shrink: 0;
}

.activity-item-user {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
}

.activity-item-detail {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}

/* --- Drag and Drop States --- */

.file-drop-target {
    outline: 2px dashed var(--primary-color, #3b82f6) !important;
    outline-offset: -2px;
    background: var(--primary-light, #eff6ff) !important;
    border-radius: 6px;
    transition: background 0.15s, outline 0.15s;
}

.file-drop-target.folder-tree-item {
    border-radius: 4px;
}

.file-drop-target.breadcrumb-item {
    border-radius: 4px;
    padding: 2px 6px;
}

[draggable="true"] {
    cursor: grab;
}

.dragging {
    opacity: 0.35 !important;
    pointer-events: none;
}

/* Highlight valid drop targets during drag */
.drag-active [data-drop-folder-id]:not(.dragging) {
    transition: background 0.15s, outline 0.15s;
}

.drag-active .breadcrumb-item[data-drop-folder-id] {
    cursor: copy;
}

.drag-ghost {
    font-family: var(--font-family, sans-serif);
}

.drag-ghost svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* --- File Upload Drop Zone --- */

.file-browser-content {
    position: relative;
}

.file-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(59, 130, 246, 0.08);
    border: 2px dashed var(--primary-color, #3b82f6);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.file-drop-zone-active .file-drop-overlay {
    display: flex;
}

.file-drop-overlay-content {
    text-align: center;
    color: var(--primary-color, #3b82f6);
}

.file-drop-overlay-content svg {
    margin-bottom: 8px;
}

.file-drop-overlay-content p {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.file-drop-hint {
    flex-direction: column;
}

.file-drop-hint .text-muted {
    font-size: 0.85rem;
    margin-top: 4px;
}

@media (prefers-color-scheme: dark) {
    .file-drop-overlay {
        background: rgba(59, 130, 246, 0.12);
    }
}

/* --- Access Level Badges --- */

.badge-public { background: #dcfce7; color: #166534; }
.badge-members_only { background: #dbeafe; color: #1e40af; }
.badge-event_attendees { background: #fef3c7; color: #92400e; }
.badge-private { background: #fce7f3; color: #9d174d; }

/* --- Filter Tabs --- */

.filter-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    padding: 0 1.25rem;
}

.filter-tab {
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-light, #6b7280);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.filter-tab:hover {
    color: var(--text-dark, #1e293b);
}

.filter-tab.active {
    color: var(--primary, #C8102E);
    border-bottom-color: var(--primary, #C8102E);
}

.filter-tab .count {
    background: var(--gray-100, #f1f5f9);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.filter-tab.active .count {
    background: var(--primary-light, rgba(200, 16, 46, 0.1));
    color: var(--primary, #C8102E);
}

/* --- Empty State --- */

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted, #94a3b8);
    font-size: 14px;
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark, #1e293b);
}

.empty-state p {
    color: var(--text-light, #6b7280);
    margin: 0;
    font-size: 14px;
}

.empty-text {
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
    text-align: center;
    padding: 16px;
}

.loading-text {
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
    text-align: center;
    padding: 16px;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .file-browser {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 130px);
    }

    .file-browser-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color, #e2e8f0);
        max-height: 180px;
    }

    .filetree-collapsed .file-browser-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 40px;
        border-bottom: 1px solid var(--border-color, #e2e8f0);
    }

    .resize-handle {
        display: none;
    }

    .file-browser-preview {
        width: 100% !important;
        border-left: none;
        border-top: 1px solid var(--border-color, #e2e8f0);
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .file-search input {
        width: 140px;
    }
}

@media (max-width: 600px) {
    .file-browser-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .file-toolbar-left,
    .file-toolbar-right {
        justify-content: space-between;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }

    .file-card {
        padding: 8px;
    }

    .file-card-icon svg {
        width: 32px;
        height: 32px;
    }
}
