/* CoachAI Responsive Table Styles */

/* Mobile Table Responsive Pattern 1: Horizontal Scroll */
@media screen and (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }
    
    .table-responsive table {
        min-width: 600px;
        margin-bottom: 0;
    }
    
    /* Visual indicator for scrollable tables */
    .table-responsive::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
}

/* Mobile Table Responsive Pattern 2: Stack Pattern */
@media screen and (max-width: 768px) {
    .table-stack {
        display: block;
        width: 100%;
    }
    
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody {
        display: block;
    }
    
    .table-stack tr {
        display: block;
        margin-bottom: 16px;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .table-stack td:last-child {
        border-bottom: none;
    }
    
    .table-stack td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.875rem;
        margin-right: 8px;
        flex-shrink: 0;
    }
    
    .table-stack td[data-label=""] {
        justify-content: flex-end;
    }
    
    /* Action buttons in stacked tables */
    .table-stack .action-buttons {
        display: flex;
        gap: 8px;
        justify-content: flex-end;
        width: 100%;
        margin-top: 8px;
    }
    
    .table-stack .action-buttons button,
    .table-stack .action-buttons a {
        flex: 1;
        text-align: center;
        padding: 8px 12px;
        font-size: 0.875rem;
    }
}

/* Mobile Forms */
@media screen and (max-width: 768px) {
    /* Form Layout */
    .form-row {
        display: block !important;
        margin-bottom: 16px;
    }
    
    .form-group,
    .form-col {
        width: 100% !important;
        margin-bottom: 16px !important;
    }
    
    .form-group label {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
        color: #374151;
        font-size: 0.875rem;
    }
    
    /* Form Controls */
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    input[type="time"],
    input[type="search"],
    select,
    textarea {
        width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
        border: 1px solid #d1d5db !important;
        border-radius: 8px !important;
        background-color: #ffffff !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
        transition: border-color 0.2s ease;
    }
    
    /* Focus states */
    .form-control:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    /* Select dropdown arrow */
    select {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding-right: 40px !important;
    }
    
    /* Checkbox and Radio */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        margin-right: 8px;
        vertical-align: middle;
    }
    
    .checkbox-label,
    .radio-label {
        display: flex;
        align-items: center;
        margin-bottom: 8px;
        cursor: pointer;
    }
    
    /* Form buttons */
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: 24px;
    }
    
    .form-actions button,
    .form-actions .btn {
        width: 100% !important;
        padding: 12px 24px !important;
        font-size: 16px !important;
        min-height: 48px;
    }
    
    /* Inline forms on mobile */
    .form-inline {
        display: block !important;
    }
    
    .form-inline .form-group {
        display: block !important;
        width: 100% !important;
        margin-bottom: 12px !important;
    }
    
    /* Search forms */
    .search-form {
        display: flex;
        gap: 8px;
    }
    
    .search-form input[type="search"] {
        flex: 1;
    }
    
    .search-form button {
        flex-shrink: 0;
        padding: 0 16px !important;
    }
}

/* ACF Forms Mobile Styles */
@media screen and (max-width: 768px) {
    .acf-form .acf-fields {
        margin: 0 !important;
    }
    
    .acf-form .acf-field {
        padding: 12px 0 !important;
        margin: 0 !important;
    }
    
    .acf-form .acf-label {
        margin-bottom: 6px !important;
    }
    
    .acf-form .acf-label label {
        font-size: 0.875rem !important;
        font-weight: 500 !important;
    }
    
    .acf-form .acf-input input,
    .acf-form .acf-input select,
    .acf-form .acf-input textarea {
        font-size: 16px !important;
        padding: 12px !important;
    }
    
    /* ACF Repeater Fields */
    .acf-repeater .acf-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .acf-repeater td {
        min-width: 150px;
    }
    
    /* ACF Gallery Field */
    .acf-gallery-attachments {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .acf-gallery-attachment {
        padding-bottom: 100% !important;
    }
}

/* DataTables Mobile */
@media screen and (max-width: 768px) {
    .dataTables_wrapper {
        padding: 0 !important;
    }
    
    .dataTables_length,
    .dataTables_filter {
        float: none !important;
        text-align: left !important;
        margin-bottom: 16px !important;
    }
    
    .dataTables_length select,
    .dataTables_filter input {
        width: auto !important;
        display: inline-block !important;
        margin-left: 8px !important;
    }
    
    .dataTables_info,
    .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 16px !important;
    }
    
    .dataTables_paginate .paginate_button {
        padding: 8px 12px !important;
        margin: 2px !important;
    }
    
    /* Make DataTables responsive */
    table.dataTable {
        width: 100% !important;
    }
    
    div.dataTables_wrapper div.dataTables_processing {
        top: 50% !important;
    }
}

/* Modal/Dialog Mobile Styles */
@media screen and (max-width: 768px) {
    .modal,
    .dialog,
    [role="dialog"] {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .modal-content,
    .dialog-content {
        height: 100% !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }
    
    .modal-header,
    .dialog-header {
        flex-shrink: 0;
        padding: 16px !important;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .modal-body,
    .dialog-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px !important;
    }
    
    .modal-footer,
    .dialog-footer {
        flex-shrink: 0;
        padding: 16px !important;
        border-top: 1px solid #e5e7eb;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-footer button,
    .dialog-footer button {
        width: 100% !important;
        min-height: 44px !important;
    }
}

/* Utility Classes for Mobile */
@media screen and (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .full-width-mobile {
        width: 100% !important;
    }
    
    .stack-mobile {
        display: block !important;
    }
    
    .stack-mobile > * {
        display: block !important;
        width: 100% !important;
        margin-bottom: 12px !important;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    tr {
        page-break-inside: avoid;
    }
}