/**
 * Frontend styles for Attendance PDF Manager.
 *
 * Implements a modern, responsive layout with premium typography, harmonized color palettes,
 * smooth hover animations, and card conversion on mobile screens.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.apm-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 30px 0;
    color: #1e293b;
}

/* 1. Filter Form Styling */
.apm-frontend-filter-form {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.apm-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
}

.apm-filter-field {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 160px;
}

.apm-filter-field label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.apm-filter-field select {
    appearance: none;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

.apm-filter-field select:focus {
    border-color: #6366f1;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.apm-filter-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    height: 42px; /* aligns button with inputs */
}

.apm-btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    padding: 10px 24px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.apm-btn-filter {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.apm-btn-filter:hover {
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3);
}

.apm-btn-filter:active {
    transform: translateY(0);
}

.apm-reset-link {
    font-size: 14px;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.apm-reset-link:hover {
    color: #ef4444;
}

/* 2. Responsive Table Styling */
.apm-table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    background: #ffffff;
}

.apm-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 15px;
}

.apm-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
}

.apm-table td {
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.apm-table tr:last-child td {
    border-bottom: none;
}

.apm-table tbody tr {
    transition: background-color 0.2s ease;
}

.apm-table tbody tr:hover {
    background-color: #f8fafc;
}

.apm-no-records {
    text-align: center;
    color: #64748b;
    padding: 40px 24px !important;
    font-style: italic;
}

/* Title cell and PDF preview icon */
.apm-title-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.apm-title-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.apm-title-text {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.apm-downloads-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background-color: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 9999px;
    gap: 3.5px;
    border: 1px solid #e2e8f0;
}

.apm-downloads-badge svg {
    width: 12px;
    height: 12px;
    color: #64748b;
}

.apm-dept-header {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 12px;
    letter-spacing: -0.02em;
}

.apm-pdf-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: #fee2e2;
    color: #ef4444;
    border-radius: 8px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.apm-table tr:hover .apm-pdf-icon-wrapper {
    background-color: #fecaca;
    transform: scale(1.05);
}

.apm-pdf-svg {
    width: 20px;
    height: 20px;
}

/* View Button Styling */
.apm-btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    color: #4f46e5;
    border: 1px solid #cbd5e1;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.apm-btn-view:hover {
    background-color: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.15);
    transform: translateY(-1px);
}

.apm-btn-view:active {
    transform: translateY(0);
}

/* Error messages */
.apm-error {
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 16px;
    border-radius: 8px;
    font-weight: 500;
    margin: 20px 0;
}

/* ==========================================
 * 3. Mobile Responsiveness (Max-Width: 768px)
 * ========================================== */
@media (max-width: 768px) {
    .apm-filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .apm-filter-field {
        width: 100%;
    }
    
    .apm-filter-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 5px;
        height: auto;
    }

    .apm-btn-filter {
        width: 100%;
    }

    /* Convert Table into Cards */
    .apm-table, .apm-table thead, .apm-table tbody, .apm-table th, .apm-table td, .apm-table tr {
        display: block;
    }

    .apm-table thead {
        display: none; /* Hide header columns */
    }

    .apm-table tr {
        border-bottom: 2px solid #e2e8f0;
        padding: 15px 10px;
    }

    .apm-table tr:last-child {
        border-bottom: none;
    }

    .apm-table td {
        border-bottom: none;
        padding: 10px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: right;
    }

    .apm-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.05em;
        color: #64748b;
        float: left;
        text-align: left;
        margin-right: 15px;
    }

    .apm-title-cell {
        display: flex !important;
        justify-content: space-between !important;
    }

    .apm-title-cell::before {
        align-self: center;
    }

    .apm-btn-view {
        width: 100%;
        box-sizing: border-box;
    }
}
