/* Educational Materials Manager - Modal Styles */

/* Modal Overlay */
.emm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
}

/* Modal Container - Full Width */
.emm-modal-container {
    position: relative;
    background: #ffffff;
    border-radius: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    overflow: hidden;
    animation: emmModalSlideIn 0.3s ease-out;
    margin: 0;
    display: flex;
    flex-direction: column;
}

@keyframes emmModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Header - Professional Design */
.emm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #6b9f6e 0%, #5a8a5e 100%);
    color: white;
    flex-shrink: 0;
    min-height: 90px;
    position: relative;
}

.emm-modal-header::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #6b9f6e 0%, #4a7c4f 50%, #6b9f6e 100%);
}

.emm-modal-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: white;
    line-height: 1.3;
    max-width: 80%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.02em;
}

.emm-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-size: 24px;
    line-height: 1;
    color: white;
    cursor: pointer;
    padding: 12px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 300;
}

.emm-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Modal Content - Professional Layout */
.emm-modal-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #6b9f6e transparent;
    display: flex;
    flex-direction: column;
    background: #fafbfc;
}

.emm-modal-content::-webkit-scrollbar {
    width: 8px;
}

.emm-modal-content::-webkit-scrollbar-track {
    background: #f1f3f4;
}

.emm-modal-content::-webkit-scrollbar-thumb {
    background: #6b9f6e;
    border-radius: 4px;
}

.emm-modal-content::-webkit-scrollbar-thumb:hover {
    background: #5a8a5e;
}

/* Loading State */
.emm-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 60px 40px;
    text-align: center;
}

.emm-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-left-color: #6b9f6e;
    border-radius: 50%;
    animation: emmSpin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes emmSpin {
    to {
        transform: rotate(360deg);
    }
}

.emm-modal-loading p {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
}

/* Modal Body - Professional Layout */
.emm-modal-body {
    /* padding: 20px 30px; */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.7;
    color: #374151;
    max-width:100%;
    margin: 0 auto;
    flex: 1;
    background: white;
}

.emm-modal-body h1,
.emm-modal-body h2,
.emm-modal-body h3,
.emm-modal-body h4,
.emm-modal-body h5,
.emm-modal-body h6 {
    color: #1f2937;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.emm-modal-body h1 { font-size: 2.25rem; }
.emm-modal-body h2 { font-size: 1.875rem; }
.emm-modal-body h3 { font-size: 1.5rem; }
.emm-modal-body h4 { font-size: 1.25rem; margin-top: 1.5rem; /* Reduced margin-top */ }

.emm-modal-body p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: #4b5563;
    max-width: 75ch;
}

.emm-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.emm-modal-body ul,
.emm-modal-body ol {
    margin-bottom: 2rem;
    padding-left: 2rem;
    max-width: 80ch;
}

.emm-modal-body li {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    color: #4b5563;
}

.emm-modal-body blockquote {
    border-left: 4px solid #6b9f6e;
    padding-left: 2rem;
    margin: 2rem 0;
    font-style: italic;
    color: #6b7280;
    font-size: 1.2rem;
    background: #f9fafb;
    padding: 1.5rem 2rem;
    border-radius: 8px;
}

/* Featured Image - Professional Display */
.emm-modal-featured-image {
    margin: -50px -60px 50px -60px;
    position: relative;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    overflow: hidden;
}

.emm-modal-featured-image img {
    width: 100%;
    height: 350px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.emm-modal-featured-image:hover img {
    transform: scale(1.02);
}

/* Main Content Area */
.emm-modal-main-content {
    margin-bottom: 3rem;
}

.emm-modal-body code {
    background: #f0f9f0;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #4a7c4f;
    border: 1px solid #e8f5e8;
}

.emm-modal-body pre {
    background: #f8fcf8;
    padding: 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    border: 1px solid #e8f5e8;
    margin: 2rem 0;
}

.emm-modal-body pre code {
    background: none;
    padding: 0;
    color: #374151;
}

/* Material Files in Modal - Full Width Layout */
.emm-modal-body .emm-material-files {
    margin-top: 1.5rem; /* Reduced margin-top */
    padding-top: 1.5rem; /* Reduced padding-top */
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    margin-left: -30px; /* Adjusted margin */
    margin-right: -30px; /* Adjusted margin */
    padding-left: 30px; /* Adjusted padding */
    padding-right: 30px; /* Adjusted padding */
}

/* New List Design for Files */
.emm-files-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.emm-file-list-item {
    display: flex;
    flex-direction: column; /* Changed to column */
    align-items: stretch; /* Changed to stretch */
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px; /* Reduced padding */
    transition: all 0.2s ease;
}

.emm-file-list-item:hover {
    border-color: #6b9f6e;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.emm-file-list-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px; /* Reduced margin-bottom */
}

.emm-file-list-icon {
    font-size: 1.8rem;
    margin-right: 15px;
    color: #6b9f6e;
    flex-shrink: 0;
}

.emm-file-list-details {
    flex-grow: 1;
}

.emm-file-list-title {
    font-size: 1.05em;
    font-weight: 600;
    color: #1a202c;
    margin: 0 0 2px 0;
}

.emm-file-list-description {
    font-size: 0.9em;
    color: #718096;
    margin: 0;
}

.emm-file-list-actions {
    display: flex;
    gap: 10px;
    margin-left: 0; /* Removed margin-left */
    border-top: 1px solid #f1f5f9; /* Added border-top */
    padding-top: 10px; /* Reduced padding-top */
    margin-top: auto; /* Pushes to the bottom */
}

.emm-file-list-actions .emm-btn {
    padding: 8px 16px;
    font-size: 0.9em;
    flex-grow: 1; /* Make buttons take equal space */
    text-align: center; /* Center text in button */
}

.emm-btn-view {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.emm-btn-view:hover {
    background: #dcfce7;
    color: #15803d;
}

.emm-btn-download {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.emm-btn-download:hover {
    background: #dbeafe;
    color: #1e3a8a;
}

/* End of New List Design */

.emm-modal-body .emm-material-files h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem; /* Reduced margin */
    color: #1f2937;
}

.emm-modal-body .emm-file-item {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.emm-modal-body .emm-file-item:hover {
    border-color: #6b9f6e;
    background: #f0f9f0;
}

.emm-modal-body .emm-file-icon {
    margin-right: 1rem;
    font-size: 1.5rem;
    color: #6b9f6e;
}

.emm-modal-body .emm-file-details {
    flex: 1;
}

.emm-modal-body .emm-file-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

.emm-modal-body .emm-file-description {
    margin: 0 0 0.5rem 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.emm-modal-body .emm-file-info {
    font-size: 0.8rem;
    color: #9ca3af;
}

.emm-modal-body .emm-file-actions {
    margin-left: 1rem;
}

/* Button Styles - Professional Green Theme */
.emm-modal-body .emm-btn {
    display: inline-block;
    padding: 12px 24px;
    margin: 0 8px 8px 0;
    background: linear-gradient(135deg, #6b9f6e 0%, #5a8a5e 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.025em;
    box-shadow: 0 2px 4px rgba(107, 159, 110, 0.2);
}

.emm-modal-body .emm-btn:hover {
    background: linear-gradient(135deg, #5a8a5e 0%, #4a7c4f 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(107, 159, 110, 0.3);
    color: white;
    text-decoration: none;
}

.emm-modal-body .emm-btn-view {
    background: linear-gradient(135deg, #6b9f6e 0%, #5a8a5e 100%);
    box-shadow: 0 2px 4px rgba(107, 159, 110, 0.2);
}

.emm-modal-body .emm-btn-view:hover {
    background: linear-gradient(135deg, #5a8a5e 0%, #4a7c4f 100%);
    box-shadow: 0 8px 25px rgba(107, 159, 110, 0.3);
}

.emm-modal-body .emm-btn-download {
    background: linear-gradient(135deg, #6b9f6e 0%, #5a8a5e 100%);
    box-shadow: 0 2px 4px rgba(107, 159, 110, 0.2);
}

.emm-modal-body .emm-btn-download:hover {
    background: linear-gradient(135deg, #5a8a5e 0%, #4a7c4f 100%);
    box-shadow: 0 8px 25px rgba(107, 159, 110, 0.3);
}

.emm-modal-body .emm-btn-disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.emm-modal-body .emm-btn-disabled:hover {
    background: #e5e7eb;
    color: #9ca3af;
    transform: none;
    box-shadow: none;
}

/* Metadata Section - Professional Design */
.emm-modal-metadata {
    background: linear-gradient(135deg, #f8fcf8 0%, #f0f9f0 100%);
    margin: 2rem -30px 0 -30px; /* Adjusted margin */
    padding: 1.5rem 30px; /* Adjusted padding */
    border-top: 3px solid #6b9f6e;
    position: relative;
}

.emm-modal-metadata::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #6b9f6e 50%, transparent 100%);
}

.emm-meta-item {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: #374151;
    padding: 12px 0;
    border-bottom: 1px solid rgba(107, 159, 110, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.emm-meta-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.emm-meta-item strong {
    color: #1f2937;
    font-weight: 600;
    min-width: 120px;
    display: inline-block;
}

.emm-meta-item::before {
    content: "•";
    color: #6b9f6e;
    font-weight: bold;
    font-size: 1.2em;
}

/* Error State */
.emm-error {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-weight: 500;
}

/* Body Lock */
body.emm-modal-open {
    overflow: hidden;
}

/* Mobile Responsiveness - Full Width */
@media (max-width: 768px) {
    .emm-modal-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    
    .emm-modal-header {
        padding: 15px 20px; /* Reduced padding */
        min-height: 70px;
    }
    
    .emm-modal-title {
        font-size: 1.5rem;
        max-width: 75%;
    }
    
    .emm-modal-close {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
    
    .emm-modal-body {
        padding:5px; /* Reduced padding */
    }
    
    .emm-modal-body p {
        font-size: 1rem;
    }
    
    .emm-modal-body h1 { font-size: 2rem; }
    .emm-modal-body h2 { font-size: 1.75rem; }
    .emm-modal-body h3 { font-size: 1.5rem; }
    .emm-modal-body h4 { font-size: 1.25rem; }
    
    .emm-modal-featured-image {
        margin: -25px -25px 25px -25px;
    }
    
    .emm-modal-featured-image img {
        height: 250px;
    }
    
    .emm-modal-body .emm-material-files {
        margin-left: -20px; /* Adjusted margin */
        margin-right: -20px; /* Adjusted margin */
        padding-left: 20px; /* Adjusted padding */
        padding-right: 20px; /* Adjusted padding */
    }
    
    .emm-modal-metadata {
        margin-left: -20px; /* Adjusted margin */
        margin-right: -20px; /* Adjusted margin */
        padding-left: 20px; /* Adjusted padding */
        padding-right: 20px; /* Adjusted padding */
    }
    
    .emm-modal-body .emm-file-item {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        padding: 1.25rem;
    }
    
    .emm-modal-body .emm-file-icon {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .emm-modal-body .emm-file-actions {
        margin-left: 0;
        margin-top: 1rem;
        width: 100%;
    }
    
    .emm-modal-body .emm-btn {
        display: block;
        width: 100%;
        margin: 0.25rem 0;
        text-align: center;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .emm-modal-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .emm-modal-container {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .emm-modal-container {
        animation: none;
    }
    
    .emm-loading-spinner {
        animation: none;
    }
    
    .emm-modal-body .emm-btn:hover {
        transform: none;
    }
}

/* Full Width Modal Enhancements */

/* Improved Loading State for Full Width */
.emm-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 60px 40px;
    text-align: center;
}

/* Content Typography for Better Reading */
.emm-modal-body {
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
}

.emm-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.emm-modal-body ul,
.emm-modal-body ol {
    margin-bottom: 2rem;
    padding-left: 2rem;
    max-width: 80ch;
}

.emm-modal-body li {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.emm-modal-body blockquote {
    border-left: 4px solid #6b9f6e;
    padding-left: 2rem;
    margin: 2rem 0;
    font-style: italic;
    color: #6b7280;
    font-size: 1.2rem;
    background: #f9fafb;
    padding: 1.5rem 2rem;
    border-radius: 8px;
}

/* Scroll to Top Button for Long Content */
.emm-scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #6b9f6e;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(107, 159, 110, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000000;
}

.emm-scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.emm-scroll-top:hover {
    background: #5a8a5e;
    transform: translateY(-2px);
}

/* Large Screen Optimizations */
@media (min-width: 1200px) {
    .emm-modal-body {
        padding: 40px 60px; /* Reduced padding */
    }
    
    .emm-modal-featured-image {
        margin: -40px -60px 40px -60px; /* Adjusted margin */
    }
    
    .emm-modal-featured-image img {
        height: 500px;
    }
    
    .emm-modal-body .emm-material-files {
        margin-left: -60px; /* Adjusted margin */
        margin-right: -60px; /* Adjusted margin */
        padding-left: 60px; /* Adjusted padding */
        padding-right: 60px; /* Adjusted padding */
    }
    
    .emm-modal-metadata {
        margin-left: -60px; /* Adjusted margin */
        margin-right: -60px; /* Adjusted margin */
        padding-left: 60px; /* Adjusted padding */
        padding-right: 60px; /* Adjusted padding */
    }
}

/* Extra Large Screen Optimizations */
@media (min-width: 1600px) {
    .emm-modal-body {
        max-width: 1400px;
        padding: 50px 80px; /* Reduced padding */
    }
    
    .emm-modal-featured-image {
        margin: -50px -80px 50px -80px; /* Adjusted margin */
    }
    
    .emm-modal-body .emm-material-files {
        margin-left: -80px; /* Adjusted margin */
        margin-right: -80px; /* Adjusted margin */
        padding-left: 80px; /* Adjusted padding */
        padding-right: 80px; /* Adjusted padding */
    }
    
    .emm-modal-metadata {
        margin-left: -80px; /* Adjusted margin */
        margin-right: -80px; /* Adjusted margin */
        padding-left: 80px; /* Adjusted padding */
        padding-right: 80px; /* Adjusted padding */
    }
}

/* File Preview Styles */
.emm-file-preview {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.emm-file-preview audio,
.emm-file-preview video {
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.emm-file-preview audio {
    background: #ffffff;
    padding: 10px;
    border: 1px solid #ddd;
}

.emm-file-preview img {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.emm-file-preview iframe {
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.emm-file-action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* File Item Styling for Modal */
.emm-modal-files .emm-file-item {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.emm-modal-files .emm-file-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.emm-modal-files .emm-file-title {
    color: #1f2937;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.emm-modal-files .emm-file-description {
    color: #6b7280;
    margin: 0 0 15px 0;
    line-height: 1.5;
}

.emm-modal-files .emm-file-info {
    margin-bottom: 15px;
}

.emm-modal-files .emm-file-type {
    background: linear-gradient(135deg, #6b9f6e 0%, #5a8a5e 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Audio/Video Controls Enhancement */
.emm-modal-files audio::-webkit-media-controls-panel {
    background-color: #6b9f6e;
}

.emm-modal-files video::-webkit-media-controls-panel {
    background-color: rgba(107, 159, 110, 0.9);
}

/* Responsive */
@media (max-width: 768px) {
    .emm-file-action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .emm-file-action-buttons .emm-btn {
        margin: 5px 0;
        text-align: center;
    }
    
    .emm-file-preview audio,
    .emm-file-preview video {
        width: 100% !important;
        max-width: 100% !important;
    }
}
