/* 
 * Mobile-Responsive CRM Quotes List for ERPAthos CRM
 * 
 * This CSS provides a mobile-friendly card layout for the CRM Quotes list
 * on small and medium screens while preserving the desktop table view on larger screens.
 * 
 * Breakpoints:
 * - Mobile: < 768px (card layout)
 * - Tablet: 768px - 1023px (card layout)
 * - Desktop: >= 1024px (table layout)
 */

/* ==========================================
   DEFAULT STYLES - Prevent FOUC
   ========================================== */
.crm-quotes-page .mobile-quotes-list {
    display: none;
}

/* ==========================================
   MOBILE: < 768px - Card Layout
   ========================================== */
@media (max-width: 767px) {
    /* Hide table on mobile */
    .crm-quotes-page .table-responsive {
        display: none !important;
    }

    /* Show mobile card list */
    .crm-quotes-page .mobile-quotes-list {
        display: block;
    }

    /* Quote card styling */
    .mobile-quote-card {
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        transition: transform 0.2s, box-shadow 0.2s;
        position: relative;
        overflow: hidden;
        cursor: pointer;
    }

    .mobile-quote-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    /* Card header with quote number and status */
    .mobile-quote-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
        gap: 8px;
    }

    .mobile-quote-number {
        font-weight: 700;
        font-size: 1.1rem;
        color: #212529;
        flex: 1;
    }

    .mobile-quote-ref {
        font-size: 0.875rem;
        color: #6c757d;
        margin-top: 2px;
    }

    /* Conversion badges container */
    .mobile-quote-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 4px;
    }

    /* Status badge positioning */
    .mobile-quote-status {
        align-self: flex-start;
    }

    /* Quote meta information */
    .mobile-quote-meta {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
    }

    .mobile-quote-info-row {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.875rem;
        color: #495057;
    }

    .mobile-quote-info-row i {
        width: 16px;
        text-align: center;
        color: #6c757d;
    }

    .mobile-quote-info-label {
        font-weight: 600;
        min-width: 100px;
    }

    .mobile-quote-info-value {
        flex: 1;
    }

    /* Amount display box */
    .mobile-quote-amounts {
        background: #f8f9fa;
        border-radius: 6px;
        padding: 12px;
        margin-bottom: 12px;
    }

    .mobile-quote-amount-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        font-size: 0.875rem;
    }

    .mobile-quote-amount-row.total {
        border-top: 2px solid #dee2e6;
        margin-top: 8px;
        padding-top: 8px;
    }

    .mobile-quote-amount-label {
        color: #6c757d;
        font-weight: 500;
    }

    .mobile-quote-amount-value {
        font-weight: 600;
        color: #212529;
    }

    .mobile-quote-amount-row.total .mobile-quote-amount-label {
        font-weight: 700;
        color: #212529;
    }

    .mobile-quote-amount-row.total .mobile-quote-amount-value {
        font-weight: 700;
        font-size: 1.1rem;
        color: #6610f2;
    }

    /* Expiry warning */
    .mobile-quote-expiry-warning {
        color: #dc3545;
        font-weight: 600;
    }

    /* Card actions */
    .mobile-quote-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-top: 12px;
    }

    .mobile-quote-actions .btn {
        font-size: 0.875rem;
        padding: 10px 12px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        border-radius: 6px;
        font-weight: 500;
    }

    .mobile-quote-actions .btn i {
        font-size: 1rem;
    }

    /* Ensure badges don't wrap awkwardly */
    .badge {
        white-space: nowrap;
        padding: 6px 10px;
        font-size: 0.75rem;
        font-weight: 600;
    }
}

/* ==========================================
   TABLET: 768px - 1023px
   ========================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Hide table on tablet */
    .crm-quotes-page .table-responsive {
        display: none !important;
    }

    /* Show mobile card list */
    .crm-quotes-page .mobile-quotes-list {
        display: block;
    }

    /* Tablet: 3 column layout for action buttons */
    .mobile-quote-actions {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Slightly larger cards on tablet */
    .mobile-quote-card {
        padding: 20px;
    }
}

/* ==========================================
   DESKTOP: >= 1024px - Show Table
   ========================================== */
@media (min-width: 1024px) {
    /* Show table on desktop */
    .crm-quotes-page .table-responsive {
        display: block !important;
    }

    /* Hide mobile cards on desktop */
    .crm-quotes-page .mobile-quotes-list {
        display: none !important;
    }
}

/* ==========================================
   EXTRA SMALL MOBILE: < 480px
   ========================================== */
@media (max-width: 479px) {
    .mobile-quote-card {
        padding: 12px;
        margin-bottom: 10px;
    }

    .mobile-quote-number {
        font-size: 1rem;
    }

    .mobile-quote-info-label {
        min-width: 80px;
        font-size: 0.8rem;
    }

    .mobile-quote-amount-row {
        font-size: 0.8rem;
    }

    .mobile-quote-amount-row.total .mobile-quote-amount-value {
        font-size: 1rem;
    }
}

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */
@media (prefers-color-scheme: dark) {
    html.dark-mode .mobile-quote-card {
        background: #2d3748;
        border-color: #4a5568;
        box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }

    html.dark-mode .mobile-quote-number {
        color: #f7fafc;
    }

    html.dark-mode .mobile-quote-ref {
        color: #a0aec0;
    }

    html.dark-mode .mobile-quote-info-row {
        color: #e2e8f0;
    }

    html.dark-mode .mobile-quote-info-row i {
        color: #a0aec0;
    }

    html.dark-mode .mobile-quote-amounts {
        background: #1a202c;
    }

    html.dark-mode .mobile-quote-amount-label {
        color: #a0aec0;
    }

    html.dark-mode .mobile-quote-amount-value {
        color: #e2e8f0;
    }

    html.dark-mode .mobile-quote-amount-row.total .mobile-quote-amount-label,
    html.dark-mode .mobile-quote-amount-row.total .mobile-quote-amount-value {
        color: #f7fafc;
    }

    html.dark-mode .mobile-quote-amount-row.total .mobile-quote-amount-value {
        color: #9f7aea;
    }

    html.dark-mode .mobile-quote-expiry-warning {
        color: #fc8181;
    }
}

/* ==========================================
   ACCESSIBILITY & TOUCH OPTIMIZATIONS
   ========================================== */
@media (max-width: 1023px) {
    /* Ensure touch targets are at least 44px */
    .mobile-quote-actions button,
    .mobile-quote-actions a {
        min-height: 44px;
        min-width: 44px;
    }

    /* Prevent zoom on iOS */
    input[type="text"],
    input[type="date"],
    input[type="number"],
    select {
        font-size: 16px !important;
    }

    /* Better focus indicators for keyboard navigation */
    .mobile-quote-card:focus-within {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }

    /* Smooth scrolling */
    .mobile-quotes-list {
        scroll-behavior: smooth;
    }
}
