/* ==========================================================================
   DESKTOP STYLING (Web Viewports >= 992px)
   ========================================================================== */

/* 1. Header & Navigation Tabs */
.desk-header {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

#deskTab .nav-link {
    border-radius: 8px 8px 0 0;
    padding: 0.65rem 1.25rem;
    font-size: 0.92rem;
    transition: all 0.15s ease-in-out;
}

#deskTab .nav-link:not(.active) {
    background-color: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0 #e2e8f0 transparent;
}

#deskTab .nav-link.active {
    background-color: #ffffff;
    border-top: 3px solid #0d6efd;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.03);
}

#deskTab #operator-tab.active {
    border-top: 3px solid #dc3545;
}

/* 2. Core Cards & Diagnostics Containers */
.card {
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.card-header {
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* 3. Call Initiator Radio Buttons */
#callerBehalfGroup {
    display: flex;
    gap: 2px;
}

#callerBehalfGroup .btn {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    border-radius: 6px !important;
}

.btn-check:checked + .btn-outline-secondary {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: #ffffff !important;
}

/* 4. Form Controls & Focus States */
.form-select-sm, .form-control-sm {
    border-radius: 6px;
    border-color: #cbd5e1;
}

.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 5. Dense Table Formatting */
.table-responsive {
    border-radius: 0 0 8px 8px;
}

.table > :not(caption) > * > * {
    padding: 0.65rem 0.75rem;
}

.table thead th {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748b;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

/* ==========================================================================
   TICKET STATUS BADGES (OPEN = RED, CLOSED = GREEN)
   ========================================================================== */
.badge-ticket-open {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca !important;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.badge-ticket-open:hover {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}

.badge-ticket-closed {
    background-color: #ecfdf5 !important;
    color: #059669 !important;
    border: 1px solid #a7f3d0 !important;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.badge-ticket-closed:hover {
    background-color: #d1fae5 !important;
    color: #047857 !important;
    border-color: #6ee7b7 !important;
}

/* ==========================================================================
   MOBILE RESPONSIVE STYLING (Viewports <= 767.98px)
   ========================================================================== */

@media (max-width: 767.98px) {
    /* 1. Header & Action Buttons */
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .desk-header h3 {
        font-size: 1.25rem;
    }

    .btn-group {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    .btn-group > .btn {
        flex: 1 1 auto;
        padding: 0.4rem 0.6rem;
        font-size: 0.78rem;
        text-align: center;
    }

    /* 2. Horizontal Scrollable Nav Tabs */
    #deskTab {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    #deskTab .nav-item {
        white-space: nowrap;
        flex-shrink: 0;
    }

    #deskTab .nav-link {
        padding: 0.5rem 0.85rem;
        font-size: 0.84rem;
    }

    /* 3. Search Bar Stacking */
    form[action*="call_desk"] .col-md-10,
    form[action*="call_desk"] .col-md-2 {
        width: 100%;
    }

    form[action*="call_desk"] .input-group input {
        font-size: 0.92rem;
    }

    /* 4. Multi-button Radio Grid (2x2 Layout on Phones) */
    #callerBehalfGroup {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    #callerBehalfGroup .btn {
        border-radius: 6px !important;
        width: 100%;
        padding: 0.5rem 0.25rem;
    }

    /* 5. Mobile Tables: Safe Touch Scroll */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table {
        min-width: 620px; /* Prevents cell distortion; allows clean lateral swipe */
    }

    /* 6. Form Padding & Inputs (Prevents iOS zoom on focus) */
    .form-control, .form-select {
        font-size: 16px !important;
    }

    .form-control-sm, .form-select-sm {
        font-size: 14px !important;
    }

    /* 7. Call History Filter Panel Stacking */
    form[action*="call_history"] .col-md-2,
    form[action*="call_history"] .col-md-3,
    form[action*="call_history"] .col-md-1 {
        width: 100% !important;
    }

    form[action*="call_history"] button[type="submit"] {
        margin-top: 0.5rem;
        padding: 0.55rem !important;
    }
}