/**
 * AI Text Frontend Styles
 * Responsive styling for the Q&A interface
 */

.aitext-container {
    max-width: 1000px;
    margin: 20px auto;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.aitext-container h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.5em;
    text-align: center;
}

.aitext-question-area,
.aitext-answer-area,
.aitext-result-area {
    margin-bottom: 20px;
}
/* answer grow fix */
#aitext-result {
    display: block !important;
    height: auto !important;
    min-height: 400 !important;
    max-height: none !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    resize: none !important;
    box-sizing: border-box !important;
}
#aitext-result-container,
#aitext-result-wrapper,
#aitext-result-parent {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}
/* end of answer grow fix */
/* #aitext-result {
    height: auto !important;
    overflow: hidden !important;
    resize: none !important;
    box-sizing: border-box !important;
} */
.aitext-question-area label,
.aitext-answer-area label,
.aitext-result-area label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

/* Answer label container with word count */
.aitext-answer-label-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.aitext-word-count {
    font-size: 14px;
    color: #000;
    font-weight: bold;
}

/* Controls layout - speech toggle and timer controls */
.aitext-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
}

.aitext-speech-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aitext-control-label {
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

.aitext-timer-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.aitext-timer-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: #333;
}

.aitext-timer-icon {
    font-size: 18px;
}

.aitext-timer-countdown {
    font-size: 16px;
    min-width: 60px;
    text-align: center;
}

/* Blinking animation for timer */
@keyframes aitext-timer-blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.aitext-timer-blinking {
    animation: aitext-timer-blink 1s infinite;
}

/* Timer toggle switch */
.aitext-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.aitext-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.aitext-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.aitext-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .aitext-slider {
    background-color: #2196F3;
}

input:checked + .aitext-slider:before {
    transform: translateX(26px);
}

.aitext-textarea {
    height:auto;
    width: 100%;
    /* min-height: 400px; */
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box; 
    transition: border-color 0.3s ease;
    font-family: Arial, sans-serif;
    color: #000;
    background: #fff;
}

/* Text-to-speech highlighting */
.aitext-story .highlighted {
    background-color: rgba(255, 107, 53, 0.3);
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-weight: inherit;
    transition: background-color 0.3s ease;
    box-shadow: none;
    border-bottom: 2px solid #ff6b35;
}

.aitext-tts-controls {
    margin-bottom: 10px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.aitext-tts-controls button {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.aitext-tts-controls button:hover {
    background: #005a87;
}

.aitext-tts-controls select,
.aitext-tts-controls input[type="range"] {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
}

.aitext-tts-controls #aitext-tts-rate-value {
    font-size: 12px;
    color: #666;
}

/* Story area specific styling */

#aitext-story {
    font-family: Arial, sans-serif !important;
    font-size: 16px !important;
    line-height: 1.6 !important;
    color: #000 !important;
    background: #fff !important;
    padding: 12px !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    white-space: pre-wrap !important;
    min-height: 50px !important;
    cursor: default !important; /* Normal arrow cursor instead of no-entry */
}

/* Ensure highlighting works on story text */
#aitext-story .highlighted {
    background-color: rgba(255, 107, 53, 0.3) !important;
    color: inherit !important;
    padding: 0 !important;
    border-radius: 0 !important;
    font-weight: inherit !important;
    transition: background-color 0.3s ease !important;
    box-shadow: none !important;
    border-bottom: 2px solid #ff6b35 !important;
}

/* Answer label container with word count */
.aitext-answer-label-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

/* Header layout with title and controls */
.aitext-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.aitext-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
    text-align: left;
    flex: 1;
}

/* Controls layout - speech toggle and timer controls */
.aitext-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.aitext-speech-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aitext-control-label {
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

.aitext-timer-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.aitext-timer-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: #333;
}

.aitext-timer-icon {
    font-size: 18px;
}

.aitext-timer-countdown {
    font-size: 16px;
    min-width: 60px;
    text-align: center;
}

/* Blinking animation for timer */
@keyframes aitext-timer-blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.aitext-timer-blinking {
    animation: aitext-timer-blink 1s infinite;
}

/* Timer toggle switch */
.aitext-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.aitext-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.aitext-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.aitext-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .aitext-slider {
    background-color: #2196F3;
}

input:checked + .aitext-slider:before {
    transform: translateX(26px);
}

.aitext-textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

.aitext-textarea[readonly] {
    background-color: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

.aitext-button {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.aitext-button:hover:not(:disabled) {
    background: #005a87;
}

.aitext-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Skip button styling */
.aitext-skip-button {
    display: none;
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.aitext-skip-button[style*="display: block"] {
    display: inline-block !important;
}

.aitext-skip-button:hover {
    background: #000000 !important;
}

.aitext-skip-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Next button styling - make it green to indicate progression */
#aitext-next {
    background: #28a745;
    margin-top: 15px;
}

#aitext-next:hover:not(:disabled) {
    background: #20c937;
}

.aitext-loading {
    text-align: center;
    padding: 20px;
    color: #000;
}

.aitext-loading p {
    margin: 0;
    font-style: italic;
}

.aitext-error {
    padding: 12px;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    margin-top: 10px;
}

.aitext-result-area {
    background: #e8f5e8;
    border: 1px solid #c8e6c9;
    border-radius: 4px;
    padding: 15px;
    margin-top: 20px;
}

.aitext-result-area label {
    color: #2e7d32;
}

/* Make the story text white on a blue background for better readability */
#aitext-story {
    color: #ffffff;
    /* white text */
    background-color: #0066cc;
    /* blue background */
    padding: 0.5rem;
    /* a little inner spacing */
    border-radius: 4px;
    /* optional rounded corners */
    min-height: 50px !important;
}

/* Ensure the story container respects the new background */
.aitext-story-area {
    margin-bottom: 1rem;
}

/* Blinking animation for timer */
@keyframes aitext-timer-blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.aitext-timer-blinking {
    animation: aitext-timer-blink 1s infinite;
}

/* Timer toggle switch */
.aitext-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.aitext-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.aitext-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.aitext-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .aitext-slider {
    background-color: #2196F3;
}

input:checked + .aitext-slider:before {
    transform: translateX(26px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .aitext-container {
        margin: 10px;
        padding: 15px;
    }

    .aitext-container h3 {
        font-size: 1.3em;
    }

    .aitext-textarea {
        min-height: 10px;
        font-size: 16px;
        /* Better for mobile touch */
    }

    .aitext-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .aitext-timer-controls {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .aitext-container {
        padding: 10px;
        margin: 5px;
    }

    /* .aitext-textarea {
        min-height: 50px;
    } */

    .aitext-button {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* Animation for loading state */
@keyframes aitext-pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.1;
    }

    100% {
        opacity: 1;
    }
}

.aitext-loading p {
    animation: aitext-pulse 1.5s ease-in-out infinite;
}

/* Success state styling */
.aitext-result-area.success {
    background: #e8f5e8;
    border-color: #4caf50;
}

.aitext-result-area.warning {
    background: #fff3e0;
    border-color: #ff9800;
}

.aitext-result-area.error {
    background: #ffebee;
    border-color: #f44336;
}

/* Print styles */
@media print {
    .aitext-button {
        display: none;
    }

    .aitext-textarea[readonly] {
        border: 1px solid #000;
        background: white;
    }
}