/* UDS Questionnaire Styles */

body {
    background-color: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar-brand {
    font-size: 1.1rem;
}

.navbar-brand:hover {
    opacity: 0.9;
}

/* Card styling */
.card {
    border: none;
    border-radius: 12px;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    border-bottom: 1px solid #e9ecef;
}

/* Progress bar */
.progress {
    border-radius: 4px;
    background-color: #e9ecef;
}

.progress-bar {
    transition: width 0.4s ease;
}

/* Question styling */
.question-wrapper {
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

/* Question number styling */
.question-num {
    color: #6f42c1;
    font-weight: 600;
}

.question-wrapper:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.form-label {
    color: #333;
    margin-bottom: 0.5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #6f42c1;
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.15);
}

.form-check-input:checked {
    background-color: #6f42c1;
    border-color: #6f42c1;
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.15);
}

/* Button styling */
.btn-primary {
    background-color: #6f42c1;
    border-color: #6f42c1;
}

.btn-primary:hover {
    background-color: #5a32a3;
    border-color: #5a32a3;
}

.btn-primary:focus {
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.5);
}

.btn-outline-primary {
    color: #6f42c1;
    border-color: #6f42c1;
}

.btn-outline-primary:hover {
    background-color: #6f42c1;
    border-color: #6f42c1;
    color: white;
}

.btn-success {
    background-color: #198754;
    border-color: #198754;
}

.btn-success:hover {
    background-color: #157347;
    border-color: #157347;
}

/* Alert styling */
.alert {
    border-radius: 8px;
}

.alert-info {
    background-color: #e8f4fd;
    border-color: #b8daff;
    color: #004085;
}

/* Group input styling */
.question-wrapper .bg-light {
    background-color: #f8f9fa !important;
}

/* Badge styling */
.badge.bg-primary {
    background-color: #6f42c1 !important;
}

/* Footer */
footer {
    margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #btn-previous,
    #btn-next,
    #btn-submit {
        flex: 1;
        min-width: 100px;
    }

    #btn-save {
        order: -1;
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Animation for alerts */
.alert.fade {
    transition: opacity 0.15s linear;
}

.alert.fade.show {
    opacity: 1;
}

/* Loading spinner */
#loading {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Placeholder styling */
::placeholder {
    color: #b8c0c8 !important;
    opacity: 1 !important;
}

.form-control::placeholder,
.form-select::placeholder {
    color: #b8c0c8 !important;
    opacity: 1 !important;
}

/* Filled/selected input styling - green indicator */
.form-control.filled,
.form-select.filled,
textarea.form-control.filled {
    border-color: #198754 !important;
    background-color: #f0fdf4 !important;
}

.form-control.filled:focus,
.form-select.filled:focus {
    border-color: #198754 !important;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.15) !important;
}

/* Checkbox styling when checked */
.form-check-input:checked {
    background-color: #198754 !important;
    border-color: #198754 !important;
}

/* Required field indicator */
.text-danger {
    font-weight: normal;
}

/* Help text styling */
.form-text {
    font-size: 0.85rem;
}

/* Disabled button styling */
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* SOR List View Styles */
#list-view h4 {
    color: #333;
}

.sor-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.sor-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.sor-card .sor-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.sor-card .sor-meta {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

.sor-card .sor-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sor-card .sor-actions .btn {
    font-size: 0.85rem;
    padding: 0.375rem 0.75rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.empty-state h5 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* Responsive SOR list */
@media (max-width: 576px) {
    .sor-card .sor-actions {
        flex-direction: column;
    }

    .sor-card .sor-actions .btn {
        width: 100%;
    }
}

/* ==================== Section Sidebar Styles ==================== */

/* Wider container for questionnaire */
#questionnaire-container {
    max-width: 1600px;
    margin: 0 auto;
}

#list-view {
    max-width: 900px;
    margin: 0 auto;
}

.section-sidebar {
    position: sticky;
    top: 1rem;
    border-radius: 12px;
    overflow: hidden;
}

.section-sidebar .card-header {
    border-radius: 0;
}

.section-sidebar .card-footer {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

/* Section Tree Navigation */
.section-tree {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.section-tree::-webkit-scrollbar {
    width: 4px;
}

.section-tree::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.section-tree::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.section-tree::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Section Item */
.section-item {
    display: flex;
    align-items: flex-start;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #495057;
}

.section-item:last-child {
    border-bottom: none;
}

.section-item:hover {
    background-color: #f8f4ff;
    color: #6f42c1;
}

.section-item.active {
    background-color: #6f42c1;
    color: white;
}

.section-item.active .section-number {
    background-color: white;
    color: #6f42c1;
}

.section-item.active .section-title {
    color: white;
}

.section-item.active .section-status {
    color: rgba(255, 255, 255, 0.8);
}

/* Section Number Badge */
.section-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background-color: #e9ecef;
    color: #666;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.section-item.completed .section-number {
    background-color: #198754;
    color: white;
}

/* Section Info */
.section-info {
    flex: 1;
    min-width: 0;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
    line-height: 1.3;
    color: inherit;
    word-wrap: break-word;
}

.section-status {
    font-size: 0.7rem;
    color: #6c757d;
}

/* Section Completion Percentage */
.section-pct {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
}

.section-pct.pct-low {
    background-color: #ffeeba;
    color: #856404;
}

.section-pct.pct-medium {
    background-color: #d4edda;
    color: #155724;
}

.section-pct.pct-complete {
    background-color: #198754;
    color: white;
}

/* Active section percentage styling */
.section-item.active .section-pct {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.section-item.active .section-pct.pct-complete {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Sidebar Toggle Button */
#btn-toggle-sidebar {
    display: none;
}

/* Responsive Sidebar */
@media (max-width: 991px) {
    #sidebar-col {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        padding: 1rem;
        background: white;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
    }

    #sidebar-col.show {
        display: block;
    }

    #sidebar-col .section-sidebar {
        position: static;
    }

    #btn-toggle-sidebar {
        display: inline-flex;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    #main-content-col {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
}

@media (max-width: 767px) {
    .section-tree {
        max-height: calc(100vh - 200px);
    }

    .section-item {
        padding: 0.5rem 0.75rem;
    }

    .section-title {
        font-size: 0.8rem;
    }
}

/* ==================== PDF Preview Modal Styles ==================== */

#previewModal .modal-header {
    z-index: 10;
}

#previewModal .modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-loading,
#preview-error {
    flex-direction: column;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

#preview-iframe {
    background: #525659;
}

/* Preview button styling */
.btn-outline-info {
    color: #0dcaf0;
    border-color: #0dcaf0;
}

.btn-outline-info:hover {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: #000;
}

/* Responsive preview modal */
@media (max-width: 576px) {
    #previewModal .modal-header h5 {
        font-size: 0.95rem;
    }

    #previewModal .modal-header .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    #btn-preview {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
        margin-right: 0 !important;
    }
}
