/* Base Styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #f4f7fc;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 950px;
    margin: 40px auto;
    background: linear-gradient(to bottom right, #ffffff, #f4f7fc);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* Header Styling */
.form-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.logo {
    height: 60px;
    width: 60px;
    margin-right: 15px;
    object-fit: contain;
}

.title-container {
    flex-grow: 1;
    text-align: center;
}

h1 {
    color: #2c3e50;
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

/* Form Layout */
.row {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.col-md-6 {
    flex: 1;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

label {
    font-weight: 500;
    display: block;
    margin-bottom: 6px;
    color: #2c3e50;
    font-size: 14px;
}

select, textarea, input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    background-color: #fff;
    box-sizing: border-box;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

select:focus, textarea:focus, input[type="text"]:focus {
    border-color: #007bff;
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.3);
    outline: none;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Icon Card Radio Button Styling */
.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 8px;
}

.radio-card {
    flex: 1;
    cursor: pointer;
    max-width: 180px;
    position: relative;
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-card-content {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background-color: #fff;
    transition: all 0.2s ease;
}

.radio-card:hover .radio-card-content {
    border-color: #ccc;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.radio-card input[type="radio"]:checked + .radio-card-content {
    border-width: 2px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.radio-card input[type="radio"][value="Safe Act"]:checked + .radio-card-content {
    border-color: #28a745;
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.2);
}

.radio-card input[type="radio"][value="Unsafe Act"]:checked + .radio-card-content {
    border-color: #dc3545;
    box-shadow: 0 3px 8px rgba(220, 53, 69, 0.2);
}

.radio-card-content .card-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.radio-card-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radio-card-label {
    font-weight: 500;
    color: #495057;
}

.radio-card input[type="radio"][value="Safe Act"]:checked + .radio-card-content .radio-card-icon {
    color: #28a745;
}

.radio-card input[type="radio"][value="Unsafe Act"]:checked + .radio-card-content .radio-card-icon {
    color: #dc3545;
}

.radio-card input[type="radio"][value="Safe Act"]:checked + .radio-card-content .radio-card-label {
    color: #28a745;
}

.radio-card input[type="radio"][value="Unsafe Act"]:checked + .radio-card-content .radio-card-label {
    color: #dc3545;
}

.radio-card input[type="radio"]:disabled + .radio-card-content {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.radio-card input[type="radio"]:focus + .radio-card-content {
    outline: 2px solid rgba(0, 123, 255, 0.25);
    outline-offset: 2px;
}

/* Submit Button */
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-primary {
    background-color: #0056d2;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(0, 86, 210, 0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-primary:hover {
    background-color: #0046b3;
    transform: translateY(-1px);
}

/* Select2 Styling - IMPROVED FOR BETTER ALIGNMENT */
.select2-container .select2-selection--single {
    height: 42px;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #444;
    line-height: 42px; /* Match the height of the select container */
    padding-left: 14px; /* Match the padding of other form elements */
    padding-right: 20px; /* Space for the dropdown arrow */
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
    width: 30px;
    right: 3px;
}

.select2-container--default .select2-results__option {
    padding: 8px 14px;
    font-size: 14px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0056d2;
}

.select2-dropdown {
    border: 1px solid #ccc;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Fix dropdown width to match container */
.select2-container {
    width: 100% !important;
}

/* Placeholder styling */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #999;
}

/* Date picker styling */
.flatpickr-input {
    background-color: #fff !important;
}

/* Consistent input vertical alignment fix */
select, textarea, input[type="text"] {
    vertical-align: middle;
    line-height: 1.5;
    height: 42px; /* Fixed height for better alignment */
}

/* Make sure textarea keeps its height */
textarea {
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Alert styling */
.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid transparent;
}

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

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

.btn-close {
    float: right;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: inherit;
    opacity: 0.5;
    background: none;
    border: 0;
    cursor: pointer;
}

/* Disabled state styling */
select:disabled, textarea:disabled, input[type="text"]:disabled,
input[type="radio"]:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Responsive Enhancements */
@media (max-width: 576px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
        margin: 20px auto;
        border-radius: 12px;
    }

    h1 {
        font-size: 22px;
    }

    label, select, textarea, input[type="text"] {
        font-size: 13px;
    }

    .form-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .title-container {
        text-align: left;
        margin-top: 10px;
    }

    .form-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
}

/* Ensure flex items wrap on smaller screens */
.row {
    flex-wrap: wrap;
}


/* Modal Styling */
.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal-body svg {
    width: 64px;
    height: 64px;
}

.modal-body h4 {
    font-weight: 600;
    color: #28a745;
}

.modal-body p {
    font-size: 14px;
    color: #6c757d;
}

.modal-footer .btn {
    min-width: 160px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
}

/* Custom yellow button for Emaint */
.btn-emaint {
    background-color: #fff8dc; /* light yellow */
    color: #5c3d00;
    border: 1px solid #ffe39f;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-emaint:hover {
    background-color: #ffe39f;
    color: #3e2c00;
    transform: translateY(-1px);
}

/* Notify Supervisor Button Styling */
.btn-notify {
    background-color: #ff9800;
    color: white;
    transition: all 0.2s ease;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(255, 152, 0, 0.2);
}

.btn-notify:hover {
    background-color: #e68a00;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(255, 152, 0, 0.3);
}

.btn-notify:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.3);
}

.btn-notify.sent {
    background-color: #28a745;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.2);
}

.btn-notify .notify-text {
    display: inline-block;
}

.btn-notify .sent-text {
    display: none;
}

.btn-notify.sent .notify-text {
    display: none;
}

.btn-notify.sent .sent-text {
    display: inline-block;
}

.loading-spinner {
    width: 1.2rem;
    height: 1.2rem;
    display: none;
    vertical-align: text-bottom;
}

.btn-notify.loading .loading-spinner {
    display: inline-block;
}

.btn-notify.loading .notify-text {
    display: none;
}

.btn-notify.loading {
    background-color: #ff9800;
    opacity: 0.8;
    cursor: wait;
}

/* Style for supervisor name */
.supervisor-name {
    font-weight: normal;
    font-style: italic;
    margin-left: 3px;
}

/* Calendar Icon Styling */
.calendar-icon {
    cursor: pointer;
    background-color: #f8f9fa;
    border-color: #ccc;
    transition: background-color 0.2s;
}

.calendar-icon:hover {
    background-color: #e9ecef;
}

.input-group {
    display: flex;
    width: 100%;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: center;
    white-space: nowrap;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 0 0.25rem 0.25rem 0;
}

/* NEW RESPONSIVE IMPROVEMENTS */

/* Improve mobile responsiveness */
@media (max-width: 768px) {
  /* Better form layout on tablets */
  .row {
    flex-direction: column;
    gap: 12px;
  }
  
  /* Improve date picker on mobile */
  .input-group {
    flex-wrap: nowrap;
  }
  
  /* Better modal responsiveness */
  .modal-dialog {
    margin: 10px;
  }
  
  /* Improve action buttons in success modal */
  .d-flex.justify-content-center.flex-wrap.gap-3 {
    flex-direction: column;
  }
  
  .d-flex.justify-content-center.flex-wrap.gap-3 .btn {
    margin-bottom: 10px;
    width: 100%;
  }
}

/* Improve tiny screens (iPhone SE, etc) */
@media (max-width: 375px) {
  .container {
    padding: 15px;
    margin: 10px auto;
  }
  
  /* Improve radio buttons on tiny screens */
  .radio-group {
    flex-direction: column;
    gap: 10px;
  }
  
  .radio-card {
    max-width: none;
  }
}

/* Ensure date picker appears above other elements */
.flatpickr-calendar {
  z-index: 1060 !important;
}

/* Fix for modal on mobile */
.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem);
}

/* Improve Select2 on mobile */
@media (max-width: 576px) {
  .select2-container .select2-selection--single {
    height: 38px;
  }
  
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
  }
}

/* Ensure form fields are accessible */
select, textarea, input[type="text"], .form-check-input {
  touch-action: manipulation;
}

/* Fix for iOS modal */
body.modal-open-ios {
  position: fixed;
  width: 100%;
}

/* User authentication styling */
.user-auth {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info span {
    font-size: 14px;
    color: #555;
}

/* Weekly Submissions Button */
.btn-info {
    background-color: #17a2b8;
    color: white;
    transition: all 0.2s ease;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(23, 162, 184, 0.2);
}

.btn-info:hover {
    background-color: #138496;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(23, 162, 184, 0.3);
}

/* Weekly Submissions Modal */
#weekSubmissionsModal .modal-header {
    background-color: #f8f9fa;
    padding: 15px 20px;
}

#weekSubmissionsModal .modal-title {
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

#weekSubmissionsModal .modal-body {
    padding: 20px;
    max-height: 50vh;
    overflow-y: auto;
}

#weekSubmissionsModal .modal-footer {
    background-color: #f8f9fa;
    padding: 15px 20px;
}

/* Submission List Items */
#submissionsContainer .list-group-item {
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

#submissionsContainer .list-group-item:hover {
    background-color: #f8f9fa;
}

#submissionsContainer .list-group-item h6 {
    font-weight: 600;
    color: #2c3e50;
}

#submissionsContainer .badge {
    padding: 6px 10px;
    font-weight: 500;
    font-size: 12px;
    border-radius: 6px;
}

#submissionsContainer .badge.bg-success {
    background-color: #28a745 !important;
}

#submissionsContainer .badge.bg-danger {
    background-color: #dc3545 !important;
}

/* Loading State */
#submissionsContainer .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-bottom: 12px;
    color: #0056d2;
}

#submissionsContainer .alert {
    margin-bottom: 0;
}

/* Mobile Optimization for Weekly Submissions */
@media (max-width: 576px) {
    #weekSubmissionsModal .modal-body {
        max-height: 60vh;
        padding: 15px;
    }
    
    #submissionsContainer .list-group-item {
        padding: 12px;
    }
    
    #submissionsContainer .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    #submissionsContainer .badge {
        margin-top: 5px;
    }
}