/* ============================================
   MODALS COMPONENT - Complete with Form Styles
   ============================================ */

/* ============================================
   MODAL OVERLAY
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(0px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.modal {
    background: #fff;
    border-radius: var(--radius-lg, 16px);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

/* Modal Scrollbar */
.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ============================================
   MODAL HEADER
   ============================================ */
.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
    border-radius: 16px 16px 0 0;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark, #2d3748);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title i {
    color: var(--yellow, #f6ad55);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-lighter, #a0aec0);
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0 5px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--danger, #fc8181);
    background: #fff5f5;
    transform: rotate(90deg);
}

/* ============================================
   MODAL BODY
   ============================================ */
.modal-body {
    padding: 25px;
    color: var(--text-medium, #4a5568);
}

/* ============================================
   MODAL FOOTER
   ============================================ */
.modal-footer {
    padding: 15px 25px 25px;
    border-top: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-radius: 0 0 16px 16px;
    background: #fafafa;
}

/* ============================================
   MODAL FORM ELEMENTS
   ============================================ */

/* Form Group */
.modal-body .form-group {
    margin-bottom: 18px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

/* Form Labels */
.modal-body .form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark, #2d3748);
    margin-bottom: 6px;
}

.modal-body .form-label .required {
    color: var(--danger, #fc8181);
    margin-left: 2px;
}

.modal-body .form-label .label-icon {
    margin-right: 6px;
    color: var(--yellow, #f6ad55);
}

/* Form Inputs */
.modal-body .form-input,
.modal-body .form-select,
.modal-body .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #f7fafc;
    color: var(--text-dark, #2d3748);
}

.modal-body .form-input:focus,
.modal-body .form-select:focus,
.modal-body .form-textarea:focus {
    outline: none;
    border-color: var(--yellow, #f6ad55);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(246, 173, 85, 0.15);
}

.modal-body .form-input.error,
.modal-body .form-select.error,
.modal-body .form-textarea.error {
    border-color: var(--danger, #fc8181);
    background: #fff5f5;
}

.modal-body .form-input.error:focus,
.modal-body .form-select.error:focus,
.modal-body .form-textarea.error:focus {
    box-shadow: 0 0 0 3px rgba(252, 129, 129, 0.15);
}

.modal-body .form-input:disabled,
.modal-body .form-select:disabled,
.modal-body .form-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Form Textarea */
.modal-body .form-textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
}

/* Form Select */
.modal-body .form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* Form Row (2 columns) */
.modal-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-body .form-row:last-child {
    margin-bottom: 0;
}

/* Form Hint */
.modal-body .form-hint {
    font-size: 12px;
    color: var(--text-lighter, #a0aec0);
    margin-top: 4px;
}

.modal-body .form-hint.error-hint {
    color: var(--danger, #fc8181);
}

/* ============================================
   CHECKBOXES & RADIO BUTTONS
   ============================================ */

/* Custom Checkbox */
.modal-body .checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
}

.modal-body .checkbox-group input[type="checkbox"] {
    display: none;
}

.modal-body .checkbox-group .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-medium, #cbd5e0);
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.modal-body .checkbox-group input:checked + .checkmark {
    background: var(--yellow, #f6ad55);
    border-color: var(--yellow, #f6ad55);
}

.modal-body .checkbox-group input:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.modal-body .checkbox-group:hover .checkmark {
    border-color: var(--yellow, #f6ad55);
}

.modal-body .checkbox-group .checkbox-label {
    font-size: 14px;
    color: var(--text-dark, #2d3748);
}

/* Custom Radio */
.modal-body .radio-group {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
}

.modal-body .radio-group input[type="radio"] {
    display: none;
}

.modal-body .radio-group .radio-mark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-medium, #cbd5e0);
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.modal-body .radio-group input:checked + .radio-mark {
    border-color: var(--yellow, #f6ad55);
}

.modal-body .radio-group input:checked + .radio-mark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--yellow, #f6ad55);
    border-radius: 50%;
}

.modal-body .radio-group:hover .radio-mark {
    border-color: var(--yellow, #f6ad55);
}

.modal-body .radio-group .radio-label {
    font-size: 14px;
    color: var(--text-dark, #2d3748);
}

/* ============================================
   PRIVILEGE GRID (Checkbox Grid)
   ============================================ */
.modal-body .privileges-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light, #e2e8f0);
}

.modal-body .privileges-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark, #2d3748);
    margin: 0 0 4px;
}

.modal-body .privileges-section h4 i {
    color: var(--yellow, #f6ad55);
    margin-right: 8px;
}

.modal-body .section-hint {
    font-size: 13px;
    color: var(--text-light, #718096);
    margin: 0 0 15px;
}

.modal-body .privileges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.modal-body .privilege-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.modal-body .privilege-item:hover {
    background: #edf2f7;
}

.modal-body .privilege-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--yellow, #f6ad55);
    cursor: pointer;
}

.modal-body .privilege-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.modal-body .privilege-label i {
    color: #a0aec0;
    font-size: 12px;
}

/* ============================================
   MODAL BUTTONS
   ============================================ */
.modal-footer .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.modal-footer .btn-yellow {
    background: var(--yellow, #f6ad55);
    color: #1a202c;
}

.modal-footer .btn-yellow:hover {
    background: var(--yellow-dark, #ed8936);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(246, 173, 85, 0.3);
}

.modal-footer .btn-yellow:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.modal-footer .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.modal-footer .btn-secondary:hover {
    background: #cbd5e0;
}

.modal-footer .btn-danger {
    background: #fc8181;
    color: #fff;
}

.modal-footer .btn-danger:hover {
    background: #f56565;
}

.modal-footer .btn-success {
    background: #48bb78;
    color: #fff;
}

.modal-footer .btn-success:hover {
    background: #38a169;
}

.modal-footer .btn-primary {
    background: #667eea;
    color: #fff;
}

.modal-footer .btn-primary:hover {
    background: #5a67d8;
}

/* ============================================
   MODAL CONFIRM TYPES
   ============================================ */
.modal-confirm .modal-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 15px;
}

.modal-confirm .modal-body {
    text-align: center;
}

.modal-icon-success { color: #48bb78; }
.modal-icon-danger { color: #fc8181; }
.modal-icon-warning { color: #ed8936; }
.modal-icon-info { color: #63b3ed; }

/* ============================================
   MODAL ANIMATIONS
   ============================================ */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .modal {
        max-width: 100%;
        margin: 10px;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
    
    .modal-body .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .modal-body .privileges-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .modal {
        margin: 5px;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 12px 16px;
    }
    
    .modal-title {
        font-size: 17px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        padding: 12px 16px;
    }
    
    .modal-body .privileges-grid {
        grid-template-columns: 1fr;
    }
}