/* ============================================================================
   RESPONSIVE STYLES
   ============================================================================
   All media queries extracted from style.css for better organization
   ============================================================================ */

/* ===== SELECT2 RESPONSIVE ===== */
@media (max-width: 768px) {
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
        max-width: 150px;
    }
    
    .select2-container--default .select2-dropdown {
        margin-top: 4px;
    }
    
    .select2-container--default .select2-search--dropdown .select2-search__field {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
}

/* ===== SIDEBAR RESPONSIVE ===== */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        z-index: 1040;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .content {
        margin-left: 0;
    }
    
    .content.expanded {
        margin-left: 0;
    }
}

@media (max-width: 992px) {
    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar-toggle {
        display: none;
    }
}

/* Desktop sidebar hide on mobile */
@media (max-width: 991.98px) {
    .sidebar {
        display: none !important;
    }
    
    .content {
        margin-left: 0 !important;
    }
}

/* ===== TICKET VIEW RESPONSIVE ===== */
@media (max-width: 768px) {
    .thread-message {
        padding: 1rem;
    }
    
    .message-header .row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .message-meta {
        text-align: left;
    }
    
    .email-body {
        max-height: 300px;
    }
}

/* ===== FILE UPLOAD RESPONSIVE ===== */
@media (max-width: 768px) {
    .upload-area {
        padding: 1.5rem 1rem;
    }
    
    .upload-content h6 {
        font-size: 0.9rem;
    }
    
    .upload-content p {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .file-upload-container {
        padding: 1.5rem;
    }
    
    .file-upload-icon {
        font-size: 2.5rem;
    }
    
    .file-item {
        padding: 0.5rem;
    }
    
    .file-actions {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* ===== ERROR PAGE RESPONSIVE ===== */
@media (max-width: 768px) {
    .error-content {
        animation-duration: 0.6s;
    }
    
    .error-code {
        animation-duration: 0.8s;
    }
    
    .error-title,
    .error-message,
    .error-description,
    .error-actions {
        animation-duration: 0.4s;
    }
}

/* ===== NOTIFICATIONS RESPONSIVE ===== */
@media (max-width: 768px) {
    .page-notifications .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .page-notifications .notification-item {
        padding: 12px !important;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-notifications .notification-icon {
        margin-right: 0 !important;
        margin-bottom: 8px;
    }
    
    .page-notifications .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-notifications .mb-0 {
        margin-bottom: 0 !important;
    }
    
    .page-notifications .ms-2 {
        margin-left: 0 !important;
        margin-top: 4px;
    }
    
    .page-notifications .text-md-end {
        text-align: left !important;
        margin-top: 8px;
    }
    
    .page-notifications .col-md-3 {
        margin-bottom: 15px;
    }
    
    .page-notifications .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* Notification dropdown mobile alignment */
@media (max-width: 991.98px) {
    .notification-dropdown {
        width: 300px !important;
        max-width: calc(100vw - 2rem);
        right: 0 !important;
        left: auto !important;
        position: fixed !important;
        top: 60px !important;
        z-index: 1055 !important;
        transform: none !important;
        margin: 0 !important;
    }
    
    /* Ensure proper positioning for mobile navbar */
    .navbar-nav .dropdown-menu {
        position: fixed !important;
        top: 60px !important;
        right: 1rem !important;
        left: auto !important;
        transform: none !important;
        margin: 0 !important;
    }
    
    /* Mobile notification dropdown specific styling */
    .notification-dropdown {
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
        border: 1px solid rgba(0, 0, 0, 0.1) !important;
        border-radius: 0.5rem !important;
    }
    
    /* Mobile notification items */
    .notification-dropdown .notification-item {
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    }
    
    
    /* Mobile notification footer */
    .notification-dropdown .dropdown-footer {
        padding: 0.5rem 1rem !important;
        background-color: #f8f9fa !important;
        border-top: 1px solid #dee2e6 !important;
    }
    
    /* Mobile notification content */
    .notification-dropdown .notification-content {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    /* Mobile notification icon sizing */
    .notification-dropdown .notification-icon {
        width: 2rem !important;
        height: 2rem !important;
        margin-right: 0.75rem !important;
    }
    
    /* Mobile notification text sizing */
    .notification-dropdown .notification-title {
        font-size: 0.875rem !important;
        font-weight: 600 !important;
    }
    
    .notification-dropdown .notification-message {
        font-size: 0.8125rem !important;
        line-height: 1.4 !important;
    }
    
    .notification-dropdown .notification-time {
        font-size: 0.75rem !important;
    }
}

/* Tablet specific adjustments */
@media (max-width: 768px) and (min-width: 576px) {
    .notification-dropdown {
        width: 280px !important;
        max-width: calc(100vw - 1rem) !important;
        right: 0.5rem !important;
    }
}

/* Small mobile adjustments */
@media (max-width: 575.98px) {
    .notification-dropdown {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem) !important;
        right: 0.5rem !important;
        left: 0.5rem !important;
    }
    
    .navbar-nav .dropdown-menu {
        right: 0.5rem !important;
        left: 0.5rem !important;
    }
    
    /* Smaller notification items for small screens */
    .notification-dropdown .notification-item {
        padding: 0.5rem 0.75rem !important;
    }
    
    .notification-dropdown .notification-icon {
        width: 1.75rem !important;
        height: 1.75rem !important;
        margin-right: 0.5rem !important;
    }
    
    .notification-dropdown .notification-title {
        font-size: 0.8rem !important;
    }
    
    .notification-dropdown .notification-message {
        font-size: 0.75rem !important;
    }
    
    .notification-dropdown .notification-time {
        font-size: 0.7rem !important;
    }
}

/* Mobile notification dropdown backdrop and interaction improvements */
@media (max-width: 991.98px) {
    /* Ensure dropdown doesn't get cut off */
    .notification-dropdown {
        max-height: calc(100vh - 80px) !important;
        overflow-y: auto !important;
    }
    
    /* Better touch targets for mobile */
    .notification-dropdown .notification-item {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    
    
    /* Mobile notification badge positioning */
    .navbar-nav .nav-link .badge {
        font-size: 0.7rem !important;
        padding: 0.25em 0.5em !important;
        min-width: 18px !important;
        height: 18px !important;
        line-height: 1 !important;
    }
    
    /* Ensure proper z-index layering */
    .notification-dropdown {
        z-index: 1055 !important;
    }
    
    /* Mobile dropdown animation */
    .notification-dropdown.show {
        animation: slideDownMobile 0.2s ease-out !important;
    }
    
    @keyframes slideDownMobile {
        from {
            opacity: 0;
            transform: translateY(-10px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
    
    /* Prevent dropdown from being hidden behind other elements */
    .navbar-nav .dropdown {
        position: static !important;
    }
    
    /* Mobile notification list scrolling */
    .notification-dropdown #notificationList {
        max-height: 250px !important;
        overflow-y: auto !important;
    }
}

/* ===== STATION AND CATEGORY RESPONSIVE ===== */
@media (max-width: 768px) {
    .station-icon,
    .category-icon {
        width: 32px;
        height: 32px;
    }
    
    .station-icon i,
    .category-icon i {
        font-size: 1rem;
    }
    
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .modal-dialog {
        margin: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .btn-group .btn {
        margin: 0;
        border-radius: 0.375rem;
    }
}

/* ===== RESPONSIVE ACTION BUTTONS (icon-only on mobile, label on md+) ===== */
.btn-responsive-action {
    min-width: 2.75rem;
}

@media (min-width: 768px) {
    .btn-responsive-action {
        min-width: 160px;
    }
}

/* ===== TICKET LIST RESPONSIVE ===== */
/* Disable fixed table layout on mobile/tablet */
@media (max-width: 991.98px) {
    .table-responsive table {
        table-layout: auto !important;
    }
    
    /* Title column minimum width on mobile/tablet */
    .tickets-list.table-responsive table th:nth-child(4),
    .tickets-list.table-responsive table td:nth-child(4) {
        min-width: 400px !important;
    }
}

/* ===== DASHBOARD SEARCH RESULTS RESPONSIVE ===== */
@media (max-width: 991.98px) {
    /* Disable fixed table layout on mobile/tablet */
    .dashboard-results-table {
        table-layout: auto !important;
        min-width: 800px; /* Ensure horizontal scroll on smaller screens */
    }
    
    /* Column widths for better mobile display */
    .dashboard-results-table .col-id {
        width: 60px;
        min-width: 60px;
    }
    
    .dashboard-results-table .col-reporter {
        width: 140px;
        min-width: 140px;
    }
    
    .dashboard-results-table .col-title {
        width: 200px;
        min-width: 200px;
    }
    
    .dashboard-results-table .col-station {
        width: 100px;
        min-width: 100px;
    }
    
    .dashboard-results-table .col-category {
        width: 100px;
        min-width: 100px;
    }
    
    .dashboard-results-table .col-subcategory {
        width: 100px;
        min-width: 100px;
    }
    
    .dashboard-results-table .col-remarks {
        width: 120px;
        min-width: 120px;
    }
    
    .dashboard-results-table .col-status {
        width: 80px;
        min-width: 80px;
    }
    
    /* Ensure table-responsive wrapper allows horizontal scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better spacing for filter cards on mobile */
    .card-body .row.g-3 {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .card-body .row.g-3 > [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Mobile specific adjustments (below 768px) */
@media (max-width: 767.98px) {
    /* Smaller font sizes for mobile */
    .dashboard-results-table {
        font-size: 0.875rem;
    }
    
    .dashboard-results-table th,
    .dashboard-results-table td {
        padding: 0.5rem 0.375rem;
    }
    
    /* Compact badge sizes */
    .dashboard-results-table .badge {
        font-size: 0.75rem;
        padding: 0.25em 0.5em;
    }
    
    /* Smaller text in cells */
    .dashboard-results-table .text-muted.small {
        font-size: 0.75rem;
    }
    
    /* Adjust column widths for very small screens */
    .dashboard-results-table .col-id {
        width: 50px;
        min-width: 50px;
    }
    
    .dashboard-results-table .col-reporter {
        width: 120px;
        min-width: 120px;
    }
    
    .dashboard-results-table .col-title {
        width: 200px;
        min-width: 200px;
    }
    
    .dashboard-results-table .col-station,
    .dashboard-results-table .col-category,
    .dashboard-results-table .col-subcategory {
        width: 90px;
        min-width: 90px;
    }
    
    .dashboard-results-table .col-remarks {
        width: 100px;
        min-width: 100px;
    }
    
    .dashboard-results-table .col-status {
        width: 70px;
        min-width: 70px;
    }
    
    /* Card header adjustments */
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    
    .card-header h6 {
        margin-bottom: 0;
    }
    
    /* Filter cards full width on mobile */
    .card-body .col-md-4 {
        margin-bottom: 0.75rem;
    }
}

/* ===== NAVBAR RESPONSIVE ===== */
/* Mobile navbar brand spacing */
@media (max-width: 991.98px) {
    .navbar-brand {
        margin-left: 0;
    }
    
    .navbar-nav {
        gap: 0.5rem;
    }
}

/* Mobile navbar grid layout */
@media (max-width: 767.98px) {
    .navbar-container {
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        grid-template-rows: auto auto;
        gap: 0.5rem 0.75rem;
        align-items: center;
        width: 100%;
        padding: 0.5rem 0;
    }
    
    /* First row: Toggle, Brand, Dark Mode, Notification */
    .navbar-mobile-toggle {
        grid-column: 1;
        grid-row: 1;
        margin: 0;
        padding: 0.25rem 0.5rem;
    }
    
    .navbar-mobile-brand {
        grid-column: 2;
        grid-row: 1;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 1rem;
    }
    
    .navbar-mobile-theme {
        grid-column: 3;
        grid-row: 1;
        margin: 0;
    }
    
    .navbar-mobile-theme .theme-toggle {
        padding: 0.25rem 0.5rem;
        border: none;
        background: transparent;
    }
    
    .navbar-mobile-notification {
        grid-column: 4;
        grid-row: 1;
        margin: 0;
    }
    
    .navbar-mobile-notification .nav-link {
        padding: 0.25rem 0.5rem;
    }
    
    /* Second row: User Dropdown (full width) */
    .navbar-mobile-user {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        margin: 0;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        padding-top: 0.5rem;
    }
    
    .navbar-mobile-user .nav-link {
        justify-content: flex-end;
        width: 100%;
        padding: 0.5rem;
    }
    
    /* Hide desktop layout on mobile */
    .navbar-nav-desktop {
        display: none !important;
    }
}

/* Tablet and desktop: Keep original flex layout */
@media (min-width: 768px) {
    .navbar-container {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }
    
    /* Reset grid positioning for desktop */
    .navbar-mobile-toggle,
    .navbar-mobile-brand,
    .navbar-mobile-theme,
    .navbar-mobile-notification,
    .navbar-mobile-user {
        position: static;
        grid-column: auto;
        grid-row: auto;
    }
    
    /* Hide mobile-specific elements on tablet/desktop */
    .navbar-mobile-theme,
    .navbar-mobile-notification,
    .navbar-mobile-user {
        display: none !important;
    }
    
    /* Show desktop layout */
    .navbar-nav-desktop {
        display: flex !important;
    }
}

