/* ============================================
   E-FUEL SYSTEM - RESPONSIVE CSS
   Mobile-First Responsive Design
   ============================================ */

/* ============================================
   MOBILE SIDEBAR & NAVIGATION
   ============================================ */

/* Mobile Sidebar Toggle Button */
.sidebar-toggle {
    padding: 0;
    border: none;
    background: none;
    line-height: 1;
}

.sidebar-toggle:hover {
    opacity: 0.7;
}

.sidebar-toggle:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Enhanced Table Responsiveness */
.table-responsive {
   /* position: relative;*/
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.main-content { 
	margin-left: var(--sidebar-width); 
	min-height: 100vh;
	background: #f8f9fa;
}

/* ============================================
   MOBILE FIRST: 767px and below
   ============================================ */
@media (max-width: 767px) {

	.main-content {
       margin-left: 0px;
	}
    /* ----- SIDEBAR & NAVIGATION ----- */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050;
        width: 280px;
        will-change: transform;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
        z-index: 1050;
    }

    /* Ensure top-bar is below sidebar on mobile */
    .top-bar {
        position: relative;
        z-index: 1000;
    }

    /* ----- LAYOUT ----- */
    .main-content {
        margin-left: 0;
    }

    .top-bar {
        padding: 8px 12px;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .top-bar h5 {
        font-size: 0.95rem;
        flex: 1;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content-area {
        padding: 12px;
    }

    /* ----- CARDS ----- */
    .stat-card {
        margin-bottom: 12px;
        padding: 12px;
    }

    .stat-card-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
        min-width: 36px;
    }

    /* ----- GRID SYSTEM ----- */
    .row .col-md-3,
    .row .col-md-4,
    .row .col-md-6,
    .row .col-md-8 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* ----- TABLES ----- */
    .table-responsive {
        background:
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
            radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
        background-repeat: no-repeat;
        background-color: white;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-position: 0 0, 100%, 0 0, 100%;
        background-attachment: local, local, scroll, scroll;
    }

    .table {
        font-size: 0.85rem;
        /*min-width: 800px;*/
        margin-bottom: 0;
    }

    .table th,
    .table td {
        padding: 6px 8px;
        white-space: nowrap;
        vertical-align: middle;
    }

    /* Override for table cells in stat-cards on mobile - allow text wrapping */
    .stat-card .table td,
    .stat-card .table th {
        white-space: normal !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Sticky first column for context */
    .table thead th:first-child,
    .table tbody td:first-child {
        position: sticky;
        left: 0;
        background-color: white;
        z-index: 10;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    }

    .table thead th:first-child {
        z-index: 11;
        background-color: #f8f9fa;
    }

    /* Sticky last column for actions */
    .table th:last-child,
    .table td:last-child {
        position: sticky;
        right: 0;
        background-color: white;
        box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    }

    .table thead th:last-child {
        background-color: #f8f9fa;
    }

    /* Table scroll hint */
    .table-responsive::after {
        content: "← Swipe to see more →";
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: #6c757d;
        padding: 8px;
        background: #f8f9fa;
        border-top: 1px solid #dee2e6;
    }

    .table-responsive.scrolled::after {
        display: none;
    }

    /* ----- FORMS ----- */
    .form-label {
        margin-bottom: 6px;
        font-weight: 500;
        font-size: 0.9rem;
    }

    .form-control,
    .form-select {
        min-height: 40px;
        font-size: 0.95rem;
    }

    .form-select {
        background-size: 16px 12px;
        padding-right: 35px;
    }

    .form-check-input {
        width: 1.25em;
        height: 1.25em;
        margin-top: 0.125em;
    }

    .form-check-label {
        padding-left: 0.5rem;
    }

    .row.mb-3 .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        margin-bottom: 12px;
    }

    /* Stack button groups */
    .d-grid.gap-2.d-md-flex {
        display: grid !important;
        gap: 8px;
    }

    .d-grid.gap-2.d-md-flex .btn {
        width: 100%;
    }

    /* ----- BUTTONS ----- */
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .btn-group .btn {
        min-width: 36px;
        min-height: 36px;
    }

    .btn-sm {
        min-width: 36px;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* ----- PAGE HEADERS ----- */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > div {
        width: 100%;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 h2 {
        font-size: 1.35rem;
        margin-bottom: 0;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 .btn {
        width: 100%;
        justify-content: center;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child {
        display: flex;
        gap: 8px;
        width: 100%;
        flex-wrap: wrap;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child .btn {
        flex: 1;
        font-size: 0.85rem;
        min-width: 100px;
    }

    /* ----- ALERTS ----- */
    .alert {
        font-size: 0.85rem;
        padding: 10px;
    }

    /* ----- BADGES ----- */
    .badge {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    /* ----- ICONS ----- */
    .table .bi,
    .bi {
        font-size: 0.9rem;
    }

    /* ----- EMPTY STATES ----- */
    .text-center.text-muted.py-5,
    .text-center.text-muted.py-4 {
        padding: 2rem 1rem !important;
    }

    .text-center.text-muted i[style*="font-size"] {
        font-size: 3rem !important;
    }

    .text-center.text-muted p {
        font-size: 0.95rem;
    }

    /* ----- DROPDOWN ----- */
    .dropdown-menu {
        font-size: 0.95rem;
        min-width: 180px;
    }

    /* ----- STAT CARD SPECIFICS ----- */
    .stat-card .d-flex {
        gap: 12px;
    }

    .stat-card .d-grid {
        gap: 8px !important;
    }

    .stat-card .table-sm {
        font-size: 0.8rem;
    }

    .stat-card .table-sm td {
        padding: 6px 4px;
    }
}

/* ============================================
   TABLET: 768px - 991px
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {
    .content-area {
        padding: 16px;
    }

    .table {
        font-size: 0.85rem;
    }
}

/* ============================================
   TOUCH IMPROVEMENTS: Up to 991px
   ============================================ */
@media (max-width: 991px) {
    /* Larger touch targets */
    .btn-sm {
        min-width: 36px;
        min-height: 36px;
        padding: 6px 10px;
    }

    .table .btn-group .btn {
        padding: 5px 8px;
    }

    .form-control,
    .form-select {
        min-height: 40px;
        font-size: 0.95rem;
    }

    /* Better tap targets for links */
    a {
        min-height: 30px;
        display: inline-flex;
        align-items: center;
    }
}

/* ============================================
   LANDSCAPE PHONE OPTIMIZATION
   ============================================ */
@media (max-width: 767px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }

    .content-area {
        padding: 8px 12px;
    }

    .stat-card {
        padding: 10px;
    }
}

/* ============================================
   VERY SMALL DEVICES: 375px and below
   ============================================ */
@media (max-width: 375px) {
    .top-bar h5 {
        font-size: 0.9rem;
    }

    .table {
        font-size: 0.8rem;
    }

    .btn {
        font-size: 0.85rem;
    }
}

/* ============================================
   AUTH PAGES MOBILE RESPONSIVENESS
   ============================================ */
@media (max-width: 576px) {
    /* Auth Container */
    .auth-container {
        padding: 12px;
    }

    .auth-card {
        max-width: 100%;
    }

    .auth-header {
        padding: 24px 16px;
    }

    .auth-header img {
        max-width: 150px;
    }

    .auth-header h2 {
        font-size: 1.35rem;
    }

    .auth-body {
        padding: 24px 16px;
    }

    /* Legacy classes for backwards compatibility */
    .login-container,
    .forgot-container,
    .reset-container {
        max-width: 100%;
    }

    .login-header,
    .forgot-header,
    .reset-header {
        padding: 16px;
    }

    .login-header h2,
    .forgot-header h2,
    .reset-header h2 {
        font-size: 1.35rem;
    }

    .login-body {
        padding: 20px 16px;
    }

    .forgot-container .p-4,
    .reset-container .p-4 {
        padding: 20px 16px !important;
    }
}

/* ============================================
   MOBILE CARD LAYOUT FOR LISTING PAGES
   Replaces tables with cards on mobile devices
   ============================================ */

/* Hide table on mobile, show on desktop */
@media (max-width: 767px) {
    .table-responsive {
        display: none !important;
    }

    .mobile-card-view {
        display: block !important;
    }
}

@media (min-width: 768px) {
    .mobile-card-view {
        display: none !important;
    }
}

/* Mobile Card Container */
.mobile-card-view {
    display: none;
}

/* Individual Mobile Card */
.mobile-card {
    background: white;
    border-radius: var(--radius-lg, 12px);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
    border: 1px solid #e2e8f0;
    transition: var(--transition-base, 200ms ease);
}

.mobile-card:hover {
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0,0,0,0.1));
    transform: translateY(-2px);
}

/* Card Header */
.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.mobile-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800, #1E293B);
    margin: 0;
    flex: 1;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mobile-card-badge {
    margin-left: 8px;
    flex-shrink: 0;
}

/* Card Body */
.mobile-card-body {
    margin-bottom: 12px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.mobile-card-row:last-child {
    border-bottom: none;
}

.mobile-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600, #64748B);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    min-width: 100px;
    white-space: normal;
    word-wrap: break-word;
}

.mobile-card-value {
    font-size: 0.875rem;
    color: var(--gray-800, #1E293B);
    text-align: right;
    flex: 1;
    word-break: break-word;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mobile-card-value strong {
    font-weight: 600;
    color: var(--primary-blue, #1B96D4);
}

/* Card Footer - Actions */
.mobile-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.mobile-card-footer .btn {
    flex: 1;
    min-width: calc(50% - 4px);
    font-size: 0.8125rem;
    padding: 8px 12px;
}

.mobile-card-footer .btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

/* Full width buttons */
.mobile-card-footer .btn-block {
    flex: 1 1 100%;
}

/* Icon-only buttons for compact view */
.mobile-card-footer .btn-icon {
    min-width: auto;
    flex: 0 0 auto;
    padding: 8px 12px;
}

/* Compact info display */
.mobile-card-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-card-info-item {
    display: flex;
    align-items: flex-start;
    font-size: 0.8125rem;
    color: var(--gray-700, #334155);
}

.mobile-card-info-item i {
    margin-right: 6px;
    margin-top: 2px;
    color: var(--gray-500, #64748B);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.mobile-card-info-item div {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    flex: 1;
}

/* Status indicators */
.mobile-card-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Highlighted values */
.mobile-card-highlight {
    background: #f0f9ff;
    padding: 8px 12px;
    border-radius: var(--radius-sm, 6px);
    border-left: 3px solid var(--primary-blue, #1B96D4);
    margin: 8px 0;
}

.mobile-card-highlight-label {
    font-size: 0.6875rem;
    color: var(--gray-600, #64748B);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    white-space: normal;
    word-wrap: break-word;
}

.mobile-card-highlight-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-blue, #1B96D4);
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Empty state for mobile */
.mobile-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500, #64748B);
}

.mobile-empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.mobile-empty-state p {
    margin: 0;
    font-size: 0.875rem;
}

/* Responsive action buttons */
@media (max-width: 375px) {
    .mobile-card-footer .btn {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .mobile-card-footer .btn-icon {
        flex: 1 1 calc(33.333% - 6px);
    }

    /* Account Information and Order Information tables on mobile */
    .stat-card table.table-sm {
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }

    .stat-card table.table-sm td {
        display: block;
        width: 100%;
        padding: 8px 12px;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        white-space: normal !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .stat-card table.table-sm td:first-child {
        background-color: #f8fafc;
        font-weight: 600;
        color: #64748b;
        padding-bottom: 4px;
        border-bottom: none;
        font-size: 0.8125rem;
        white-space: normal !important;
    }

    .stat-card table.table-sm td:last-child {
        padding-top: 4px;
        padding-bottom: 12px;
        font-weight: 500;
        color: #1e293b;
        white-space: normal !important;
    }

    .stat-card table.table-sm tr {
        display: block;
        margin-bottom: 8px;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 4px;
    }

    .stat-card table.table-sm tr:last-child {
        border-bottom: none;
    }

    /* Ensure badges and special elements display properly in mobile tables */
    .stat-card table.table-sm .badge {
        display: inline-block;
        margin-top: 4px;
    }

    /* Better spacing for sections with multiple tables */
    .stat-card .row.mb-3 {
        margin-bottom: 1.5rem !important;
    }

    /* Stack columns on mobile for better readability */
    .stat-card .col-md-6 {
        margin-bottom: 1rem;
    }

    /* Horizontal rules on mobile */
    .stat-card hr {
        margin: 1.5rem 0;
        border-color: #e2e8f0;
    }
}
