/* 
 * Styles for manage_chestionare.php
 * This file contains CSS for the questionnaire management interface
 */

/* ===== Custom Modal Styles ===== */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Darker overlay, similar to pdf-viewer */
    display: flex; /* Use flex to center content */
    align-items: center;
    justify-content: center;
    z-index: 1050; /* Ensure it's above other content */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.custom-modal-content {
    background-color: #fff;
    border-radius: 8px; /* Rounded corners */
    box-shadow: 0 5px 15px rgba(0,0,0,.5); /* Shadow like pdf-viewer */
    width: 800px; /* Default width, can be adjusted */
    max-width: 95%;
    max-height: 90vh; /* Max height */
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.custom-modal-overlay.active .custom-modal-content {
    transform: scale(1);
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem; /* Padding like pdf-viewer */
    border-bottom: 1px solid #dee2e6; /* Separator line */
    background-color: #f8f9fa; /* Light header background */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.custom-modal-title {
    margin-bottom: 0;
    font-size: 1.25rem; /* Slightly larger title */
    font-weight: 500;
}

.custom-modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
    color: #000;
    text-shadow: 0 1px 0 #fff;
    opacity: .5;
    cursor: pointer;
}

.custom-modal-close-btn:hover {
    opacity: .75;
}

.custom-modal-body {
    padding: 1.5rem; /* Padding like pdf-viewer */
    overflow-y: auto; /* Scroll for long content */
    flex-grow: 1;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 1rem 1.5rem; /* Padding like pdf-viewer */
    border-top: 1px solid #dee2e6; /* Separator line */
    background-color: #f8f9fa; /* Light footer background */
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.custom-modal-footer .btn {
    margin-left: 0.5rem;
}

/* Form styling within the modal, inspired by main.css and chestionar.php */
.custom-modal-body .form-group {
    margin-bottom: var(--spacing-md, 1rem); /* Use CSS var from main.css or fallback */
}

.custom-modal-body .form-label {
    display: block;
    margin-bottom: var(--spacing-xs, 0.25rem);
    font-weight: 500;
}

.custom-modal-body .form-input,
.custom-modal-body .form-input[type="text"],
.custom-modal-body .form-input[type="number"],
.custom-modal-body .form-input[type="email"],
.custom-modal-body textarea.form-input,
.custom-modal-body select.form-input {
    width: 100%;
    padding: var(--spacing-sm, 0.5rem);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-sm, 4px);
    font-size: 1rem;
    line-height: 1.5;
    background-color: #fff;
    color: var(--text-dark, #1e293b);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-modal-body .form-input:focus {
    outline: none;
    border-color: var(--primary-dark, #76ad5a);
    box-shadow: 0 0 0 2px rgba(139, 205, 106, 0.3); /* Adjust color if needed */
}

/* Two-column layout for form groups */
.custom-modal-body .form-grid-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md, 1rem);
}

/* Checkbox specific styling */
.custom-modal-body .form-group-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 0.5rem);
}

.custom-modal-body .form-input-checkbox {
    width: auto; /* Override width: 100% from .form-input if it was applied */
    margin-top: 0; /* Adjust vertical alignment if needed */
}

.custom-modal-body .form-label-checkbox {
    margin-bottom: 0; /* Override default form-label margin */
    font-weight: normal; /* Checkboxes usually have normal weight labels */
}

/* ===== Questionnaire Controls ===== */
.controls-questionnaires {
    margin-bottom: 1rem;
}

/* ===== Drag and Drop Styles ===== */
.drag-drop-info {
    color: #6c757d;
    padding: 8px;
    border-radius: 4px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    margin-top: 10px;
}

.table tbody tr {
    cursor: move;
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.ui-sortable-helper {
    display: table;
    background: white !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
}

.ui-sortable-placeholder {
    visibility: visible !important;
    background-color: #f8f9fa !important;
    border: 2px dashed #dee2e6 !important;
    height: 53px !important;
}

/* Button spacing in specific contexts */
.custom-modal-footer .btn + .btn {
    margin-left: 0.5rem;
}

/* ===== Toast Styles ===== */
.toast-container {
    z-index: 1500;
    position: fixed;
    top: 20px;
    right: 20px;
}
.toast {
    min-width: 280px;
    padding: 0.5rem;
    font-size: 0.95rem;
    background: rgba(0, 0, 0, 0.85);
    border: none;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}
.toast.show {
    opacity: 1;
}
.toast.bg-success {
    background: rgba(40, 167, 69, 0.95) !important;
}
.toast.bg-danger {
    background: rgba(220, 53, 69, 0.95) !important;
}
.toast .toast-body {
    padding: 0.5rem 0.75rem;
    color: white;
    font-weight: 500;
}
.toast .btn-close {
    padding: 0.75rem 0.5rem;
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.8;
    filter: brightness(2);
}
.toast .btn-close:hover {
    opacity: 1;
}

/* Table Button Group Styles */
.btn-group {
    display: flex;
    gap: var(--spacing-sm);
}

/* ===== Form textarea styles ===== */
.form-input[rows] {
    resize: vertical;
    min-height: 60px;
}

/* Make sure the form grid rows display properly for textareas */
.form-grid-row .form-group textarea.form-input {
    width: 100%;
    display: block;
}

.tablechestionare {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
    border-radius: 8px;
    overflow: hidden;
}

.tablechestionare th,
.tablechestionare td {
    padding: 0.75rem 1rem;
    border: 1px solid #dee2e6;
    text-align: left;
    vertical-align: middle;
}

.tablechestionare thead {
    background-color: #f8f9fa;
    color: #495057;
    font-weight: bold;
}

.tablechestionare tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

.tablechestionare tbody tr:hover {
    background-color: #e9ecef;
    transition: background-color 0.2s ease-in-out;
}


/* Responsive adjustments */
/* Add these styles to your existing manage_chestionare.css file */

/* Card view for mobile devices */
/* Action buttons styling */
.btn-group {
    display: flex !important;
    gap: var(--spacing-sm);
}


@media (max-width: 767.98px) {
    .mobile-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
        width: 100%;
    }

    .btn-group {
        display: none;
    }
    /* Mobile card styles */
    .table-questionnaires {
        border: none;
        background-color: transparent;
    }
    
    .table-questionnaires thead {
        display: none;
    }
    
    .table-questionnaires tbody tr {
        display: block;
        margin-bottom: 1.5rem;
        border-radius: 12px;
        box-shadow: 0 3px 8px rgba(0,0,0,0.12);
        background-color: #fff;
        border: 1px solid #e9ecef;
    }
    
    .table-questionnaires tbody td {
        display: flex;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f1f1f1;
        text-align: left;
        align-items: center;
    }
    
    .table-questionnaires tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        min-width: 40%;
        margin-right: 1rem;
        color: #495057;
    }
    
    /* Actions cell styling */
    .table-questionnaires td:last-child {
        border-bottom: none;
        background-color: #f8f9fa;
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
        padding: 1rem;
    }

    .table-questionnaires td:last-child .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .table-questionnaires td:last-child .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        justify-content: center;
    }

    .table-questionnaires td:last-child .btn:last-child {
        margin-bottom: 0;
    }
    
    .table-questionnaires td:last-child::before {
        display: none;
    }
    
    .table-questionnaires .btn {
        width: 100%;
        margin: 0;
        padding: var(--btn-padding-sm);
        font-size: var(--btn-font-size-sm);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--spacing-sm);
    }
    
    .table-questionnaires .btn i {
        margin-right: var(--btn-icon-spacing);
    }
    
    .drag-drop-info {
        display: none;
    }
    
    .sort-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #f8f9fa;
        padding: 0.5rem;
        margin: -0.75rem -1rem;
        margin-bottom: 0.5rem;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
        border-bottom: 1px solid #e9ecef;
        color: #6c757d;
        display: none;
    }
    
    .sort-handle i {
        font-size: 1.25rem;
    }
    
    /* Enhance badges display */
    .badge {
        flex-shrink: 0;
        font-size: 0.875rem;
        padding: 0.4em 0.8em;
    }
    
    /* Improve spacing for questions link */
    .table-questionnaires td a.btn-info {
        text-align: center;
        width: 100%;
    }
}