/* Enhanced Features CSS for NCERT Solutions Question Page */

/* Common Styles */
.voting-section {
    margin: 20px 10px;
    padding-top: 15px;
    padding-bottom: 1px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #111;
}

.vote-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 15px;
    margin: 0 5px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    color: #495057;
    transition: all 0.3s ease;
}

.vote-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    text-decoration: none;
    color: #495057;
}

.vote-btn.voted-up {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.vote-btn.voted-down {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.vote-count-up,
.vote-count-down {
    font-weight: bold;
    margin-right: 5px;
}

/* User Answer Form */
.user-answer-form {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.user-answer-form h4 {
    color: #495057;
    margin-bottom: 20px;
}

.single-form {
    margin-bottom: 15px;
}

.single-form input,
.single-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.single-form input:focus,
.single-form textarea:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.single-form button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    margin-right: 10px;
    transition: background-color 0.3s ease;
}

.single-form button[type="button"]:first-of-type {
    background: #007bff;
    color: white;
}

.single-form button[type="button"]:first-of-type:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d !important;
    color: white !important;
}

.btn-secondary:hover {
    background: #545b62 !important;
}

/* User Answers Section */
.user-answers-section {
    margin: 30px 0;
}

.user-answer-item {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.answer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.answer-date {
    color: #6c757d;
    font-size: 12px;
}

.answer-content {
    line-height: 1.6;
    color: #495057;
}

.answer-voting {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
}

/* Issue Report Modal */
.modal-content {
    border-radius: 8px;
}

.modal-body h4 {
    color: #495057;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 5px;
    display: block;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Enhanced Comment Section */
.comment-item {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.comment-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 10px;
}

.reply-form {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 20px;
}

.replies-section {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 20px;
}

.reply-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    margin-left: 20px;
}

/* Alert Messages */
.alert-q {
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .voting-section .meta {
        display: table-row-group;
        flex-direction: column;
        gap: 10px;
    }
    
    .voting-section .meta li {
        flex: 1;
    }
    
    .vote-btn {
        display: block;
        text-align: center;
        width: 100%;
        margin: 5px 0;
    }
    
    .user-answer-form {
        padding: 15px;
    }
    
    .user-answer-item {
        padding: 15px;
    }
    
    .answer-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .comment-actions {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .reply-form {
        padding: 15px;
    }
    
    .replies-section {
        padding: 15px;
    }
    
    .reply-item {
        margin-left: 10px;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .voting-section {
        padding: 10px;
    }
    
    .vote-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .user-answer-form,
    .user-answer-item {
        padding: 10px;
    }
    
    .single-form input,
    .single-form textarea {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .single-form button {
        width: 100%;
        margin-bottom: 10px;
        padding: 12px;
    }
    
    .comment-actions {
        justify-content: space-between;
    }
    
    .vote-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error States */
.vote-success {
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}


/* Print Styles */
@media print {
    .voting-section,
    .user-answer-form,
    .comment-actions,
    .reply-form {
        display: none;
    }
    
    .user-answer-item,
    .comment-item {
        border: 1px solid #000;
        margin-bottom: 20px;
        page-break-inside: avoid;
    }
}

.ncert-pdf-fallback-section {
    margin: 28px 0;
    padding: 20px;
    border: 1px solid #d9e6f2;
    border-radius: 8px;
    background: #f8fbff;
}

.ncert-pdf-fallback-head h2 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.25;
    color: #17365d;
}

.ncert-pdf-fallback-head p {
    margin: 0 0 18px;
    color: #4c5f73;
}

.ncert-pdf-viewer {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
}

.ncert-pdf-frame-wrap {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-height: 520px;
    height: calc(100vh - 120px);
    height: calc(100dvh - 120px);
    margin: 0;
    overflow: hidden;
    border: 1px solid #ccd9e6;
    border-radius: 8px;
    background: #fff;
}

.ncert-pdf-frame {
    width: 100%;
    height: 100%;
    min-height: 520px;
    border: 0;
}

.ncert-pdf-fallback,
.ncert-pdf-actions {
    margin: 12px 0;
}

.ncert-pdf-actions,
.ncert-pdf-fallback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ncert-pdf-toolbar {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin: 0 0 8px;
}

.ncert-pdf-control {
    min-height: 38px;
    padding: 8px 12px;
    border: 0;
    border-radius: 7px;
    background: #17365d;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.ncert-pdf-control.secondary {
    background: #e8eef6;
    color: #17365d;
}

.ncert-pdf-viewer.is-fullscreen {
    position: fixed;
    z-index: 99999;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 8px;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
}

.ncert-pdf-viewer.is-fullscreen .ncert-pdf-frame-wrap,
.ncert-pdf-viewer:fullscreen .ncert-pdf-frame-wrap {
    flex: 1 1 auto;
    height: calc(100vh - 54px);
    height: calc(100dvh - 54px);
    min-height: 0;
    margin: 0;
}

.ncert-pdf-viewer.is-fullscreen .ncert-pdf-frame,
.ncert-pdf-viewer:fullscreen .ncert-pdf-frame {
    min-height: 0;
}

.ncert-pdf-viewer.is-minimized .ncert-pdf-frame-wrap,
.ncert-pdf-viewer.is-minimized .ncert-pdf-fallback {
    display: none;
}

.ncert-pdf-viewer.is-fullscreen .ncert-pdf-fallback,
.ncert-pdf-viewer.is-fullscreen .ncert-pdf-actions,
.ncert-pdf-viewer:fullscreen .ncert-pdf-fallback,
.ncert-pdf-viewer:fullscreen .ncert-pdf-actions {
    display: none;
}

.ncert-pdf-actions a,
.ncert-pdf-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 13px;
    border-radius: 7px;
    background: #0d5ea8;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.ncert-pdf-actions a:hover,
.ncert-pdf-link:hover {
    color: #fff;
    text-decoration: none;
    background: #084b87;
}

.ncert-pdf-fallback-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.ncert-pdf-fallback-card {
    padding: 14px;
    border: 1px solid #dde8f2;
    border-radius: 8px;
    background: #fff;
}

.ncert-pdf-fallback-card h3 {
    margin: 0 0 12px;
    font-size: 17px;
    line-height: 1.35;
    color: #1b2f49;
}

@media (max-width: 767px) {
    .ncert-pdf-fallback-section {
        padding: 14px;
        margin: 22px 0;
    }
    .ncert-pdf-fallback-head h2 {
        font-size: 20px;
    }
    .ncert-pdf-frame-wrap,
    .ncert-pdf-frame {
        min-height: 520px;
    }
    .ncert-pdf-frame-wrap {
        height: calc(100vh - 96px);
        height: calc(100dvh - 96px);
    }
    .ncert-pdf-actions a,
    .ncert-pdf-link {
        width: 100%;
        justify-content: center;
    }
}

/* Contextual actions on NCERT Q&A pages */
.qna-floating-actions{position:fixed;right:22px;bottom:88px;z-index:1040;display:flex;flex-direction:column;align-items:stretch;gap:10px}
.qna-floating-action{display:inline-flex;min-height:46px;padding:11px 17px;align-items:center;justify-content:flex-start;gap:9px;border:0;border-radius:24px;box-shadow:0 5px 18px rgba(25,35,55,.22);color:#fff;cursor:pointer;font:600 14px/1.2 inherit;text-decoration:none;transition:transform .2s ease,box-shadow .2s ease}
.qna-floating-action:hover,.qna-floating-action:focus{color:#fff;text-decoration:none;transform:translateY(-2px);box-shadow:0 8px 22px rgba(25,35,55,.28);outline:3px solid rgba(30,115,190,.22);outline-offset:2px}
.qna-floating-action--ask{background:#1769aa}.qna-floating-action--feedback{background:#d86618}
.qna-floating-action i{width:18px;text-align:center;font-size:17px}
@media(max-width:767px){.qna-floating-actions{right:12px;bottom:72px;gap:8px}.qna-floating-action{min-height:42px;padding:9px 13px;border-radius:22px;font-size:13px}}
@media(prefers-reduced-motion:reduce){.qna-floating-action{transition:none}}
