/* Custom CSS for DTech Application */

/* -----------------------------------------------------------
   Universal Premium Selector Modals: Premium Card Design
   Used for: Customer, Vehicle, Item, Package Selectors
   ----------------------------------------------------------- */

@media (max-width: 767.98px) {
    /* 1. Base Container & Rows */
    .dt-mobile-cards {
        border: 0 !important;
    }

    .dt-mobile-cards thead {
        display: none !important; /* Hide column headers on mobile */
    }

    .dt-mobile-cards tbody tr {
        display: block !important;
        background: #fff;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;
        margin-bottom: 2rem !important;
        padding: 1rem !important;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        transition: transform 0.2s, box-shadow 0.2s;
        position: relative !important;
        padding-top: 3.5rem !important; /* Standardized space for headers */
    }

    .dt-mobile-cards tbody tr:hover {
        transform: translateY(-2px);
        background: #fff !important;
    }

    /* 2. Cell Layout (Flex row for data, block for headers/buttons) */
    .dt-mobile-cards tbody td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 0 !important;
        border: 0 !important;
        font-size: 1rem;
        color: #1e293b;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .dt-mobile-cards tbody td:last-child {
        border-bottom: 0 !important;
    }

    /* Standard Data Labels */
    .dt-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    /* 3. Universal Card Header (Identifies first visual field) */
    /* Primary identifiers like Name, Code, Package, Vehicle, Item */
    .dt-mobile-cards tbody td[data-label="Package"],
    .dt-mobile-cards tbody td[data-label="Name"],
    .dt-mobile-cards tbody td[data-label="Vehicle"],
    .dt-mobile-cards tbody td[data-label="Registration"],
    .dt-mobile-cards tbody td[data-label="Item"],
    .dt-mobile-cards tbody td[data-label="Code"] {
        position: absolute !important;
        top: 0;
        left: 0;
        right: 0;
        height: 3rem;
        background: #f8fafc;
        border-bottom: 1.5px solid #e2e8f0 !important;
        padding: 0 1.25rem !important;
        font-weight: 700 !important;
        color: #1e293b !important;
        font-size: 1.05rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        border-radius: 12px 12px 0 0;
    }

    /* Hide redundant label in the header */
    .dt-mobile-cards tbody td[data-label="Package"]::before,
    .dt-mobile-cards tbody td[data-label="Name"]::before,
    .dt-mobile-cards tbody td[data-label="Vehicle"]::before,
    .dt-mobile-cards tbody td[data-label="Item"]::before,
    .dt-mobile-cards tbody td[data-label="Code"]::before {
        display: none !important;
    }

    /* Specific adjustment for identifying Code vs Name (if both in header range) */
    /* We prioritize Name as the header if possible, else Code */
    .dt-mobile-cards tbody td[data-label="Code"] {
        z-index: 1;
    }
    .dt-mobile-cards tbody td[data-label="Name"],
    .dt-mobile-cards tbody td[data-label="Package"],
    .dt-mobile-cards tbody td[data-label="Vehicle"],
    .dt-mobile-cards tbody td[data-label="Item"] {
        z-index: 2;
    }

    /* 4. Action/Pick Column: Redesign */
    /* Hide the "Pick" or "Action" label completely */
    .dt-mobile-cards tbody td[data-label="Pick"],
    .dt-mobile-cards tbody td[data-label="Action"] {
        display: block !important;
        padding-top: 1.5rem !important;
        text-align: center !important;
        border-bottom: 0 !important;
    }

    .dt-mobile-cards tbody td[data-label="Pick"]::before,
    .dt-mobile-cards tbody td[data-label="Action"]::before {
        display: none !important;
    }

    /* Center and expand Select buttons */
    .dt-mobile-cards .btn-select-item,
    .dt-mobile-cards .btn-pick,
    .dt-mobile-cards .btn-primary {
        width: 100% !important;
        padding: 0.85rem !important;
        border-radius: 10px;
        font-weight: 700;
        font-size: 1rem;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
    }

    /* Special handling for the TRASH icon (Remove button) */
    .dt-mobile-cards tbody .remove-package-btn {
        position: absolute !important;
        top: 0.6rem;
        right: 0.6rem;
        z-index: 10;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(239, 68, 68, 0.1);
        color: #ef4444;
        border: 1px solid rgba(239, 68, 68, 0.2);
        box-shadow: none !important;
    }

    /* 5. Input Refinement inside Cards */
    .dt-mobile-cards tbody td:has(.form-control) {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .dt-mobile-cards tbody td .form-control {
        margin-top: 0.75rem;
        border-radius: 10px !important;
        padding: 0.75rem 1rem !important;
        background: #f8fafc !important;
        border: 1.5px solid #f1f5f9 !important;
        font-weight: 500;
        width: 100% !important;
    }

    .dt-mobile-cards tbody td .form-control:focus {
        background: #fff !important;
        border-color: #2563eb !important;
        box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1) !important;
    }

    /* 6. Footer/Total Summary */
    .dt-mobile-cards tfoot {
        display: block !important;
        margin-top: 2rem;
    }

    .dt-mobile-cards tfoot tr {
        display: block !important;
        background: #f8fafc;
        border: 2px solid #e2e8f0;
        border-radius: 15px;
        padding: 1.5rem;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    }

    .dt-mobile-cards tfoot tr th {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        border: 0 !important;
        padding: 0.5rem 0 !important;
        font-size: 1.15rem !important;
    }

    .dt-mobile-cards tfoot tr th:first-child {
        color: #64748b;
        font-weight: 700;
    }

    .dt-mobile-cards tfoot tr th#packagesTotal {
        color: #2563eb !important;
        font-weight: 800 !important;
        font-size: 1.4rem !important;
    }

    .dt-mobile-cards tfoot tr th:empty {
        display: none !important;
    }
} /* End Media Query */

/* Shared Global Modal UI */
.modal-search-wrapper {
    position: relative;
    margin-bottom: 2rem;
}

.modal-search-wrapper .search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1.1rem;
}

.modal-search-wrapper .form-control {
    padding-left: 3.25rem;
    border-radius: 12px;
    height: 54px;
    border: 1.5px solid #e2e8f0;
    font-size: 1.05rem;
    transition: all 0.2s;
}

.modal-search-wrapper .form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* -----------------------------------------------------------
   Global Premium Preloader (Glassmorphism + Pulse)
   ----------------------------------------------------------- */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.6s ease, visibility 0.6s;
}

body.dark-mode .preloader {
    background: rgba(15, 23, 42, 0.8);
}

.preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-pulse {
    position: relative;
    width: 80px;
    height: 80px;
    background: var(--primary, #2563eb);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.4);
    animation: loaderPulse 2s infinite ease-in-out;
}

.loader-pulse::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--primary, #2563eb);
    animation: loaderRipple 2s infinite ease-out;
}

@keyframes loaderPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(37, 99, 235, 0.3); }
    50% { transform: scale(1.1); box-shadow: 0 0 50px rgba(37, 99, 235, 0.6); }
}

@keyframes loaderRipple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

.loader-text {
    margin-top: 2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #1e293b;
    font-size: 0.85rem;
    animation: loaderTextFade 1.5s infinite alternate;
}

body.dark-mode .loader-text {
    color: #f1f5f9;
}

@keyframes loaderTextFade {
    from { opacity: 0.4; transform: translateY(0); }
    to { opacity: 1; transform: translateY(-3px); }
}

/* Animations */
@keyframes loaderTextFade {
    from { opacity: 0.4; transform: translateY(0); }
    to { opacity: 1; transform: translateY(-3px); }
}

/* -----------------------------------------------------------
   Full-Height & Full-Width XL Modals
   ----------------------------------------------------------- */
.modal-xl {
    max-width: 98% !important;
    width: 98% !important;
    margin: 2vh auto !important;
}

.modal-xl .modal-content {
    height: 96vh !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}

.modal-xl .modal-header {
    flex-shrink: 0 !important;
}

.modal-xl .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
}

.modal-xl .modal-footer {
    flex-shrink: 0 !important;
}
