/* Optimized & Modernized Styles */
:root {
    --primary: #4f46e5;
}

body {
    font-family: 'Inter', sans-serif;
}

/* Modern Glassmorphism Inputs & Selects */
.form-control,
.form-select {
    @apply w-full pl-6 pr-4 py-2.5 bg-white border border-slate-300 rounded-xl text-[13px] transition-all duration-300 outline-none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.form-control:focus,
.form-select:focus {
    @apply border-[#FF3E1D] ring-2 ring-[#FF3E1D]/20;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

.fancy-select {
    position: relative;
    width: 100%;
}

.fancy-select-native {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    left: 0;
    top: 0;
}

.fancy-select-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 9px;
    background: #ffffff;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.fancy-select-btn:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

.fancy-select-btn-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.fancy-select-btn-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fancy-select-caret {
    color: #64748b;
    flex: 0 0 auto;
}

.fancy-select-icon {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--primary);
}

.fancy-emoji {
    font-size: 14px;
    line-height: 1;
}

.fancy-select-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    width: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
    z-index: 80;
    max-height: 320px;
    overflow: auto;
}

.fancy-select-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 5px;
    border-radius: 12px;
    color: #334155;
    transition: background 0.15s ease;
}

.fancy-select-item:hover {
    background: #f1f5f9;
}

.fancy-select-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.fancy-select-item-text {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.fancy-select-item-icon {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--primary);
}

.fancy-select-item-disabled {
    opacity: 0.55;
    cursor: default;
}

.fancy-select-item-disabled:hover {
    background: transparent;
}

.fancy-select-check {
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.form-label {
    @apply block text-[10px] font-bold text-slate-400 uppercase tracking-[0.12em] mb-1.5 ml-1;
}

.section-title {
    @apply text-[#FF3E1D] font-bold text-[11px] uppercase tracking-widest border-b border-slate-100 pb-2 mb-4;
}

/* Tight Row Spacing Logic */
#shipment-table td {
    vertical-align: middle;
    height: auto;
}

#shipment-user-table td {
    vertical-align: middle;
    height: auto;
}

/* Checkbox Style */
input[type="checkbox"] {
    @apply w-4 h-4 text-[#FF3E1D] border-slate-300 rounded-md focus:ring-indigo-500/20 cursor-pointer;
}

/* Table Scrollbar (Thin Styling) */
.overflow-x-auto::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.overflow-x-auto::-webkit-scrollbar-track,
.overflow-y-auto::-webkit-scrollbar-track {
    @apply bg-transparent;
}

.overflow-x-auto::-webkit-scrollbar-thumb,
.overflow-y-auto::-webkit-scrollbar-thumb {
    @apply bg-slate-200 rounded-full transition-colors duration-300;
}

.overflow-x-auto::-webkit-scrollbar-thumb:hover,
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    @apply bg-[#FF3E1D]/40;
}

.inp-f-w {
    width: 100% !important;
}

@media (max-width: 1024px) {
    .sticky {
        position: static !important;
    }
}

/* Target the address textarea specifically */
textarea[name="address"] {
    width: calc(100%) !important;

    resize: none;
    /* Prevents user from breaking your layout */
    position: relative;
    z-index: 10;
}

/* Ensure dropdown appears above the table */
#datePickerContainer {
    position: relative;
    z-index: 50;
}

#datePickerDropdown {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    width: 650px;
    max-width: calc(100vw - 24px);
    /* left: 50%; */
    /* transform: translateX(-50%); */
}

@media (max-width: 768px) {
    #datePickerDropdown .dp-calendar-area {
        padding: 16px;
    }
}

@media (max-width: 640px) {
    #datePickerDropdown {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: visible;
    }

    #datePickerDropdown .dp-sidebar {
        display: none;
    }

    #datePickerDropdown .dp-calendar-area {
        padding: 14px;
        width: 100%;
        flex: 1 1 auto;
    }

    #datePickerDropdown #monthDropdown,
    #datePickerDropdown #yearDropdown {
        width: 100%;
        max-width: calc(100vw - 48px);
        max-height: 60vh;
        overflow: auto;
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin-top: 0 !important;
        z-index: 9999;
    }

    #datePickerDropdown #monthDropdownList,
    #datePickerDropdown #yearDropdownList {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Entry Animation */
@keyframes pickerFade {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.animate-fade-in {
    animation: pickerFade 0.2s ease-out forwards;
}

/* Custom Scrollbar for mobile preset list */
#datePickerDropdown div::-webkit-scrollbar {
    width: 4px;
}

#datePickerDropdown div::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* All Dispatches title override (hosting fix) */
.all-dispatches-title {
    font-size: 22px !important;
    line-height: 1.25rem;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5f5;
    border-radius: 10px;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    -ms-border-radius: 10px;
    -o-border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Container positions */
.toast-container {
    position: fixed;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Desktop positions */
.toast-container.top-right {
    top: 20px;
    right: 20px;
}

.toast-container.top-left {
    top: 20px;
    left: 20px;
}

/* ✅ Mobile: Top Center */
.toast-container.mobile-top {
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 20px);
    max-width: 400px;
}

/* Toast base */
.toast {
    width: 100%;
    min-width: unset;
    max-width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    animation: toast-in 0.3s ease;
}

/* Success (Green) */
.toast-success {
    background: #ecfdf5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

/* Error (Red) */
.toast-error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Animations */
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

:root {
    --primary: #6366f1;
    --bg: #f8fafc;
    --text: #1e293b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --radius: 12px;
}

select,
::picker(select) {
    appearance: base-select;
}

select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
}

select:hover {
    border-color: var(--primary);
}

select::picker-icon {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80a8,8,0,0,1,11.32-11.32L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    margin-left: auto;
}

::picker(select) {
    width: anchor-size(width);
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.2s, transform 0.2s, display 0.2s allow-discrete;
}

:open::picker(select) {
    opacity: 1;
    transform: translateY(6px) scale(1);
}

@starting-style {
    :open::picker(select) {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
}

option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
}

option:hover {
    background: #f1f5f9;
}

option:checked {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 500;
}

option::checkmark {
    content: "✓";
    margin-left: 8px;
    color: var(--primary);
}

#datePickerDropdown .dp-preset {
    position: relative;
    color: #475569;
    background: transparent;
}

#datePickerDropdown .dp-preset.dp-preset-inactive:hover {
    background: #f8fafc;
}

#datePickerDropdown .dp-preset.dp-preset-active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

#datePickerDropdown .dp-preset.dp-preset-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 999px;
    background: var(--primary);
}

#datePickerDropdown .dp-day {
    height: 36px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.875rem;
    user-select: none;
    position: relative;
}

#datePickerDropdown .dp-day.dp-notinrange:hover {
    background: #f1f5f9;
    border-radius: 10px;
}

#datePickerDropdown .dp-day.dp-inrange {
    background: var(--primary);
    color: #ffffff;
}

#datePickerDropdown .dp-day.dp-start {
    border-top-left-radius: 999px;
    border-bottom-left-radius: 999px;
}

#datePickerDropdown .dp-day.dp-end {
    border-top-right-radius: 999px;
    border-bottom-right-radius: 999px;
}

#datePickerDropdown .dp-day.dp-inrange.dp-start.dp-end {
    border-radius: 999px;
}

#datePickerDropdown .dp-day.dp-inmonth {
    color: #374151;
}

#datePickerDropdown .dp-day.dp-outmonth {
    color: #d1d5db;
}

#datePickerDropdown .dp-today-dot {
    position: absolute;
    bottom: 4px;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 999px;
}

#datePickerDropdown #monthDropdown,
#datePickerDropdown #yearDropdown {
    margin-top: 6px;
}