/* =======================================================
   DUTY SLIP - PROFESSIONAL UI/UX STYLES
   ======================================================= */

/* --- 1. ROOT VARIABLES & DESIGN SYSTEM --- */
:root {
    --primary-blue: #4F46E5;
    --primary-dark: #3730A3;
    --secondary-teal: #0D9488;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-400: #9CA3AF;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-900: #0F172A;
    --danger-color: #EF4444;
    --whatsapp-color: #25D366;
    --white: #FFFFFF;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --space-2: 0.5rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --transition-fast: 0.2s ease-out;
    --transition-normal: 0.3s ease-out;
}

/* --- 2. FORM & LAYOUT STYLING --- */
.duty-slip-screen {
    max-width: 1280px;
    margin: 0 auto;
}

.header,
.main-body-table,
.usage-table,
.footer {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.section-header {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-4);
    position: relative;
    padding-left: var(--space-4);
}

.section-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 80%;
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-teal));
    border-radius: 5px;
}

/* --- Enhanced Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: var(--space-5);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.logo-screen {
    max-height: 60px; /* A slightly more refined size */
}

.header-title-block {
    display: flex;
    flex-direction: column;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0;
}

.page-subtitle {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-600);
    margin: 0;
    margin-top: 4px; /* A little space from the title */
}

#ds-no-display {
    font-weight: 600;
    color: var(--primary-blue);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* --- Prominent Trip Category --- */
.trip-category-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

/* --- Modern Floating Label Form Group --- */
.form-group {
    position: relative;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 22px var(--space-4) 8px var(--space-4);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    background-color: var(--gray-50);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    background-color: var(--white);
}

.form-group label {
    position: absolute;
    top: 16px;
    left: var(--space-4);
    color: var(--gray-600);
    pointer-events: none;
    transition: all var(--transition-fast);
    background-color: var(--gray-50);
    padding: 0 var(--space-2);
}

.form-group input:focus+label,
.form-group input:not(:placeholder-shown)+label,
.form-group textarea:focus+label,
.form-group textarea:not(:placeholder-shown)+label,
.form-group input[type="date"]+label,
.form-group input[type="time"]+label,
.form-group select+label {
    top: -1px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary-blue);
    background-color: var(--white);
}

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

/* --- Table-based Layouts --- */
.main-body-table {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
}

.left-details,
.right-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

@media (min-width: 1024px) {
    .main-body-table {
        grid-template-columns: 1fr 1fr;
    }
}

.usage-table .usage-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

/* --- Signature Area --- */
.footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.signature-area {
    width: 100%;
    max-width: 450px;
    /* Add this to prevent it from getting too wide */
    margin: 0 auto;
    /* Add this to center it within the footer */
    text-align: center;
}

.signature-box {
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    height: 150px;
    margin-top: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--gray-400);
    background-color: var(--gray-50);
    overflow: hidden;
}

.signature-image {
    width: 100%;
    height: 100%;
    display: none;
    object-fit: contain;
}

@media (min-width: 768px) {
    .footer {
        flex-direction: row;
    }
}




/* --- Signature Modal --- */
#signature-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    padding: var(--space-4);
}

#signature-modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 1.5rem;
    text-align: center;
    width: 100%;
    max-width: 450px;
}

#signature-canvas {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    width: 100%;
    height: 200px;
}

.modal-buttons {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.modal-buttons button {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-save {
    background-color: var(--primary-blue);
    color: white;
}

.btn-clear,
.btn-cancel {
    background-color: var(--gray-200);
    color: var(--gray-700);
}

/* --- PRINT STYLES --- */
@media print {
    body {
        background-color: #fff;
        padding: 0;
        margin: 0;
        font-size: 9pt;
        color: #000;
    }

    .admin-layout,
    .action-buttons-container,
    #signature-modal {
        display: none !important;
    }

    .duty-slip-print {
        display: block !important;
        margin: 20px;
    }

    .print-main-table {
        width: 100%;
        border-collapse: collapse;
        border: 2px solid #000;
    }

    .print-main-table>tbody>tr>td {
        border-bottom: 2px solid #000;
        padding: 0;
        vertical-align: top;
    }

    .print-main-table>tbody:last-child>tr>td {
        border-bottom: none;
    }

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

    .print-header-table td {
        padding: 5px;
        vertical-align: middle;
    }

    .logo-print {
        max-height: 70px;
    }

    .p-h-center {
        width: 15%;
        text-align: center;
        font-weight: bold;
        font-size: 1.4em;
        border-right: 2px solid #000;
    }

    .p-h-right {
        width: 30%;
    }

    .p-h-right table {
        width: 100%;
        border-collapse: collapse;
        border: 1px solid #000;
    }

    .p-h-right table td {
        padding: 4px;
        border-bottom: 1px solid #000;
    }

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

    .p-b-left {
        width: 55%;
    }

    .p-b-right {
        width: 45%;
        border-left: 2px solid #000;
    }

    .field-table {
        width: 100%;
        line-height: 1.5;
    }

    .field-table .label {
        width: 120px;
    }

    .field-table .value span,
    .field-table .value textarea {
        display: block;
        border-bottom: 1px dotted #ccc;
        min-height: 1.2em;
    }

    .field-table textarea {
        border: none;
        background: transparent;
        width: 100%;
        resize: none;
    }

    .print-usage-table,
    .print-footer-table {
        width: 100%;
        border-collapse: collapse;
    }

    .usage-left-panel {
        width: 65%;
        border-right: 2px solid #000;
    }

    .left-grid {
        width: 100%;
        text-align: left;
    }

    .left-grid td {
        border: 1px solid #000;
        padding: 4px;
    }

    .customer-usage-box {
        border: 1px solid #000;
        margin: 5px;
        padding: 5px;
        height: calc(100% - 10px);
    }

    .p-f-auth,
    .p-f-guest {
        width: 35%;
        text-align: center;
        height: 80px;
    }

    .p-f-routing {
        width: 30%;
        border-left: 1px solid #000;
        border-right: 1px solid #000;
    }

    .signature-display {
        max-height: 45px;
        max-width: 140px;
    }
}

@keyframes blink-error {
    50% {
        border-color: #ef4444;
    }
}

/* --- Floating Action Button (FAB) Styles --- */
.input-error {
    border-color: #f87171 !important;
    animation: blink-error 1s ease-in-out;
}

/* --- Button Submitting State --- */
.action-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: scale(0.98);
    /* Pressed effect */
}

.fa-spinner {
    animation: spin 1s linear infinite;
}

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

/* --- Responsive Save Button --- */
.action-buttons-container-simplified {
    display: flex;
    justify-content: flex-end;
    padding: 1rem;
}

.action-button-single {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background-color: #4F46E5;
    /* Primary blue */
    color: white;
    border: none;
    border-radius: 50px;
    /* Rounded pill shape */
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-button-single .icon {
    margin-right: 8px;
    font-size: 1.1em;
}

/* Mobile styles */
@media (max-width: 768px) {
    .action-buttons-container-simplified {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1000;
    }

    .action-button-single {
        min-width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 50%;
    }

    .action-button-single .text {
        display: none;
    }

    .action-button-single .icon {
        margin-right: 0;
    }
}

/* Outstation Strategic Alerts */
.outstation-warning {
    border-color: var(--danger-color) !important;
    background-color: #fff1f2 !important;
}

.category-select {
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
}

/* --- TRIP CATEGORY SELECTOR STYLING --- */
.trip-category-group {
    margin-bottom: 0; /* No longer needed as it's in a container */
}

.category-select {
    width: 100%;
    padding: 22px var(--space-4) 8px var(--space-4);
    border: 2px solid var(--primary-blue) !important; /* Bold border for the brain of the form */
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    background-color: var(--white);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.category-select:focus {
    box-shadow: 0 0 0 4px var(--primary-light); /* Established primary light variable */
    outline: none;
}

/* Logic Signal: Color changes based on category to prevent errors */
#trip-category option[value="Outstation"] {
    color: var(--secondary-teal); /* Distinct teal for Outstation */
}

#trip-category option[value="Local"] {
    color: var(--primary-blue);
}

/* Strategic Warning: Applied via JS when Outstation Min KM isn't met */
.outstation-warning {
    border-color: var(--danger-color) !important;
    background-color: #fff1f2 !important; /* Soft red alert */
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0px rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0px rgba(239, 68, 68, 0); }
}