/**
 * Mobile Card View Styles
 * 
 * Responsive card layout for DataTables on mobile devices.
 * Transforms complex tables into accessible, touch-friendly cards.
 * 
 * @package TeamPortal
 * @subpackage Assets/CSS
 * @since Phase 5.2.1
 * @version 1.0.0
 * 
 * FEATURES:
 * - Responsive card design (<768px)
 * - Touch-optimized interactions
 * - Accessible focus states
 * - Smooth animations
 * - High contrast support
 * - Reduced motion support
 */

/* ============================================
   MOBILE CARD VIEW - CORE STYLES
   ============================================ */

/**
 * Mobile View Wrapper
 * Applied to .dataTables_wrapper when in mobile mode
 */
.tp-mobile-view {
    /* Override DataTables default styles */
}

.tp-mobile-view table.dataTable {
    border-collapse: separate;
    border-spacing: 0;
}

.tp-mobile-view table.dataTable thead {
    /* Hide table headers on mobile - data shown as card labels */
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.tp-mobile-view table.dataTable tbody {
    display: block;
    width: 100%;
}

/**
 * Mobile Card Rows
 * Each <tr> becomes a card container
 */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card {
    display: block;
    width: 100%;
    margin-bottom: 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    overflow: hidden;
}

/* Dark mode support */
body.dark-mode .tp-mobile-view table.dataTable tbody tr.tp-mobile-card {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
}

/**
 * Card Hover/Focus States
 */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.tp-mobile-view table.dataTable tbody tr.tp-mobile-card:focus-within {
    outline: 2px solid var(--focus-ring-color, #3b82f6);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/**
 * Touch Feedback
 * Active state when card is tapped
 */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card.tp-card-active {
    background: #f9fafb;
    transform: scale(0.98);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

body.dark-mode .tp-mobile-view table.dataTable tbody tr.tp-mobile-card.tp-card-active {
    background: #111827;
}

/**
 * Mobile Card Cells
 * Each <td> becomes a card row
 */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card td {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
}

/**
 * Card Item Container
 * Wraps label + value
 */
.tp-card-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    min-height: 44px; /* WCAG 2.5.5 - Touch target size */
}

body.dark-mode .tp-card-item {
    border-bottom-color: #374151;
}

/* Remove border from last item */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card td:last-child .tp-card-item {
    border-bottom: none;
}

/**
 * Card Label (Column Name)
 */
.tp-card-label {
    flex: 0 0 120px;
    font-weight: 600;
    font-size: 13px;
    color: #6b7280;
    padding-right: 12px;
    line-height: 1.5;
    margin-top: 2px;
}

body.dark-mode .tp-card-label {
    color: #9ca3af;
}

/**
 * Card Value (Cell Data)
 */
.tp-card-value {
    flex: 1;
    font-size: 14px;
    color: #111827;
    line-height: 1.5;
    word-break: break-word;
}

body.dark-mode .tp-card-value {
    color: #f3f4f6;
}

/* ============================================
   PRIORITY COLUMNS
   ============================================ */

/**
 * First Row (Usually Name/Title)
 * Highlighted with larger text
 */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card td:first-child .tp-card-item {
    background: #f9fafb;
    padding: 16px;
    border-bottom: 2px solid #e5e7eb;
}

body.dark-mode .tp-mobile-view table.dataTable tbody tr.tp-mobile-card td:first-child .tp-card-item {
    background: #111827;
    border-bottom-color: #4b5563;
}

.tp-mobile-view table.dataTable tbody tr.tp-mobile-card td:first-child .tp-card-value {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

body.dark-mode .tp-mobile-view table.dataTable tbody tr.tp-mobile-card td:first-child .tp-card-value {
    color: #f9fafb;
}

/* ============================================
   STATUS BADGES & SPECIAL ELEMENTS
   ============================================ */

/**
 * Status Badges in Cards
 */
.tp-card-value .status-badge,
.tp-card-value .badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/**
 * Buttons in Cards
 */
.tp-card-value button,
.tp-card-value .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 16px;
    margin: 4px 0;
}

/**
 * Links in Cards
 */
.tp-card-value a {
    color: #3b82f6;
    text-decoration: underline;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.tp-card-value a:hover {
    color: #2563eb;
}

.tp-card-value a:focus {
    outline: 2px solid var(--focus-ring-color, #3b82f6);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */

/**
 * Loading State
 */
.tp-mobile-view table.dataTable.processing tbody tr.tp-mobile-card {
    opacity: 0.5;
    pointer-events: none;
}

/**
 * Empty State
 */
.tp-mobile-view .dataTables_empty {
    display: block;
    padding: 48px 24px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/**
 * Card Enter Animation
 */
@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tp-mobile-view table.dataTable tbody tr.tp-mobile-card {
    animation: cardFadeIn 0.3s ease;
}

/**
 * Reduced Motion Support
 */
@media (prefers-reduced-motion: reduce) {
    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card,
    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card:hover,
    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card.tp-card-active {
        animation: none;
        transition: none;
        transform: none;
    }
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/**
 * Mobile Only (<768px)
 * Card view enabled
 */
@media (max-width: 767px) {
    /* Ensure cards take full width */
    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    /* Adjust padding for smaller screens */
    .tp-card-item {
        padding: 10px 12px;
    }

    /* Stack label/value on very small screens */
    @media (max-width: 480px) {
        .tp-card-item {
            flex-direction: column;
            align-items: flex-start;
        }

        .tp-card-label {
            flex: 1;
            padding-right: 0;
            padding-bottom: 4px;
            margin-top: 0;
        }

        .tp-card-value {
            padding-left: 0;
        }
    }
}

/**
 * Tablet & Desktop (>=768px)
 * Normal table view
 */
@media (min-width: 768px) {
    /* Hide mobile card elements on desktop */
    .tp-card-item {
        display: contents;
    }

    .tp-card-label {
        display: none;
    }
}

/* ============================================
   DATATABLE PAGINATION & INFO
   ============================================ */

/**
 * Pagination in Mobile View
 */
.tp-mobile-view .dataTables_paginate {
    margin-top: 16px;
    text-align: center;
}

.tp-mobile-view .dataTables_paginate .paginate_button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    margin: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/**
 * Info Text in Mobile View
 */
.tp-mobile-view .dataTables_info {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: #6b7280;
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card {
        border-width: 2px;
        border-color: #000000;
    }

    .tp-card-item {
        border-bottom-width: 2px;
    }

    .tp-card-label {
        font-weight: 700;
    }

    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card:focus-within {
        outline-width: 3px;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/**
 * Screen Reader Only Content
 */
.tp-card-sr-only {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/**
 * Focus Visible for Keyboard Navigation
 */
.tp-mobile-view table.dataTable tbody tr.tp-mobile-card:focus-visible {
    outline: 3px solid var(--focus-ring-color, #3b82f6);
    outline-offset: 3px;
}

/**
 * Touch Target Minimum Size (WCAG 2.5.5)
 * Ensure all interactive elements are at least 44x44px
 */
.tp-card-value button,
.tp-card-value .btn,
.tp-card-value a,
.tp-card-value input,
.tp-card-value select {
    min-width: 44px;
    min-height: 44px;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    /* Revert to table format for printing */
    .tp-mobile-view table.dataTable thead {
        position: static;
        width: auto;
        height: auto;
    }

    .tp-mobile-view table.dataTable tbody {
        display: table-row-group;
    }

    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card {
        display: table-row;
        margin: 0;
        border: 1px solid #000;
        box-shadow: none;
    }

    .tp-mobile-view table.dataTable tbody tr.tp-mobile-card td {
        display: table-cell;
        padding: 8px;
        border: 1px solid #000;
    }

    .tp-card-label {
        display: none;
    }

    .tp-card-item {
        display: contents;
    }
}
