@import 'bootstrap/dist/css/bootstrap.css';

/* Enhanced Category Select Styles */
.category-select {
    font-family: system-ui, -apple-system, sans-serif;
}

.category-select optgroup {
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.category-select option {
    padding: 8px 16px;
    font-size: 0.95rem;
}

.category-select option:hover {
    background-color: #e9ecef;
}

/* Photo Upload Styles */
.profile-photo-wrapper {
    transition: transform 0.2s ease;
}

.profile-photo-wrapper:hover {
    transform: scale(1.02);
}

.photo-upload-overlay {
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.photo-upload-overlay:hover {
    opacity: 1 !important;
}

/* Contact Type Edit Styles */
.contact-type-display:hover .contact-type-edit-btn {
    opacity: 1 !important;
}

/* Inline Category Editor Styles */
.inline-category-editor {
    position: relative;
}

.category-display:hover {
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
}

.autocomplete-dropdown {
    position: absolute;
    z-index: 1050;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    width: 250px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    top: 100%;
    left: 0;
    margin-top: 2px;
}

.autocomplete-group-header {
    background-color: #f8f9fa;
    color: #6c757d;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    font-size: 0.9rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: #e3f2fd;
    color: #1976d2;
}

.autocomplete-item.current {
    background-color: #fff3e0;
    border-left: 3px solid #ff9800;
}

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

/* Violation Title Autocomplete Styles */
.has-autocomplete {
    /* No background icon needed since dropdown provides visual indication */
}

/* Custom Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

/* Tom Select Bootstrap Theme Overrides - Force Bootstrap styling */
.ts-wrapper {
    position: relative !important;
    display: block !important;
    width: 200px !important;
    max-width: 200px !important;
    min-width: 200px !important;
    box-sizing: border-box !important;
}

/* Ensure parent container of Tom Select has proper width */
.ts-wrapper,
.ts-wrapper.single,
.ts-wrapper.single.input-active,
.ts-wrapper.single.dropdown-active,
.ts-wrapper.single.focus,
.ts-wrapper.single.has-items {
    width: 100% !important;
    max-width: 200px !important;
    display: block !important;
}

/* Set minimum width for Tom Select parent containers */
.ts-wrapper:not([class*="col-"]) {
    min-width: 200px !important;
}

/* Or target specific parent containers if needed */
.form-group:has(.ts-wrapper),
.mr-1:has(.ts-wrapper),
div:has(.ts-wrapper) {
    min-width: 200px !important;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control {
    background: #fff !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    display: flex !important;
    align-items: center !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

.ts-wrapper.single .ts-control:focus,
.ts-wrapper.single .ts-control:focus-within,
.ts-wrapper.single.focus .ts-control {
    border-color: #86b7fe !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

.ts-wrapper.single .ts-control input[type="text"] {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    flex: 0 1 auto !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: inherit !important;
    line-height: inherit !important;
    color: #212529 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
}

.ts-wrapper.single .ts-control input[type="text"]::placeholder {
    color: #6c757d !important;
    opacity: 1 !important;
}

.ts-control .clear-button {
    position: absolute !important;
    right: 2rem !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    cursor: pointer !important;
    padding: 0.25rem !important;
    color: #6c757d !important;
    font-size: 1.2em !important;
    line-height: 1 !important;
    z-index: 2 !important;
    background: none !important;
    border: none !important;
}

.ts-control .clear-button:hover {
    color: #495057 !important;
}

.ts-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: white !important;
    border: 1px solid #ced4da !important;
    border-top: none !important;
    border-radius: 0 0 0.25rem 0.25rem !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    max-height: 200px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    margin-top: -1px !important;
}

.ts-dropdown .ts-dropdown-content {
    padding: 0 !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    scrollbar-width: thin !important;
    scrollbar-color: #ced4da transparent !important;
}

/* Webkit scrollbar styling for dropdown */
.ts-dropdown .ts-dropdown-content::-webkit-scrollbar {
    width: 8px !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-track {
    background: transparent !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb {
    background: #ced4da !important;
    border-radius: 4px !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb:hover {
    background: #adb5bd !important;
}

.ts-dropdown .option {
    padding: 0.5rem 0.75rem !important;
    border-bottom: 1px solid #f8f9fa !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease-in-out !important;
    color: #212529 !important;
    background: white !important;
}

.ts-dropdown .option:last-child {
    border-bottom: none !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

.ts-dropdown .option.selected {
    background-color: #0d6efd !important;
    color: white !important;
}

.ts-dropdown .optgroup-header {
    padding: 0.25rem 0.75rem !important;
    background-color: #e9ecef !important;
    color: #6c757d !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border-bottom: 1px solid #dee2e6 !important;
}

.ts-dropdown .no-results {
    padding: 0.75rem !important;
    text-align: center !important;
    color: #6c757d !important;
    font-style: italic !important;
}

/* Force proper padding for clear button plugin */
.ts-wrapper.single.plugin-clear_button .ts-control {
    padding-right: 3rem !important;
}

/* Remove unwanted Tom Select default styling */
.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control {
    cursor: text !important;
}

/* Loading state */
.ts-wrapper.loading .ts-control::after {
    content: "" !important;
    position: absolute !important;
    right: 0.75rem !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 1rem !important;
    height: 1rem !important;
    border: 2px solid #f3f3f3 !important;
    border-top: 2px solid #0d6efd !important;
    border-radius: 50% !important;
    animation: spin 1s linear infinite !important;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Fix the item div that contains selected text */
.ts-control .item {
    max-width: calc(100% - 3rem) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    display: inline-block !important;
}

/* Fix input field when in focus - keep it same width as unfocused */
.ts-wrapper.focus .ts-control input,
.ts-wrapper.input-active .ts-control input,
.ts-wrapper.dropdown-active .ts-control input {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 1 auto !important;
}

/* Force Tom Select to never exceed container width */
.ts-wrapper[style],
.ts-wrapper.single[style],
.ts-wrapper.single.input-active[style],
.ts-wrapper.single.dropdown-active[style],
.ts-wrapper.single.focus[style],
.ts-wrapper.single.has-items[style] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
}

.ts-wrapper,
.ts-wrapper.single,
.ts-wrapper.single.input-active,
.ts-wrapper.single.dropdown-active,
.ts-wrapper.single.focus,
.ts-wrapper.single.has-items {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
    display: block !important;
}

.ts-wrapper.single .ts-control[style],
.ts-wrapper.single.input-active .ts-control[style],
.ts-wrapper.single.dropdown-active .ts-control[style],
.ts-wrapper.single.focus .ts-control[style],
.ts-wrapper.single.has-items .ts-control[style] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.single.dropdown-active .ts-control,
.ts-wrapper.single.focus .ts-control,
.ts-wrapper.single.has-items .ts-control {
    width: 100% !important;
    max-width: 200px !important;
    min-width: auto !important;
    resize: none !important;
    box-sizing: border-box !important;
}

/* Override for modals, invoice calculator, and EasyAdmin pages - use full width */
.modal .ts-wrapper,
.modal .ts-wrapper.single,
.modal .ts-wrapper.single.input-active,
.modal .ts-wrapper.single.dropdown-active,
.modal .ts-wrapper.single.focus,
.modal .ts-wrapper.single.has-items,
[data-controller*="invoice-calculator"] .ts-wrapper,
[data-controller*="invoice-calculator"] .ts-wrapper.single,
[data-controller*="invoice-calculator"] .ts-wrapper.single.input-active,
[data-controller*="invoice-calculator"] .ts-wrapper.single.dropdown-active,
[data-controller*="invoice-calculator"] .ts-wrapper.single.focus,
[data-controller*="invoice-calculator"] .ts-wrapper.single.has-items,
body.ea .ts-wrapper,
body.ea .ts-wrapper.single,
body.ea .ts-wrapper.single.input-active,
body.ea .ts-wrapper.single.dropdown-active,
body.ea .ts-wrapper.single.focus,
body.ea .ts-wrapper.single.has-items {
    max-width: 100% !important;
}

.modal .ts-wrapper.single .ts-control,
.modal .ts-wrapper.single.input-active .ts-control,
.modal .ts-wrapper.single.dropdown-active .ts-control,
.modal .ts-wrapper.single.focus .ts-control,
.modal .ts-wrapper.single.has-items .ts-control,
[data-controller*="invoice-calculator"] .ts-wrapper.single .ts-control,
[data-controller*="invoice-calculator"] .ts-wrapper.single.input-active .ts-control,
[data-controller*="invoice-calculator"] .ts-wrapper.single.dropdown-active .ts-control,
[data-controller*="invoice-calculator"] .ts-wrapper.single.focus .ts-control,
[data-controller*="invoice-calculator"] .ts-wrapper.single.has-items .ts-control,
body.ea .ts-wrapper.single .ts-control,
body.ea .ts-wrapper.single.input-active .ts-control,
body.ea .ts-wrapper.single.dropdown-active .ts-control,
body.ea .ts-wrapper.single.focus .ts-control,
body.ea .ts-wrapper.single.has-items .ts-control {
    max-width: 100% !important;
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s ease-in-out;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: #f8f9fa;
}

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

.autocomplete-item strong {
    color: #007bff;
    font-weight: 600;
}

/* Invoice status styling - consistent for all statuses */
[class*="invoice-status-"] {
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    padding: 0.35rem 0.7rem !important;
    border-radius: 0.25rem !important;
    border: 1px solid transparent !important;
}

/* Pending */
.invoice-status-1 {
    background-color: #ffc107 !important;
    color: #212529 !important;
    border-color: #ffb307 !important;
}

/* Cancelled */
.invoice-status-2 {
    background-color: #6c757d !important;
    color: white !important;
    border-color: #5a6268 !important;
}

/* Refunded */
.invoice-status-3 {
    background-color: #17a2b8 !important;
    color: white !important;
    border-color: #138496 !important;
}

/* Paid */
.invoice-status-4 {
    background-color: #28a745 !important;
    color: white !important;
    border-color: #20c997 !important;
}

/* Delivery Failed - Missing Contacts */
.invoice-status-5 {
    background-color: #dc3545 !important;
    color: white !important;
    border-color: #c82333 !important;
}

.invoice-status-5:before {
    content: "⚠ ";
    margin-right: 0.25rem;
}

.autocomplete-group-header {
    padding: 0.25rem 0.75rem;
    background-color: #e9ecef;
    color: #6c757d;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #dee2e6;
}


