/**
 * Church Dashboard Styles
 * 
 * Styles for the church attendance dashboard table and controls
 * 
 * @package ChurchAttendanceReports
 * @since 1.1.5
 */

/* ========================================
   Dashboard Container
   ======================================== */

.church-dashboard {
    margin: 20px 0;
    max-width: 100%;
    overflow: hidden;
}

/* ========================================
   Table Wrapper for Overflow Control
   ======================================== */

.dashboard-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* Hide any overflow */
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-sizing: border-box; /* Include padding/border in width */
}

/* ========================================
   Dashboard Table
   ======================================== */

#dashboard-reports-table {
    width: 100%;
    min-width: 0; /* Let it fit the container */
    max-width: 100%; /* Don't exceed container */
    border-collapse: collapse;
    font-size: 14px;
    margin: 0;
    table-layout: fixed; /* Force columns to respect width percentages */
    box-sizing: border-box;
}

#dashboard-reports-table th,
#dashboard-reports-table td {
    padding: 10px 8px; /* Reduced from 10px 12px */
    text-align: left;
    border-bottom: 1px solid #ddd;
    box-sizing: border-box;
    overflow: hidden; /* Hide overflow text */
    text-overflow: ellipsis; /* Add ... for long text */
    white-space: nowrap; /* Don't wrap */
}

/* Table Header */
#dashboard-reports-table thead th {
    background-color: #f5f5f5;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    color: #555;
    position: relative;
}

#dashboard-reports-table thead th:hover {
    background-color: #ececec;
}

/* Sorting arrows - consistent size */
#dashboard-reports-table thead th[data-sort]::after {
    content: ' ▴▾';
    font-size: 10px;
    color: #ccc;
    margin-left: 3px;
    letter-spacing: -2px;
}

/* Table Body Rows */
#dashboard-reports-table tbody tr {
    transition: background-color 0.2s ease;
}

#dashboard-reports-table tbody tr:hover {
    background-color: #f9f9f9;
}

/* Editable rows get pointer cursor */
#dashboard-reports-table tbody tr[style*="cursor: pointer"] {
    cursor: pointer !important;
}

/* Row being edited */
#dashboard-reports-table tbody tr.editing {
    background-color: #fff9e6 !important;
    border-left: 3px solid #46b6ac;
}

/* ========================================
   Column Widths
   ======================================== */

/* Report ID column */
#dashboard-reports-table th:nth-child(1),
#dashboard-reports-table td:nth-child(1) {
    width: 4%;
    text-align: center;
    font-weight: 600;
}

/* Date column */
#dashboard-reports-table th:nth-child(2),
#dashboard-reports-table td:nth-child(2) {
    width: 8%;
}

/* Attendance number columns (In-Person, Online, ACL, Total) */
#dashboard-reports-table th:nth-child(3),
#dashboard-reports-table th:nth-child(4),
#dashboard-reports-table th:nth-child(6),
#dashboard-reports-table th:nth-child(7),
#dashboard-reports-table td:nth-child(3),
#dashboard-reports-table td:nth-child(4),
#dashboard-reports-table td:nth-child(6),
#dashboard-reports-table td:nth-child(7) {
    width: 7%; /* Wider for "In-Person" header */
    text-align: center;
    padding: 8px 4px; /* Slightly more padding */
}

/* Discipleship - slightly wider for the longer header */
#dashboard-reports-table th:nth-child(5),
#dashboard-reports-table td:nth-child(5) {
    width: 9%; /* Wider for full text */
    text-align: center;
    padding: 8px 4px;
}

/* Submitted By column */
#dashboard-reports-table th:nth-child(8),
#dashboard-reports-table td:nth-child(8) {
    width: 9%;
}

/* Submitted At column */
#dashboard-reports-table th:nth-child(9),
#dashboard-reports-table td:nth-child(9) {
    width: 13%; /* Narrower - was too wide */
}

/* Edited column */
#dashboard-reports-table th:nth-child(10),
#dashboard-reports-table td:nth-child(10) {
    width: 13%; /* Wider for buttons with text */
    text-align: center;
    padding: 8px 6px; /* More padding */
}

/* ========================================
   Input Fields (Inline Editing)
   ======================================== */

/* Inputs only appear when row is being edited */
#dashboard-reports-table input.inline-edit {
    width: 100%;
    max-width: 60px;
    padding: 4px 6px;
    font-size: 14px; /* Match table font size */
    border: 1px solid #46b6ac;
    border-radius: 3px;
    text-align: center;
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(70, 182, 172, 0.1);
    font-family: inherit; /* Use same font as table */
    line-height: 1.4; /* Match table line height */
}

#dashboard-reports-table input.inline-edit:focus {
    outline: none;
    border-color: #3a9d94;
    box-shadow: 0 0 0 3px rgba(70, 182, 172, 0.2);
}

/* Editable cells */
.editable-cell {
    cursor: pointer;
}

/* Edit action buttons */
.edit-actions {
    display: inline-flex;
    gap: 4px;
    margin-top: 2px;
    flex-wrap: nowrap;
    justify-content: center;
}

.edit-actions button {
    padding: 5px 10px;
    font-size: 11px;
    border: 1px solid;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 50px;
    line-height: 1.3;
    box-sizing: border-box;
}

.edit-actions .save-btn {
    background-color: #46b6ac;
    border-color: #3a9d94;
    color: white;
}

.edit-actions .save-btn:hover {
    background-color: #3a9d94;
    border-color: #2e847c;
}

.edit-actions .cancel-btn {
    background-color: white;
    border-color: #ccc;
    color: #666;
}

.edit-actions .cancel-btn:hover {
    background-color: #f5f5f5;
    border-color: #999;
}

/* ========================================
   Tooltip for Edited Indicator
   ======================================== */

.tooltip-icon {
    cursor: pointer;
    position: relative;
    display: inline-block;
    font-size: 16px;
}

.tooltip-content {
    visibility: hidden;
    opacity: 0;
    background-color: #333;
    color: #fff;
    text-align: left;
    padding: 8px 12px;
    border-radius: 5px;
    position: absolute;
    z-index: 1000;
    width: max-content;
    max-width: 300px;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s ease;
}

.tooltip-icon:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Arrow for tooltip */
.tooltip-content::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #333;
}

/* ========================================
   Filter Controls
   ======================================== */

.church-dashboard label {
    margin-right: 10px;
    font-weight: 500;
}

.church-dashboard input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    margin-right: 10px;
}

.church-dashboard button {
    padding: 8px 16px;
    background-color: #46b6ac;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.church-dashboard button:hover {
    background-color: #3a9d94;
}

.church-dashboard button:active {
    background-color: #2e847c;
}

/* ========================================
   Pagination Controls
   ======================================== */

.pagination-controls {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-controls select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    margin-left: 10px;
}

.pagination-controls button {
    padding: 6px 12px;
    margin: 0 5px;
}

.pagination-controls #dashboard-page-info {
    margin: 0 10px;
    font-size: 14px;
    color: #666;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablet landscape and smaller desktops */
@media screen and (max-width: 1200px) {
    #dashboard-reports-table {
        font-size: 13px;
        min-width: 700px;
    }
    
    #dashboard-reports-table th,
    #dashboard-reports-table td {
        padding: 8px 6px;
    }
    
    #dashboard-reports-table input.inline-edit {
        max-width: 50px;
        font-size: 12px;
        padding: 3px 4px;
    }
}

/* Tablet portrait */
@media screen and (max-width: 900px) {
    .dashboard-table-wrapper {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    #dashboard-reports-table {
        font-size: 12px;
        min-width: 650px;
    }
    
    #dashboard-reports-table th,
    #dashboard-reports-table td {
        padding: 6px 4px;
    }
    
    /* Stack buttons vertically on narrower screens */
    .edit-actions {
        flex-direction: column;
        gap: 3px;
        align-items: stretch;
    }
    
    .edit-actions button {
        width: 100%;
        font-size: 10px;
        padding: 4px 6px;
        min-width: unset;
        max-width: unset;
    }
}

/* Mobile landscape */
@media screen and (max-width: 768px) {
    .church-dashboard h2 {
        font-size: 1.5em;
    }
    
    .church-dashboard p {
        font-size: 0.95em;
    }
    
    /* Date inputs and buttons */
    .church-dashboard label {
        display: block;
        margin-bottom: 8px;
    }
    
    .church-dashboard input[type="date"] {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .church-dashboard button {
        width: 100%;
        margin-bottom: 8px;
    }
    
    #dashboard-reports-table {
        min-width: 600px;
    }
}

/* Mobile portrait */
@media screen and (max-width: 480px) {
    #dashboard-reports-table {
        min-width: 550px;
    }
    
    #dashboard-reports-table th,
    #dashboard-reports-table td {
        padding: 4px 2px;
        font-size: 11px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .church-dashboard button,
    .pagination-controls {
        display: none;
    }
    
    #dashboard-reports-table input[type="text"],
    #dashboard-reports-table input[type="number"] {
        border: none;
        background: transparent;
    }
}