@font-face {
    font-family: 'Opus';
    src: url('../fonts/Opus.otf') format('opentype'),
         url('../fonts/Opus.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap; /* Improves loading behavior on iOS */
}

/* Set Arial as the default font for CKEditor content */
.ck-content {
    font-family: Arial, Helvetica, sans-serif;
    font-size: inherit;
}

/* Only apply Opus font when explicitly set via inline style or class */
.ck-content [style*="font-family: Opus"],
.ck-content [style*="font-family:'Opus"],
.ck-content [style*='font-family: "Opus'],
.ck-content .opus-font {
    font-family: "Opus", sans-serif !important;
}

/* static/css/custom.css */
.ck-content a {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}
.ck-content a:hover {
    color: #0056b3;
}

/* Improve font rendering on iOS Safari */
.description {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Image styling within CKEditor */
.ck-content .image {
    min-width: 0 !important;
    min-height: 0 !important;
    display: table;
    clear: both;
}

.ck-content .image img {
    min-width: 0 !important;
    min-height: 0 !important;
    display: block;
}

/* Image alignment styles */
.ck-content .image-style-align-left,
.ck-content .image-style-side {
    float: left;
    margin-right: 1.5em;
    max-width: 50%;
}

.ck-content .image-style-align-right {
    float: right;
    margin-left: 1.5em;
    max-width: 50%;
}

.ck-content .image-style-align-center {
    margin-left: auto;
    margin-right: auto;
}

.ck-content .image-style-block-align-right {
    margin-left: auto;
    margin-right: 0;
}

.ck-content .image-style-block-align-left {
    margin-right: auto;
    margin-left: 0;
}

/* Image captions */
.ck-content .image > figcaption {
    display: table-caption;
    caption-side: bottom;
    word-break: break-word;
    color: #333;
    background-color: #f7f7f7;
    padding: 0.6em;
    font-size: 0.75em;
    outline-offset: -1px;
}

/* Custom time signature styling */
.custom-time-signature {
    width: 3px !important;
    max-width: 3px !important;
}

.custom-time-signature img {
    width: 100% !important;
    height: auto !important;
}

/* Accordion styling */
.accordion-header {
    background-color: #f4f4f4;
    padding: 10px;
    cursor: pointer;
    border: none;
    text-align: left;
    outline: none;
    font-size: 16px;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background-color: #ddd;
}

.accordion-content {
    display: none;
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #ddd;
}

.accordion-content.active {
    display: block;
}

/* Table Styling for CKEditor Content */
.ck-content .ck-table {
    width: 100%;
    max-width: 600px;
    border-collapse: collapse;
}

/* Allow CKEditor to override width when resizing */
.ck-content .ck-table[style*="width"] {
    width: auto !important;
    max-width: none !important;
}

/* Ensure alignment styles are respected */
.ck-content .ck-table[style*="margin-left: auto; margin-right: auto;"] {
    margin: 0 auto;
}

.ck-content .ck-table[style*="margin-left: 0; margin-right: auto;"] {
    margin-left: 0;
    margin-right: auto;
}

.ck-content .ck-table[style*="margin-left: auto; margin-right: 0;"] {
    margin-left: auto;
    margin-right: 0;
}

/* Table cell styling */
.ck-content .ck-table td,
.ck-content .ck-table th {
    padding: 5px;
    border: 1px solid #000;
    text-align: center;
    vertical-align: middle;
}

/* Media inside table cells */
.ck-content .ck-table img {
    width: 100%;
    height: auto;
}

.ck-content .ck-table audio {
    width: 100%;
    height: 30px;
}

/* Heading Styles - Override Tailwind prose and other styles */
.ck-content h1,
.ck-content.prose h1,
.prose .ck-content h1 {
    font-size: 2em !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    margin: 0.67em 0 !important;
}

.ck-content h2,
.ck-content.prose h2,
.prose .ck-content h2 {
    font-size: 1.5em !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0.75em 0 !important;
}

.ck-content h3,
.ck-content.prose h3,
.prose .ck-content h3 {
    font-size: 1.17em !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    margin: 0.83em 0 !important;
}

.ck-content h4,
.ck-content.prose h4,
.prose .ck-content h4 {
    font-size: 1em !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    margin: 1.12em 0 !important;
}

.ck-content h5,
.ck-content.prose h5,
.prose .ck-content h5 {
    font-size: 0.83em !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    margin: 1.5em 0 !important;
}

.ck-content h6,
.ck-content.prose h6,
.prose .ck-content h6 {
    font-size: 0.67em !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    margin: 1.67em 0 !important;
}

.ck-content p {
    margin: 0 0 1em 0;
}

/* Responsive Adjustments for Tables in CKEditor */
@media (max-width: 600px) {
    .ck-content .ck-table {
        max-width: 100%;
    }
    .ck-content .ck-table td,
    .ck-content .ck-table th {
        width: 80px !important;
        height: 40px !important;
    }
    .ck-content .ck-table img {
        width: 80px;
        height: auto;
    }
}
