/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100% !important;
    height: 100% !important;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

/* Fullscreen modal styles for all devices */
.modal.modal-fullscreen-md-down {
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden;
}

.modal.modal-fullscreen-md-down .modal-dialog {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    margin: 0 !important;
}

.modal.modal-fullscreen-md-down .modal-content {
    height: 100% !important;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
}

.modal.modal-fullscreen-md-down .modal-header {
    padding: 20px;
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 1052;
    border-radius: 0 !important;
}

.modal.modal-fullscreen-md-down .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 25px;
    padding-bottom: 80px; /* Make room for footer */
}

.modal.modal-fullscreen-md-down .modal-footer {
    border-radius: 0;
    padding: 20px;
    position: sticky;
    bottom: 0;
    background-color: #f8f9fa;
    z-index: 1052;
}

.modal.modal-fullscreen-md-down .form-control {
    font-size: 1.2rem; /* Larger font for all devices */
    padding: 12px;
}

.modal.modal-fullscreen-md-down .form-group label {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.modal.modal-fullscreen-md-down .student-item {
    padding: 15px;
    font-size: 1.2rem;
}

.modal-content {
    position: relative;
    background-color: #fefefe;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    z-index: 1051; /* Higher z-index than the modal backdrop */
}

/* Bootstrap modal backdrop fix */
.modal-backdrop {
    z-index: 1049 !important; /* Ensure backdrop is behind modal content */
}

.modal-open .modal {
    z-index: 1050 !important;
}



.modal-header {
    padding: 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 15px;
}

.modal-footer {
    padding: 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
}

/* Student search and list */
.search-container {
    position: relative;
}

.clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

.dropdown-list {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.student-item {
    padding: 8px 12px;
    cursor: pointer;
}

.student-item:hover {
    background-color: #f5f5f5;
}

.selected-student-item {
    display: inline-block;
    margin: 5px 5px 5px 0;
    padding: 5px 10px;
    background: #e9ecef;
    border-radius: 3px;
    border: 1px solid #ced4da;
}

.remove-student {
    margin-left: 8px;
    font-weight: bold;
    cursor: pointer;
}

/* Permission badges */
.permission-status {
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.status-yes {
    background-color: #d4edda;
    color: #155724;
}

.status-no {
    background-color: #f8d7da;
    color: #721c24;
}

/* Hour checkboxes */
.hour-checkboxes, .class-hours {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.hour-checkbox {
    flex: 0 0 calc(50% - 10px);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.hour-checkbox input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Make sure the modal is wide enough for two columns */
.modal-content {
    max-width: 900px;
}

/* Row and column layout for the modal */
.modal-body .row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.modal-body .col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding-right: 15px;
    padding-left: 15px;
    position: relative;
}

/* Mobile view - stack columns */
@media (max-width: 767.98px) {
    .modal-body .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Tablet-friendly modal improvements - especially for horizontal orientation */
@media only screen and (min-width: 768px) and (max-width: 1200px) {
    .modal.modal-fullscreen-md-down .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
    }

    .modal-header {
        padding: 25px 30px;
        border-bottom: 2px solid #dee2e6;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .modal-header h5 {
        font-size: 2.5rem;
        font-weight: 500;
        text-align: center;
    }

    .close-modal {
        font-size: 48px;
        padding: 0 15px;
        cursor: pointer;
    }

    .modal-body {
        padding: 35px;
        overflow-y: auto;
    }

    /* Ensure columns maintain proper width on tablets */
    .modal-body .col-md-6 {
        padding-right: 20px;
        padding-left: 20px;
    }

    /* Larger form controls for touch */
    .form-control {
        padding: 18px;
        font-size: 1.8rem;
        border-radius: 10px;
        margin-bottom: 15px;
        border-width: 2px;
    }

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

    .form-group label {
        font-size: 1.8rem;
        margin-bottom: 15px;
        font-weight: 600;
        display: block;
    }

    /* Larger checkboxes for easier selection */
    .form-check-input {
        width: 32px;
        height: 32px;
        margin-right: 18px;
        margin-top: 0;
        cursor: pointer;
    }

    .form-check-label {
        font-size: 1.8rem;
        padding: 5px 0;
        cursor: pointer;
    }

    /* Larger buttons for better touch targets */
    .modal-footer {
        display: flex;
        justify-content: center;
        gap: 30px;
    }

    .modal-footer .btn {
        padding: 15px 30px;
        font-size: 1.8rem;
        border-radius: 10px;
        min-width: 180px;
    }

    /* Improved student selection */
    .student-item {
        padding: 20px 25px;
        font-size: 1.8rem;
        border-bottom: 2px solid #eee;
    }

    .dropdown-list {
        max-height: 350px;
        border-width: 2px;
        border-radius: 10px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

    .selected-student-item {
        font-size: 1.7rem;
        padding: 12px 20px;
        margin: 10px;
        background-color: #e9f4ff;
        border-radius: 8px;
        display: inline-block;
        border: 2px solid #c9e3ff;
    }

    .remove-student {
        font-size: 2.2rem;
        margin-left: 12px;
        padding: 0 10px;
    }

    /* Larger class hours grid */
    .class-hours {
        gap: 20px;
        margin-top: 15px;
    }

    .hour-checkbox {
        flex: 0 0 calc(50% - 20px);
        margin-bottom: 20px;
        padding: 10px;
        background-color: #f8f9fa;
        border-radius: 10px;
        border: 1px solid #dee2e6;
    }

    .hour-checkbox:active {
        background-color: #e9ecef;
    }

    .hour-checkbox label {
        font-size: 1.8rem;
        margin-bottom: 0;
        cursor: pointer;
    }

    .hour-checkbox input[type="checkbox"] {
        width: 32px;
        height: 32px;
        margin-right: 15px;
    }

    /* Prominent permission status */
    .permission-status {
        font-size: 1.8rem;
        margin-left: 12px;
        padding: 4px 10px;
        border-radius: 6px;
    }

    .status-yes {
        background-color: rgba(0, 128, 0, 0.15);
    }

    .status-no {
        background-color: rgba(211, 47, 47, 0.15);
    }

    /* Make the search containers easier to use */
    .search-container {
        margin-bottom: 15px;
    }

    .clear-search {
        font-size: 2.2rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Single column hour display with larger font size */
.class-hours.single-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.class-hours.single-column .hour-checkbox {
    flex: 0 0 100%;
    margin-bottom: 8px;
    padding: 12px 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.class-hours.single-column .hour-checkbox:hover {
    background-color: #e9ecef;
}

.class-hours.single-column .hour-checkbox input[type="checkbox"] {
    margin-right: 12px;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.class-hours.single-column .hour-checkbox label {
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

/* Enhanced label and button styles */
.modal-content label {
    font-size: 1.2rem;
    font-weight: 500;
}

.modal-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.modal-footer .btn {
    font-size: 1.2rem;
    padding: 10px 20px;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
}

.form-control {
    font-size: 1.1rem;
    padding: 10px;
}

@media (max-width: 767.98px) {
    .modal-header h1 {
        font-size: 1.6rem;
    }
    
    .modal-content label,
    .modal-footer .btn,
    .form-control {
        font-size: 1.15rem;
    }
    
    .class-hours.single-column .hour-checkbox label {
        font-size: 1.2rem;
    }
}

/* Form section styling for better vertical distribution */
.modal-body .row.h-100 {
    min-height: 500px;
}

.col-md-6.d-flex.flex-column {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.form-section {
    position: relative;
}

.form-section.mb-4 {
    margin-bottom: 2rem !important;
}

.form-section .form-label {
    margin-bottom: 0.75rem;
}

.checkbox-group.mt-auto {
    margin-top: auto !important;
    padding-top: 1.5rem;
}

/* Right side hours column styling */
.col-md-6 .class-hours.single-column {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@media (max-width: 767.98px) {
    .modal-body .row.h-100 {
        min-height: auto;
    }
    
    .checkbox-group.mt-auto {
        margin-top: 2rem !important;
        padding-top: 0;
    }
}

/* Code Verification Modal Styles */
#code-verification-modal {
    overflow: hidden;
}

#code-verification-modal .modal-dialog {
    margin: 1.75rem auto;
    max-width: 500px;
}

#code-verification-modal .modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
}

#code-verification-modal .modal-content {
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    max-width: 100%;
    width: 100%;
}

#code-verification-modal .modal-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
}

#code-verification-modal .form-section {
    padding: 10px 0;
}

#verification-code {
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 2px;
    padding: 12px;
    border-width: 2px;
}

#verification-code.is-invalid {
    border-color: #dc3545;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Notification Styles */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1060;
    max-width: 350px;
}

.notification {
    display: none;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: center;
}

.notification-content i {
    margin-right: 10px;
    font-size: 1.5rem;
}

.success-notification {
    background-color: #d4edda;
    color: #155724;
    border-left: 5px solid #28a745;
}

.error-notification {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 5px solid #dc3545;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}