/**
 * Choir Practice Materials - Frontend Styles
 * Inherits theme typography and provides clean, accessible layout
 */

/* Screen Reader Only Content */
.cpm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to content for keyboard navigation */
.cpm-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100000;
}

.cpm-skip-link:focus {
    top: 0;
}

.cpm-performances-container {
    margin: 2rem 0;
}

/* Performance Container */
.cpm-performance {
    margin-bottom: 3rem;
    padding: 0;
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
}

.cpm-performance-header {
    padding: 2rem;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}

.cpm-performance-header:hover {
    background: #f0f0f0;
}

.cpm-performance-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: bold;
    padding-right: 3rem;
}

.cpm-performance-date {
    margin-top: 0;
    margin-bottom: 0;
    font-style: italic;
    opacity: 0.8;
}

.cpm-performance-content {
    padding: 0 2rem 2rem 2rem;
}

/* Songs Container */
.cpm-songs {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 1.5rem;
}

/* Individual Song */
.cpm-song {
    background: #ffffff;
    padding: 0;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.cpm-song-header {
    padding: 1.5rem;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}

.cpm-song-header:hover {
    background: #f8f8f8;
}

.cpm-song-title {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.25em;
    padding-right: 3rem;
}

.cpm-song-content {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

/* Accordion Toggle Button */
.cpm-accordion-toggle {
    position: absolute;
    top: 50%;
    right: 1.5rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.5rem;
    line-height: 1;
    color: #000;
    transition: transform 0.3s ease;
}

.cpm-accordion-toggle:hover {
    color: #666;
}

.cpm-accordion-toggle[aria-expanded="true"] .cpm-toggle-icon {
    transform: rotate(180deg);
}

.cpm-toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* Tab System */
.cpm-tabs {
    margin-top: 1rem;
}

.cpm-tab-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0rem;
    margin-bottom: 0rem;
    padding-bottom: 1.15rem;
}

.cpm-tab-button {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    font-size: 2rem;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: inherit;
}

.cpm-tab-button:hover {
    background: #f0f0f0;
}

.cpm-tab-button.active {
    background: #000000;
    color: #ffffff;
    border-bottom-color: #000000;
    font-weight: bold;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.2);
}

.cpm-tab-content-wrapper {
    position: relative;
}

.cpm-tab-content {
    display: none;
    padding: 1rem;
    background: #ffffff;
    border-radius: 0 4px 4px 4px;
}

.cpm-tab-content.active {
    display: block;
}

/* Material Items */
.cpm-material-item {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.cpm-material-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.cpm-material-item h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.1em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Download Link */
.cpm-download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    font-size: 0.9em;
    text-decoration: none;
    color: #666;
    background: #f0f0f0;
    border-radius: 3px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cpm-download-link:hover {
    color: #000;
    background: #e0e0e0;
    transform: translateY(-1px);
}

/* PDF Link */
.cpm-pdf-link {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    color: #000000;
    text-decoration: none;
    border: 2px solid #000000;
    border-radius: 4px;
    font-size: 2 rem;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: inherit;
}

.cpm-pdf-link:hover {
    background: #000000;
    color: #ffffff;
}

/* Audio and Video Players */
audio,
video {
    width: 100%;
    max-width: 100%;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

video {
    max-height: 500px;
    background: #000;
}

/* Updated Date */
.cpm-updated {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.65em;
    font-style: italic;
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cpm-performance {
        padding: 1.5rem 1rem;
    }
    
    .cpm-song {
        padding: 1rem;
    }
    
    .cpm-tab-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .cpm-tab-button {
        width: 100%;
        border-radius: 4px;
    }
    
    .cpm-tab-button.active {
        border-bottom-color: transparent;
    }
    
    .cpm-tab-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .cpm-performance {
        padding: 1rem 0.75rem;
    }
    
    .cpm-song {
        padding: 0.75rem;
    }
    
    .cpm-tab-content {
        padding: 0.75rem;
    }
    
    .cpm-performance-title {
        font-size: 1.5em;
    }
    
    .cpm-song-title {
        font-size: 1.15em;
    }
}

/* Empty State */
.cpm-performances-container > p {
    text-align: center;
    font-style: italic;
    opacity: 0.7;
    padding: 2rem;
}

/* Report Problem Section */
.cpm-report-section {
    margin: 3rem 0 2rem 0;
    text-align: center;
}

.cpm-report-button {
    padding: 1rem 2rem;
    background: #000000;
    color: #ffffff;
    border: 2px solid #000000;
    border-radius: 4px;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.cpm-report-button:hover {
    background: #333333;
    border-color: #333333;
}

/* Cantamus Section */
.cpm-cantamus-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f5f5f5;
    border: 2px solid #000000;
    border-radius: 6px;
}

.cpm-cantamus-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #000000;
    font-weight: bold;
}

.cpm-cantamus-content {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.cpm-cantamus-button,
.cpm-cantamus-info-button {
    padding: 0.75rem 1.25rem;
    border: 2px solid #000000;
    border-radius: 4px;
    font-size: 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}

.cpm-cantamus-button {
    background: #000000;
    color: #ffffff;
}

.cpm-cantamus-button:hover {
    background: #333333;
    border-color: #333333;
}

.cpm-cantamus-info-button {
    background: #ffffff;
    color: #000000;
}

.cpm-cantamus-info-button:hover {
    background: #f0f0f0;
}

/* Modal Styles */
.cpm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2rem 1rem;
    background: rgba(0, 0, 0, 0.7);
    display: block;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cpm-modal.cpm-modal-visible {
    opacity: 1;
}

.cpm-modal-overlay {
    display: none;
}

.cpm-modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: #ffffff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
    z-index: 1000000;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.cpm-modal.cpm-modal-visible .cpm-modal-content {
    transform: scale(1);
}

.cpm-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

.cpm-modal-close:hover {
    color: #000;
}

.cpm-modal-content h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #000000;
    font-weight: bold;
}

.cpm-modal-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Form Styles */
.cpm-form-group {
    margin-bottom: 1.5rem;
}

.cpm-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.cpm-form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1.15rem;
    font-family: inherit;
    box-sizing: border-box;
}

.cpm-form-group select,
.cpm-form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1.15rem;
    font-family: inherit;
    box-sizing: border-box;
}

.cpm-form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.cpm-form-group input:focus,
.cpm-form-group select:focus,
.cpm-form-group textarea:focus {
    outline: none;
    border-color: #000000;
}

.cpm-form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.cpm-submit-button,
.cpm-cancel-button {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: 2px solid #000000;
    border-radius: 4px;
    font-size: 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.cpm-submit-button {
    background: #000000;
    color: #ffffff;
}

.cpm-submit-button:hover:not(:disabled) {
    background: #333333;
    border-color: #333333;
}

.cpm-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cpm-cancel-button {
    background: #ffffff;
    color: #666;
    border-color: #ddd;
}

.cpm-cancel-button:hover {
    background: #f5f5f5;
}

.cpm-form-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    font-weight: 600;
}

.cpm-form-message.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.cpm-form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .cpm-modal {
        padding: 1rem;
    }
    
    .cpm-modal-content {
        padding: 1.5rem;
    }
    
    .cpm-cantamus-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cpm-cantamus-button,
    .cpm-cantamus-info-button {
        width: 100%;
        text-align: center;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Target iOS Safari specifically */
    .cpm-modal {
        position: fixed !important;
        z-index: 999999 !important;
        background: rgba(0, 0, 0, 0.7) !important;
    }
    
    .cpm-modal-content {
        position: relative !important;
        z-index: 1000000 !important;
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
    }
}
