/**
 * Grid View Styles for IPEM CPD Plugin
 *
 * @package    local_ipemcpd
 * @copyright  2025
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

:root {
    --card-bg: #1a1a1a;
    --card-hover: #252525;
    --accent: #1db954;
    --accent-hover: #1ed760;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --modal-bg: #121212;
    --overlay: rgba(0, 0, 0, 0.85);
}

.cpd-grid-container {
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.cpd-header {
    margin-bottom: 2rem;
}

.cpd-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.cpd-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.cpd-stat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 1rem;
    color: white;
    min-width: 150px;
}

.cpd-stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.cpd-stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.cpd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.cpd-card {
    background: var(--card-bg);
    border-radius: 1rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.cpd-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.cpd-card:hover .cpd-card-content {
    background: var(--card-hover);
}

/* Keyboard focus state for accessibility */
.cpd-card:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 102, 204, 0.5);
}

.cpd-card:focus .cpd-card-content {
    background: var(--card-hover);
}

.cpd-card-checkbox {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 24px;
    height: 24px;
    z-index: 10;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    accent-color: var(--accent);
}

.cpd-card:hover .cpd-card-checkbox,
.cpd-card:focus .cpd-card-checkbox,
.cpd-card:focus-within .cpd-card-checkbox,
.cpd-card-checkbox:checked,
.cpd-card-checkbox:focus {
    opacity: 1;
}

/* Focus state for checkbox */
.cpd-card-checkbox:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.cpd-card.selected {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
}

.cpd-card-add {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.cpd-card-add:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(29, 185, 84, 0.4);
}

.cpd-card-add-icon {
    font-size: 4rem;
    color: white;
    font-weight: 300;
}

.cpd-card-add-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.cpd-card-image {
    width: 100%;
    height: 160px;
    background: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.cpd-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cpd-card-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    padding: 0.375rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.cpd-card-status {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    backdrop-filter: blur(10px);
    padding: 0.375rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cpd-status-approved {
    background: rgba(40, 167, 69, 0.9);
    color: white;
}

.cpd-status-pending {
    background: rgba(108, 117, 125, 0.9);
    color: white;
}

.cpd-status-rejected {
    background: rgba(220, 53, 69, 0.9);
    color: white;
}

.cpd-status-needs_revision {
    background: rgba(255, 193, 7, 0.9);
    color: #1a1a1a; /* Improved contrast for WCAG AA */
}

.cpd-card-content {
    padding: 1.25rem;
    background: var(--card-bg);
    transition: background 0.3s;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cpd-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property for compatibility */
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.cpd-card-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.cpd-card-type {
    color: var(--accent);
    font-weight: 600;
}

.cpd-card-hours {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Modal Styles */
.cpd-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    z-index: 10000;
    overflow-y: auto;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s;
}

.cpd-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cpd-modal-content {
    background: var(--modal-bg);
    border-radius: 1.5rem;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cpd-modal-header {
    height: 200px;
    background: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 1.5rem 1.5rem 0 0;
}

.cpd-modal-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cpd-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s;
}

.cpd-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.cpd-modal-body {
    padding: 2rem;
}

.cpd-modal-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.cpd-modal-meta {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.cpd-modal-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cpd-modal-meta-item .cpd-card-status {
    position: static;
    display: inline-block;
    margin-top: 0.25rem;
}

.cpd-modal-meta-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cpd-modal-meta-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.cpd-modal-section {
    margin-bottom: 2rem;
}

.cpd-modal-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.cpd-modal-section-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

.cpd-modal-section-hidden {
    display: none;
}

.attached-file-item {
    margin-bottom: 0.5rem;
}

.attached-file-item a {
    color: var(--accent);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

.attached-file-item a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.cpd-modal-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cpd-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.cpd-btn-primary {
    background: var(--accent);
    color: white;
}

.cpd-btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.cpd-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.cpd-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cpd-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.cpd-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* Floating Action Bar */
.cpd-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(29, 185, 84, 0.95) 0%, rgba(29, 185, 84, 0.98) 100%);
    backdrop-filter: blur(10px);
    padding: 1.25rem 2rem;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cpd-action-bar.active {
    transform: translateY(0);
}

.cpd-action-bar-info {
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.cpd-action-bar-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cpd-action-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.cpd-action-btn-primary {
    background: white;
    color: var(--accent);
}

.cpd-action-btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cpd-action-btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.cpd-action-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cpd-action-btn-danger {
    background: #dc3545;
    color: white;
}

.cpd-action-btn-danger:hover {
    background: #c82333;
}

/* Filter and Controls Section */
.cpd-filter-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1rem 0 1rem;
}

.cpd-filter-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.cpd-date-filter {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.cpd-date-filter label {
    font-weight: 600;
    color: #333;
}

.cpd-date-filter input[type="date"] {
    width: auto;
}

.cpd-date-filter-separator {
    color: #666;
}

.cpd-filter-result-count {
    color: #666;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* Load More Section */
.cpd-load-more-container {
    text-align: center;
    margin: 2rem 0;
    display: none;
}

.cpd-load-more-btn {
    padding: 1rem 3rem;
    font-size: 1rem;
}

/* Hidden Helpers */
.cpd-evidence-data {
    display: none;
}

.cpd-empty-state-btn {
    margin-top: 1rem;
}

/* Table View Toggle */
.cpd-view-toggle {
    text-align: right;
    margin-bottom: 1rem;
}

/* Upload Evidence Helpers */
.cpd-upload-info {
    text-align: center;
}

.cpd-upload-alert {
    display: block;
    padding: 10px;
    background-color: #d9edf7;
    margin-bottom: 10px;
}

.cpd-upload-error-alert {
    display: block;
    padding: 10px;
    background-color: #f2dede;
    margin-bottom: 10px;
}

/* Keyboard Help Styling */
kbd {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    font-family: monospace;
    color: #212529;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 0 0 2px #fff;
    white-space: nowrap;
}

#keyboardHelpModal .cpd-modal-body {
    color: #ffffff;
}

#keyboardHelpModal h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #ffffff;
}

#keyboardHelpModal p,
#keyboardHelpModal ol, 
#keyboardHelpModal ul,
#keyboardHelpModal li {
    color: #e0e0e0;
    line-height: 1.8;
}

#keyboardHelpModal strong {
    color: var(--accent-hover);
    font-weight: 700;
}

#keyboardHelpModal .table {
    margin-top: 1rem;
    color: #ffffff;
}

#keyboardHelpModal .table th {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-weight: 600;
}

#keyboardHelpModal .table td {
    color: #e0e0e0;
    background-color: rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .cpd-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }

    .cpd-modal-content {
        margin: 1rem;
    }

    .cpd-action-bar {
        flex-direction: column;
        padding: 1rem;
        align-items: stretch;
    }

    .cpd-action-bar-actions {
        justify-content: center;
    }

    .cpd-action-btn {
        flex: 1;
        justify-content: center;
    }
}
