/* ========================================
   INVOICES PAGE - MOBILE RESPONSIVE STYLES
   Inspired by comparison-new.html approach
   ======================================== */

/* Desktop Table Styles */
.transactions-table {
    width: 100%;
    border-collapse: collapse;
}

.transactions-table thead tr {
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.transactions-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #fff;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transactions-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.transactions-table tbody tr {
    transition: background 0.2s ease;
}

.transactions-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Badge Styles */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-secondary {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
}

/* ========================================
   TABLET OPTIMIZATION (768px - 1024px)
   ======================================== */
@media (max-width: 1024px) {
    .transactions-table th,
    .transactions-table td {
        padding: 0.875rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .transactions-table th {
        font-size: 0.8rem;
    }
}

/* ========================================
   MOBILE OPTIMIZATION (max-width: 768px)
   Card-based layout for better mobile UX
   ======================================== */
@media (max-width: 768px) {
    /* Hide the table header on mobile */
    .transactions-table thead {
        display: none;
    }
    
    /* Make table body display as block */
    .transactions-table,
    .transactions-table tbody,
    .transactions-table tr {
        display: block;
        width: 100%;
    }
    
    /* Convert each row to a card */
    .transactions-table tbody tr {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        margin-bottom: 1rem;
        padding: 1rem;
        display: block;
        transition: all 0.3s ease;
    }
    
    .transactions-table tbody tr:hover {
        background: rgba(99, 102, 241, 0.08);
        border-color: rgba(99, 102, 241, 0.3);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    /* Style each cell as a row within the card */
    .transactions-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .transactions-table td:last-child {
        border-bottom: none;
    }
    
    /* Add labels before each cell using data attributes */
    .transactions-table td:before {
        content: attr(data-label);
        font-weight: 700;
        color: #888;
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.5px;
        min-width: 100px;
        flex-shrink: 0;
    }
    
    /* Value styling */
    .transactions-table td > * {
        text-align: right;
    }
    
    /* Special styling for transaction ID (make it prominent) */
    .transactions-table td:first-child {
        font-weight: 700;
        color: #6366f1;
        font-size: 0.95rem;
        padding-top: 0;
        margin-bottom: 0.5rem;
        border-bottom: 2px solid rgba(99, 102, 241, 0.2);
    }
    
    /* Adjust badge sizes for mobile */
    .badge {
        padding: 0.35rem 0.85rem;
        font-size: 0.7rem;
    }
    
    /* Make free text more prominent */
    .transactions-table td span[style*="color: #10b981"] {
        font-weight: 700;
        font-size: 1rem;
    }
    
    /* Stats grid mobile optimization */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    .stat-card {
        padding: 1.25rem !important;
    }
    
    .stat-card .label {
        font-size: 0.75rem !important;
    }
    
    .stat-card .value {
        font-size: 1.5rem !important;
    }
}

/* ========================================
   SMALL MOBILE (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {
    /* Stack stats cards vertically on very small screens */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Reduce card padding */
    .transactions-table tbody tr {
        padding: 0.875rem;
        margin-bottom: 0.875rem;
    }
    
    .transactions-table td {
        padding: 0.625rem 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .transactions-table td:before {
        min-width: auto;
        margin-bottom: 0.25rem;
    }
    
    .transactions-table td > * {
        text-align: left;
        width: 100%;
    }
    
    /* Adjust welcome banner */
    .welcome-banner h1 {
        font-size: 1.75rem !important;
    }
    
    .welcome-banner p {
        font-size: 0.9rem !important;
    }
    
    /* Smaller badges */
    .badge {
        padding: 0.3rem 0.7rem;
        font-size: 0.65rem;
    }
}

/* ========================================
   EXTRA SMALL MOBILE (max-width: 360px)
   ======================================== */
@media (max-width: 360px) {
    .transactions-table tbody tr {
        padding: 0.75rem;
    }
    
    .transactions-table td {
        padding: 0.5rem 0;
        font-size: 0.85rem;
    }
    
    .transactions-table td:before {
        font-size: 0.65rem;
    }
    
    .stat-card .value {
        font-size: 1.25rem !important;
    }
    
    .welcome-banner h1 {
        font-size: 1.5rem !important;
    }
}

/* ========================================
   LANDSCAPE MODE OPTIMIZATION
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-banner {
        padding: 1rem !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .transactions-table tbody tr {
        margin-bottom: 0.75rem;
    }
}

/* ========================================
   EMPTY STATE MOBILE
   ======================================== */
@media (max-width: 768px) {
    #emptyState {
        padding: 2rem 1rem !important;
    }
    
    #emptyState i {
        font-size: 3rem !important;
    }
    
    #emptyState h3 {
        font-size: 1.25rem !important;
    }
    
    #emptyState p {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   CONTAINER RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    #transactionsContainer {
        overflow-x: visible !important;
    }
    
    .card {
        border-radius: 12px !important;
    }
}

/* ========================================
   TOUCH OPTIMIZATION
   ======================================== */
@media (max-width: 768px) {
    /* Better touch targets */
    .transactions-table tbody tr {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    }
    
    /* Smooth scrolling */
    .transactions-table {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent text selection on tap */
    .transactions-table tbody tr {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* ========================================
   HIGH DPI SCREENS (Retina)
   ======================================== */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2),
       (max-width: 768px) and (min-resolution: 192dpi) {
    .transactions-table td {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}
