/* =========================================== */
/* Modern Dropdowns Redesign - Matching App Design */
/* =========================================== */

/* Global Styled Dropdowns - Modern Design */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

select.styled-dropdown {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    z-index: 2 !important;
    cursor: pointer !important;
    /* Make it invisible but still clickable */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background: transparent !important;
    border: none !important;
    color: transparent !important;
    pointer-events: none !important;
}

/* For Firefox */
select.styled-dropdown::-ms-expand {
    display: none !important;
}


/* But allow hover effects on the custom trigger */
.custom-select-wrapper:hover .select-trigger {
    pointer-events: auto;
}

/* Alternative approach: Make the select completely hidden but functional */
select.hidden-select {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}


/* Modern Trigger - Matches table design */
.select-trigger {
    width: 100%;
    min-height: 38px;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--gray-300, #dee2e6);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    position: relative;
    box-sizing: border-box;
    /*font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;*/
}

/* When trigger also carries .form-input, avoid double padding (border comes from .form-input) */
.select-trigger.form-input {
    min-height: unset;
}

.select-trigger:hover {
    border-color: #093de3;
    /*background: linear-gradient(90deg, rgba(0, 154, 255, 0.02) 0%, rgba(0, 154, 255, 0.01) 100%);*/
    background: transparent !important;
        color: #093de3 !important;
}

.select-trigger:focus,
.select-trigger.active {
    border-color: #093de3;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(0, 156, 255, 0.1);
}

.select-trigger .selected-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
        font-weight: 500;
    font-size: 0.84rem;
}

.select-trigger i {
    color: #94a3b8;
    transition: transform 0.2s ease;
    font-size: 0.8rem;
    margin-left: 8px;
}

.select-trigger.active i {
    transform: rotate(180deg);
    color: #093de3;
}

/* Modern Dropdown - Matches table design
   Wider than trigger when needed: narrow toolbars (e.g. max-width filter columns)
   keep a compact trigger but the list grows to fit option labels. */
.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    min-width: 100%;
    width: max-content;
    max-width: min(100vw - 24px, 90vw);
    box-sizing: border-box;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    z-index: 1050;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
    animation: fadeInUp 0.2s ease;
}

.custom-select-dropdown.show {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/*
.select-options {
    padding: 4px 0;
}*/

.select-option {
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1e293b;
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    /*border-left: 3px solid transparent;*/
}

.select-option:hover {
    background: linear-gradient(90deg, rgba(0, 154, 255, 0.08) 0%, rgba(0, 154, 255, 0.04) 100%);
    /*border-left-color: #093de3;*/
    color: #093de3;
}

.select-option.selected {
    background: linear-gradient(90deg, rgba(0, 154, 255, 0.1) 0%, rgba(0, 154, 255, 0.15) 100%);
    color: #093de3;
    border-left-color: #093de3;
}

.select-option.selected:hover { 
    background: linear-gradient(90deg, rgba(0, 154, 255, 0.15) 0%, rgba(0, 154, 255, 0.2) 100%);
}

/* Scrollbar styling - Modern */
.custom-select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    border-radius: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

/* Invalid state - Modern */
.is-invalid .select-trigger,
.custom-select-wrapper.is-invalid .select-trigger,
.form-group.is-invalid .select-trigger {
    border-color: #ef4444;
}

.is-invalid .select-trigger:focus,
.custom-select-wrapper.is-invalid .select-trigger:focus,
.form-group.is-invalid .select-trigger:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Group headers */
.select-group-header {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    margin-top: 4px;
}

.select-group-header:first-child {
    margin-top: 0;
    border-top: none;
}

/* =========================================== */
/* Action dropdowns (toolbar / modals) — one compact system app-wide */
/* =========================================== */

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

/* Trigger: matches dashboard “Options” (compact, not tall select-trigger style) */
.action-dropdown > .action-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.75rem;
    min-height: unset;
    background: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    transition: all 0.15s ease;
    white-space: nowrap;
    position: relative;
}

.action-dropdown > .action-trigger:hover {
    border-color: #093de3;
    color: #093de3;
    background: #fff;
}

.action-dropdown > .action-trigger:focus,
.action-dropdown > .action-trigger.active {
    border-color: #093de3;
    outline: 0;
}

.action-dropdown > .action-trigger .action-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
}

.action-dropdown > .action-trigger i {
    color: #94a3b8;
    transition: transform 0.2s ease;
    font-size: 0.8rem;
    margin-left: 0;
}

.action-dropdown > .action-trigger .fa-chevron-down {
    font-size: 0.72rem;
    color: #9ca3af;
}

.action-dropdown.show > .action-trigger .fa-chevron-down,
.action-dropdown > .action-trigger.active .fa-chevron-down {
    transform: rotate(180deg);
    color: #093de3;
}

/* Menu shell — grow with content (avoid wrapping long titles) */
.action-dropdown .action-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    display: none;
    margin-top: 4px;
    padding: 6px;
    width: max-content;
    min-width: 220px;
    max-width: min(100vw - 24px, 420px);
    animation: fadeInUp 0.2s ease;
}

.action-dropdown .action-menu.show {
    display: block;
}

/* Timesheet “Patterns” panel needs a wider menu */
.action-dropdown.patterns-dropdown .action-menu.patterns-menu {
    min-width: min(100vw - 32px, 380px);
    max-width: 420px;
    padding: 8px;
}

/* Rows */
.action-dropdown .action-item {
    padding: 9px 10px;
    margin-bottom: 0;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    color: #374151 !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 0.85rem;
}

.action-dropdown .action-item:hover {
    background: linear-gradient(90deg, rgba(0, 154, 255, 0.08) 0%, rgba(0, 154, 255, 0.04) 100%);
    color: #093de3 !important;
}

.action-dropdown .action-item:hover .action-item-title {
    color: #093de3;
}

.action-dropdown .action-item:hover .action-item-description {
    color: #64748b !important;
}

.action-dropdown .action-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.action-dropdown .action-item-title {
    color: inherit;
    font-weight: 500;
    font-size: 0.84rem;
    line-height: 1.3;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: normal;
}

.action-dropdown .action-item-description {
    color: #9ca3af !important;
    font-size: 0.74rem;
    line-height: 1.4;
    margin-top: 1px;
}

.action-dropdown .action-item-arrow {
    color: #9ca3af;
    font-size: 0.7rem;
    margin-left: 8px;
    align-self: center;
    flex-shrink: 0;
}

.action-dropdown .action-item:hover .action-item-arrow {
    color: #093de3;
}

/* Special action types with color coding */
.action-item.export-action:hover {
        background: linear-gradient(90deg, rgba(0, 154, 255, 0.08) 0%, rgba(0, 154, 255, 0.04) 100%);
    color: #093de3;
}

.action-item.export-action:hover .action-item-title {
    color: #093de3;
}

/* Delete / destructive row actions — red text + soft red hover */
.action-dropdown .action-item.delete-action,
.action-dropdown .action-item.sup-action-delete,
.action-dropdown .action-item.cust-action-delete,
.action-dropdown .action-item.staff-action-delete,
.action-dropdown .action-item.btn-delete-contractor,
.action-dropdown .action-item.ts-action-delete,
.action-dropdown .action-item.doc-action-delete {
    color: #dc2626 !important;
}
.action-dropdown .action-item.doc-action-delete .doc-action-item-inner,
.action-dropdown .action-item.doc-action-delete .text-danger,
.doc-row-actions-menu .action-item.doc-action-delete,
.doc-row-actions-menu .action-item.doc-action-delete .doc-action-item-inner,
.doc-row-actions-menu .action-item.doc-action-delete .text-danger {
    color: #dc2626 !important;
}

.action-dropdown .action-item.delete-action .action-item-arrow,
.action-dropdown .action-item.sup-action-delete .action-item-arrow,
.action-dropdown .action-item.cust-action-delete .action-item-arrow,
.action-dropdown .action-item.staff-action-delete .action-item-arrow,
.action-dropdown .action-item.btn-delete-contractor .action-item-arrow,
.action-dropdown .action-item.ts-action-delete .action-item-arrow,
.action-dropdown .action-item.doc-action-delete .action-item-arrow {
    color: #dc2626;
}

.action-dropdown .action-item.delete-action:hover,
.action-dropdown .action-item.sup-action-delete:hover,
.action-dropdown .action-item.cust-action-delete:hover,
.action-dropdown .action-item.staff-action-delete:hover,
.action-dropdown .action-item.btn-delete-contractor:hover,
.action-dropdown .action-item.ts-action-delete:hover,
.action-dropdown .action-item.doc-action-delete:hover {
    background: #fef2f2 !important;
    color: #dc2626 !important;
}

.action-dropdown .action-item.delete-action:hover .action-item-title,
.action-dropdown .action-item.delete-action:hover .action-item-arrow,
.action-dropdown .action-item.sup-action-delete:hover .action-item-arrow,
.action-dropdown .action-item.cust-action-delete:hover .action-item-arrow,
.action-dropdown .action-item.staff-action-delete:hover .action-item-arrow,
.action-dropdown .action-item.btn-delete-contractor:hover .action-item-arrow,
.action-dropdown .action-item.ts-action-delete:hover .action-item-arrow,
.action-dropdown .action-item.doc-action-delete:hover .action-item-arrow {
    color: #dc2626 !important;
}

/* Action headers — title case, no tracking */
.action-header {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: none;
    letter-spacing: normal;
    margin: 0;
    border-bottom: 1px solid #f1f5f9;
}

/* Action dividers (toolbar menus) */
.action-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}

/* Action item with icons */
.action-item i:first-child {
    color: #94a3b8;
    font-size: 0.85rem;
    margin-right: 12px;
    margin-top: 2px;
    flex-shrink: 0;
}

.action-item:hover i:first-child {
    color: #093de3;
}

/* Disabled state */
.action-dropdown > .action-trigger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f8fafc;
}

.action-dropdown > .action-trigger:disabled:hover {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #374151;
}

.action-item:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.action-item:disabled:hover {
    background: none;
    color: #1e293b;
}

.action-item:disabled:hover .action-item-title {
    color: #1e293b;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .select-trigger {
        min-height: 38px;
        font-size: 0.85rem;
        padding: 0 12px;
    }

    .action-dropdown > .action-trigger {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .select-option,
    .action-dropdown .action-item {
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .action-dropdown .action-menu {
        min-width: min(240px, calc(100vw - 24px));
        right: auto;
        left: 0;
    }

    .action-dropdown.patterns-dropdown .action-menu.patterns-menu {
        min-width: min(calc(100vw - 24px), 380px);
        left: 0;
        right: auto;
    }

    .action-dropdown .action-item-title {
        font-size: 0.82rem;
    }

    .action-dropdown .action-item-description {
        font-size: 0.72rem;
    }
}

/* Remove Bootstrap's default arrow */
.action-trigger::after {
    display: none !important;
}

/* Ensure proper positioning for dropdown menus */
.dropdown-menu-end.action-menu {
    right: 0;
    left: auto;
}

/* Job preview modal: Popper menus above modal + no clipping */
/* Job preview modal stacking: see dashboard.css (loads after this file) */

/* Compact trigger (legacy — default toolbar trigger is already compact) */
.action-trigger.compact {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
}

.select-trigger.compact {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.85rem;
}

/* Success state */
.is-valid .select-trigger {
    border-color: #10b981;
}

.is-valid .select-trigger:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Loading state */
/* Multi-select (timesheets staff pickers) */
.custom-multi-select-wrapper select.styled-multi-dropdown {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.multi-select-check {
    width: 1rem;
    height: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.65rem;
    color: transparent;
    background: #fff;
}

.multi-select-option.selected .multi-select-check {
    background: #093de3;
    border-color: #093de3;
    color: #fff;
}

.multi-select-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-trigger.loading i,
.action-trigger.loading i {
    animation: spin 1s linear infinite;
}

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

/* Searchable dropdown enhancements */
.select-search {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.select-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.select-search input:focus {
    outline: none;
    border-color: #093de3;
    box-shadow: 0 0 0 3px rgba(0, 154, 255, 0.1);
}

/* Empty state in dropdown */
.select-empty-state {
    padding: 20px 16px;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
}

.select-empty-state i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: #cbd5e1;
    display: block;
}