// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Styles for the dictation question type.
 *
 * @package    qtype_dictation
 * @copyright  2025 Deepak Sharma <deepak@palinfocom.net>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/* Dictation Question Type Styles */

/* Basic gap input styling */
.dictation-gap {
    text-align: center;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin: 0 2px;
    font-size: inherit;
    font-family: inherit;
}

.que input[size], .que textarea[cols] {
  width: auto;
  max-width: 100%;
  min-width: 43px;
}

/* Left-aligned text for input boxes when option is enabled */
.dictation-gap-left-aligned {
    text-align: left !important;
}

/* Focused gap styling */
.dictation-gap:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 4px rgba(0, 124, 186, 0.3);
}

/* Color feedback for partial matches - Change #2: Mark partial matches as red */
.dictation-feedback .gap-feedback.incorrect .student-answer {
    color: #d32f2f;
    font-weight: bold;
}

.dictation-feedback .gap-feedback.correct .student-answer {
    color: #388e3c;
    font-weight: bold;
}

/* Different display modes */
.dictation-gap-standard {
    min-width: 80px;
}

.dictation-gap-length {
    /* Dynamic width will be set inline based on word length */
}

.dictation-gap-letters {
    min-width: 5px;
}

.dictation-gap-partial {
    min-width: 40px;
}

/* Audio controls styling */
.dictation-audio-controls {
    margin: 10px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.dictation-play-btn {
    margin-right: 10px;
}

.dictation-play-counter {
    font-size: 0.9em;
    color: #666;
    margin-left: 10px;
}

/* Question text container */
.dictation-question-text {
    font-size: 1.1em;
    line-height: 1.6;
    margin: 15px 0;
    padding: 15px;
    background-color: #fafafa;
    border-left: 4px solid #007cba;
}

/* Feedback sections */
.dictation-feedback {
    margin-top: 20px;
}

.dictation-feedback-details {
    margin-top: 10px;
}

.gap-feedback {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 4px;
    border-left: 4px solid;
}

.gap-feedback.correct {
    background-color: #e8f5e8;
    border-left-color: #4caf50;
}

.gap-feedback.incorrect {
    background-color: #ffeaea;
    border-left-color: #f44336;
}

.gap-feedback .correct-answer {
    margin: 5px 0;
    font-style: italic;
}

.gap-feedback .student-answer {
    margin: 5px 0;
}

.gap-feedback .gap-score {
    margin: 5px 0;
    font-weight: bold;
}

/* Preview styling in edit form */
.dictation-preview {
    margin: 15px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Responsive design */
@media (max-width: 768px) {
    .dictation-gap {
        margin: 2px 0;
        display: inline-block;
        min-width: 8px;
    }
    .que input[size], .que textarea[cols] {
      margin: 1px;
    }
    .dictation-question-text {
        padding: 10px;
        font-size: 1em;
    }
    
    .dictation-audio-controls {
        text-align: center;
    }
}

.dictation-gap {
    border: 2px solid #007cba;
    border-radius: 3px;
    padding: 5px 2px;
    margin: 0 2px;
    font-size: 1em;
    background: #fff;
    min-width: 5px;
    text-align: center;
}

/* Gap display mode styles */
.dictation-gap-length {
   // font-family: monospace;
    letter-spacing: 0px;
}

.dictation-gap-letters {
   // font-family: monospace;
    letter-spacing: 0px;
}

.dictation-gap-partial {
    font-family: monospace;
    text-align: left;
}

.dictation-gap-standard {
    border-bottom: 2px solid #007cba;
    border-left: none;
    border-right: none;
    border-top: none;
    border-radius: 0;
    background: transparent;
}

.dictation-gap:focus {
    border-color: #0056b3;
    box-shadow: 0 0 5px rgba(0, 123, 186, 0.3);
    outline: none;
}

.dictation-audio-player {
    margin: 15px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 5px;
    border: 1px solid #ddd;
    text-align: center;
}

.dictation-audio {
    width: 100%;
    max-width: 400px;
    margin-bottom: 10px;
}

.dictation-play-btn {
    margin: 0 10px;
    padding: 8px 16px;
    font-size: 1em;
}

.dictation-play-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dictation-play-counter {
    display: inline-block;
    margin-left: 15px;
    font-size: 0.9em;
    color: #666;
}

.dictation-feedback {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.dictation-feedback h4 {
    margin-top: 0;
    color: #333;
}

.dictation-feedback-details {
    margin-top: 15px;
}

.gap-feedback {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #ccc;
}

.gap-feedback.correct {
    background: #d4edda;
    border-left-color: #28a745;
}

.gap-feedback.incorrect {
    background: #f8d7da;
    border-left-color: #dc3545;
}

.gap-feedback strong {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.correct-answer {
    color: #28a745;
    font-weight: bold;
}

.student-answer {
    color: #6c757d;
}

.gap-score {
    font-size: 0.9em;
    color: #495057;
    margin-top: 5px;
}

/* Form editing styles */
.dictation-transcript {
    font-family: monospace;
    font-size: 1em;
    line-height: 1.4;
}

.dictation-preview {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.dictation-preview h5 {
    margin-top: 0;
    color: #333;
}

.dictation-preview-text {
    font-size: 1.1em;
    line-height: 1.6;
}

.dictation-preview-gap {
    display: inline-block;
    min-width: 60px;
    height: 20px;
    border-bottom: 2px solid #007cba;
    margin: 0 2px;
    vertical-align: bottom;
}

/* Export button */
.dictation-export-btn {
    margin: 10px 0;
}

/* Responsive design */
@media (max-width: 768px) {


    .dictation-audio-player {
        text-align: center;
    }
    
    .dictation-play-counter {
        display: block;
        margin: 10px 0 0 0;
    }
    
    .dictation-gap {
        min-width: 27px;
        font-size: 0.9em;
    }
    
    .gap-feedback {
        padding: 8px;
    }
}

/* Accessibility improvements */
.dictation-gap:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.dictation-play-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}
.ctype-question {
    /*text-align: left !important;*/
    /*padding-left: 0;
    margin-left: 0;*/
}
/* High contrast mode support */
@media (prefers-contrast: high) {
    .dictation-gap {
        border-width: 3px;
    }
    
    .gap-feedback.correct {
        border-left-width: 6px;
    }
    
    .gap-feedback.incorrect {
        border-left-width: 6px;
    }
}

.dictation-gap-standard {

  margin-left: -1px !important;
  font-size: 1em;
}
