/* 
 * Mobile-Responsive Contacts List for ERPAthos CRM
 * 
 * This CSS provides a mobile-friendly card layout for the Contacts list
 * on small and medium screens while preserving the desktop table view on larger screens.
 * 
 * Breakpoints:
 * - Mobile & Tablet: < 1024px (card layout)
 * - Desktop: >= 1024px (table layout)
 */

/* ==========================================
   DEFAULT STYLES - Prevent FOUC
   ========================================== */
.contacts-page .mobile-contacts-list {
    display: none;
}

/* ==========================================
   MOBILE: < 768px - Card Layout
   ========================================== */
@media (max-width: 767px) {
    /* Hide table on mobile */
    .contacts-page .table-responsive {
        display: none !important;
    }

    /* Show mobile card list */
    .contacts-page .mobile-contacts-list {
        display: block;
    }

    /* Contact card styling */
    .contacts-page .mobile-contact-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;
    }

    .contacts-page .mobile-contact-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    /* Card header with name and status badges */
    .contacts-page .mobile-contact-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
        gap: 8px;
    }

    .contacts-page .mobile-contact-name {
        font-weight: 700;
        font-size: 1.1rem;
        color: #212529;
        flex: 1;
        word-break: break-word;
    }

    .contacts-page .mobile-contact-title {
        font-size: 0.875rem;
        color: #6c757d;
        margin-top: 2px;
    }

    .contacts-page .mobile-contact-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: flex-start;
    }

    /* Contact meta information */
    .contacts-page .mobile-contact-meta {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
    }

    .contacts-page .mobile-contact-info-row {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.875rem;
        color: #495057;
    }

    .contacts-page .mobile-contact-info-row i {
        width: 16px;
        text-align: center;
        color: #6c757d;
    }

    .contacts-page .mobile-contact-info-label {
        font-weight: 600;
        min-width: 80px;
        color: #6c757d;
    }

    .contacts-page .mobile-contact-info-value {
        flex: 1;
        word-break: break-word;
    }

    /* Job information */
    .contacts-page .mobile-contact-job {
        display: flex;
        flex-direction: column;
        gap: 4px;
        margin-bottom: 12px;
        padding: 8px;
        background: #f8f9fa;
        border-radius: 4px;
    }

    .contacts-page .mobile-contact-job-title {
        font-weight: 600;
        color: #495057;
        font-size: 0.875rem;
    }

    .contacts-page .mobile-contact-department {
        font-size: 0.8rem;
        color: #6c757d;
    }

    /* Quick actions - call and mail buttons */
    .contacts-page .mobile-contact-quick-actions,
    .contacts-page .mobile-contact-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #dee2e6;
    }

    .contacts-page .mobile-contact-quick-actions {
        position: relative;
        z-index: 1;
    }

    .contacts-page .mobile-contact-quick-actions .btn,
    .contacts-page .mobile-contact-actions .btn {
        flex: 1;
        min-height: 44px;
        font-size: 0.9rem;
        padding: 8px 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
    }

    .contacts-page .mobile-contact-quick-actions .btn i,
    .contacts-page .mobile-contact-actions .btn i {
        font-size: 1.1rem;
    }

    .contacts-page .mobile-contact-quick-actions .btn-text,
    .contacts-page .mobile-contact-actions .btn-text {
        font-size: 0.75rem;
        line-height: 1;
    }

    /* Touch-optimized filters and search */
    .contacts-page .row.mb-3 > [class*="col-"] {
        margin-bottom: 10px;
    }

    .contacts-page .form-control,
    .contacts-page .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }

    .contacts-page .btn {
        min-height: 44px;
        padding: 12px 16px;
    }

    /* Page title optimization */
    .contacts-page h3 {
        font-size: 1.5rem;
        text-align: center;
        margin-bottom: 20px;
    }

    /* Alert optimizations */
    .contacts-page .alert {
        font-size: 0.9rem;
        padding: 12px;
    }
}

/* ==========================================
   TABLET: 768px - 1023px
   ========================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    /* On tablet, still use cards but with slightly different layout */
    .contacts-page .table-responsive {
        display: none !important;
    }

    .contacts-page .mobile-contacts-list {
        display: block;
    }

    .contacts-page .mobile-contact-card {
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 20px;
        margin-bottom: 16px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        cursor: pointer;
    }

    .contacts-page .mobile-contact-quick-actions .btn,
    .contacts-page .mobile-contact-actions .btn {
        flex-direction: row;
        gap: 6px;
    }

    .contacts-page .mobile-contact-quick-actions .btn i,
    .contacts-page .mobile-contact-actions .btn i {
        font-size: 1rem;
    }
}

/* ==========================================
   DESKTOP: >= 1024px - Table Layout
   ========================================== */
@media (min-width: 1024px) {
    /* Show table on desktop */
    .contacts-page .table-responsive {
        display: block !important;
    }

    /* Hide mobile card layout on desktop */
    .contacts-page .mobile-contacts-list {
        display: none !important;
    }
}

/* ==========================================
   EXTRA SMALL MOBILE: < 480px
   ========================================== */
@media (max-width: 479px) {
    .contacts-page .mobile-contact-card {
        padding: 12px;
        margin-bottom: 10px;
    }

    .contacts-page .mobile-contact-name {
        font-size: 1rem;
    }

    .contacts-page .mobile-contact-quick-actions .btn,
    .contacts-page .mobile-contact-actions .btn {
        font-size: 0.8rem;
        padding: 6px 8px;
    }

    .contacts-page .mobile-contact-quick-actions .btn i,
    .contacts-page .mobile-contact-actions .btn i {
        font-size: 1rem;
    }
}

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */
html.dark-mode .contacts-page .mobile-contact-card {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

html.dark-mode .contacts-page .mobile-contact-name {
    color: #f7fafc;
}

html.dark-mode .contacts-page .mobile-contact-title,
html.dark-mode .contacts-page .mobile-contact-info-label,
html.dark-mode .contacts-page .mobile-contact-department {
    color: #a0aec0;
}

html.dark-mode .contacts-page .mobile-contact-info-value {
    color: #cbd5e0;
}

html.dark-mode .contacts-page .mobile-contact-job {
    background: #1a202c;
}

html.dark-mode .contacts-page .mobile-contact-job-title {
    color: #cbd5e0;
}

