/* ========================================
   SETTINGS PAGE - ADD USER MODAL STYLES
   ======================================== */

/* This CSS file contains all styles specific to the settings page,
   particularly the Add User modal form that appears when clicking
   "Add User" button */

/* ===== MODAL OVERLAY ===== */
/* Semi-transparent dark background that covers the entire page when modal is open */
.modal {
    display: none; /* Hidden by default, shown via JavaScript */
    position: fixed; /* Stays in place even when scrolling */
    z-index: 1000; /* Appears above all other content */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Dark semi-transparent overlay */
    overflow: auto; /* Enable scrolling if content is too long */
    animation: fadeIn 0.3s ease; /* Smooth fade-in animation */
}

/* Fade-in animation for modal appearance */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== MODAL CONTENT BOX ===== */
/* The white box that contains the form */
.modal-content {
    background-color: #ffffff;
    margin: 3% auto; /* Centered horizontally with top margin */
    padding: 30px;
    border: 1px solid #dee2e6;
    border-radius: 12px; /* Rounded corners */
    width: 90%; /* Responsive width */
    max-width: 700px; /* Maximum width to maintain readability */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); /* Subtle shadow for depth */
    animation: slideDown 0.3s ease; /* Slide down animation */
    position: relative;
}

/* Slide-down animation for modal content */
@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== FORM LAYOUT ===== */
/* Two-column grid layout for form fields (matches maintenance form) */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    gap: 15px; /* Space between columns */
    margin-bottom: 15px;
}

/* Individual form field container */
.form-group {
    margin-bottom: 15px;
}

/* Full-width form fields (spans both columns) */
.form-group.full-width {
    grid-column: 1 / -1; /* Spans from first to last column */
}

/* ===== FORM LABELS ===== */
/* Styling for all form labels */
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

/* Required field indicator (red asterisk) */
.form-group label span[style*="color: red"] {
    color: #dc3545;
    font-weight: bold;
}

/* ===== FORM INPUTS ===== */
/* Styling for text inputs, email, tel, select dropdowns */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease; /* Smooth transition for hover/focus effects */
    background-color: #ffffff;
    box-sizing: border-box; /* Include padding in width calculation */
}

/* Hover effect for form inputs */
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #4a90e2;
}

/* Focus effect when user clicks on input */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; /* Remove default browser outline */
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1); /* Subtle blue glow */
}

/* Placeholder text styling */
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #999;
    font-style: italic;
}

/* ===== TEXTAREA ===== */
/* Special styling for multi-line text areas */
.form-group textarea {
    resize: vertical; /* Allow vertical resizing only */
    min-height: 100px;
    font-family: inherit;
}

/* ===== SELECT DROPDOWNS ===== */
/* Additional styling for dropdown select boxes */
.form-group select {
    cursor: pointer;
    appearance: none; /* Remove default dropdown arrow */
    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='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center; /* Position custom arrow */
    padding-right: 35px; /* Space for custom arrow */
}

/* ===== PERMISSION CHECKBOXES ===== */
/* Styling for permission checkbox labels */
.permission-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none; /* Prevent text selection when clicking */
}

/* Hover effect for permission checkboxes */
.permission-checkbox:hover {
    background: #f8f9fa;
    border-color: #4a90e2;
}

/* Checkbox input styling */
.permission-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4a90e2; /* Modern checkbox color (works in most browsers) */
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

/* Checkbox label text */
.permission-checkbox span {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

/* Highlight checked checkboxes */
.permission-checkbox:has(input:checked) {
    background: #e3f2fd;
    border-color: #4a90e2;
}

.permission-checkbox:has(input:checked) span {
    color: #1976d2;
    font-weight: 600;
}

/* ===== ACTION BUTTONS ===== */
/* Styling for form buttons (Add User, Cancel) */

/* Primary button (Add User) */
/* Primary button (Add User) - RED like Schedule Maintenance */
/* Primary button (Add User) - RED */
/* Primary button (Red) - for main actions like + Add User */
.btn {
    background: #b00;          /* ✅ DARKER RED to match maintenance */
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(200, 35, 51, 0.3);  /* ✅ Updated shadow color */
}

.btn:hover {
    background: #bd2130;          /* ✅ Even darker on hover */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(200, 35, 51, 0.4);  /* ✅ Updated shadow color */
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(200, 35, 51, 0.3);
}

/* Cancel button */
/* Cancel button - DARK TEAL */
.btn-cancel {
    background: linear-gradient(135deg, #244855 0%, #2d5a68 100%);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Hover effect for cancel button */
.btn-cancel:hover {
    background: linear-gradient(135deg, #2d5a68 0%, #244855 100%);
    transform: translateY(-2px);
}

/* ===== SECTION HEADERS ===== */
/* Styling for section headers within the form */
.modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 10px;
}

/* ===== RESPONSIVE DESIGN ===== */
/* Adjustments for tablets and smaller screens */
@media (max-width: 768px) {
    /* Full-width modal on smaller screens */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
    }

    /* Stack form fields vertically on small screens */
    .form-row {
        grid-template-columns: 1fr; /* Single column layout */
        gap: 10px;
    }

    /* Stack permission checkboxes vertically */
    .modal-content div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Smaller button text on mobile */
    .btn,
    .btn-cancel {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* Adjustments for mobile phones */
@media (max-width: 480px) {
    .modal-content {
        margin: 2% auto;
        padding: 15px;
    }

    /* Smaller section headers on mobile */
    .modal-content h3 {
        font-size: 16px;
    }

    /* Smaller form inputs on mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 13px;
        padding: 8px 10px;
    }
}

/* ===== CLOSE BUTTON (X) ===== */
/* Styling for the X button in modal header */
.modal-content button[onclick*="closeAddUserForm"] {
    transition: all 0.2s ease;
}

.modal-content button[onclick*="closeAddUserForm"]:hover {
    color: #dc3545; /* Red color on hover */
}

/* ===== SCROLLBAR STYLING ===== */
/* Custom scrollbar for modal content */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== FORM VALIDATION STYLES ===== */
/* Styling for invalid form fields (when HTML5 validation fails) */
.form-group input:invalid:not(:placeholder-shown),
.form-group select:invalid:not([value=""]) {
    border-color: #dc3545;
}

/* Styling for valid form fields */
.form-group input:valid:not(:placeholder-shown),
.form-group select:valid:not([value=""]) {
    border-color: #28a745;
}

/* ===== LOADING STATE ===== */
/* Optional: Add loading spinner styles if needed for async operations */
.btn.loading {
    position: relative;
    color: transparent; /* Hide button text while loading */
    pointer-events: none; /* Disable clicking while loading */
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== SUCCESS MESSAGE ===== */
/* Optional: Styling for success messages after form submission */
.success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.success-message::before {
    content: "✓";
    font-weight: bold;
    font-size: 20px;
}

/* ===== ERROR MESSAGE ===== */
/* Optional: Styling for error messages */
.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.error-message::before {
    content: "⚠";
    font-weight: bold;
    font-size: 20px;
}

.permission-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.permission-checkbox:hover {
    background: #f8f9fa;
    border-color: #4a90e2;
}

.permission-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4a90e2;
}

.permission-checkbox span {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.permission-checkbox:has(input:checked) {
    background: #e3f2fd;
    border-color: #4a90e2;
}

.permission-checkbox:has(input:checked) span {
    color: #1976d2;
    font-weight: 600;
}

/* Secondary buttons (Import, Export, etc.) - DARK TEAL */
/* Secondary buttons - Dark Teal (for less important actions) */
.btn-secondary {
    background: #555;
    color: white;
    border: none;
    padding: 8px 18px;          /* ✅ Match primary button size */
    border-radius: 4px;           /* ✅ Changed from 4px to 6px */
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(36, 72, 85, 0.3);  /* ✅ Added shadow */
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #2d5a68 0%, #244855 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(36, 72, 85, 0.4);  /* ✅ Enhanced hover shadow */
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(36, 72, 85, 0.3);
}

/* ✅ NEW: Action buttons in tables (Edit, Delete, View, etc.) */
.btn-action {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 3px;
}

/* Edit button - Dark Teal */
.btn-edit {
    background: linear-gradient(135deg, #244855 0%, #2d5a68 100%);
    color: white;
}

.btn-edit:hover {
    background: linear-gradient(135deg, #2d5a68 0%, #244855 100%);
    transform: translateY(-2px);
}

/* Delete button - Red */
.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Status badge - Green (ACTIVE) */
.status-active {
    background: #28a745;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

/* Status badge - Gray (INACTIVE) */
.status-inactive {
    background: #6c757d;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

/* ================================================================================
   ROLES & LEVELS MANAGEMENT - ADDITIONAL STYLES
   Added: [Today's Date]
   ================================================================================ */

/* Roles table styling */
.roles-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.roles-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.roles-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.roles-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.roles-table tbody tr:hover {
    background: #f8f9fa;
}

.roles-table tbody tr:last-child td {
    border-bottom: none;
}

/* Role level badge */
.role-level-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #e3f2fd;
    color: #1976d2;
}

/* Role color preview circle */
.role-color-preview {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 2px solid #dee2e6;
    vertical-align: middle;
}

/* System role badge */
.system-role-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f0f0;
    color: #666;
    margin-left: 8px;
}

/* Protected role row highlight */
.protected-role {
    background: #ffe5e5 !important;
}

/* Small icon buttons for table actions */
.btn-icon-sm {
    padding: 4px 8px;
    border-radius: 4px;
    border: none;
    font-size: 12px;
    cursor: pointer;
    margin: 0 2px;
    transition: all 0.2s ease;
}

/* Edit role button */
.btn-edit-role {
    background: #3498db;
    color: white;
}

.btn-edit-role:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

/* Delete role button */
.btn-delete-role {
    background: #e74c3c;
    color: white;
}

.btn-delete-role:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* Disabled button state */
.btn-icon-sm:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-icon-sm:disabled:hover {
    transform: none;
}

/* Color input styling */
.form-group input[type="color"] {
    width: 100%;
    height: 40px;
    cursor: pointer;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 2px;
}

.form-group input[type="color"]:hover {
    border-color: #4a90e2;
}

/* Number input styling */
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background-color: #ffffff;
    box-sizing: border-box;
}

.form-group input[type="number"]:hover {
    border-color: #4a90e2;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Small text below form inputs */
.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* ===== RESPONSIVE DESIGN FOR ROLES TABLE ===== */
@media (max-width: 768px) {
    .roles-table {
        font-size: 12px;
    }
    
    .roles-table th,
    .roles-table td {
        padding: 8px 10px;
    }
    
    .btn-icon-sm {
        padding: 3px 6px;
        font-size: 11px;
    }
    
    .role-color-preview {
        width: 25px;
        height: 25px;
    }
}

@media (max-width: 480px) {
    /* Stack table cells vertically on very small screens */
    .roles-table thead {
        display: none;
    }
    
    .roles-table tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
    }
    
    .roles-table td {
        display: block;
        text-align: right;
        padding: 10px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .roles-table td:before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: #2c3e50;
    }
    
    .roles-table td:last-child {
        border-bottom: none;
    }
}

/* ===== END OF ROLES & LEVELS STYLES ===== */

/* ========================================
   ICON-ONLY ACTION BUTTONS (NO COLORED BACKGROUNDS)
   ======================================== */

/* Icon-only button - transparent background */
.btn-icon-action {
    background: transparent;      /* No background color */
    border: none;                 /* No border */
    padding: 4px;                 /* Minimal padding */
    margin: 0 4px;                /* Space between buttons */
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Hover effect - slight scale and opacity change */
.btn-icon-action:hover {
    transform: scale(1.15);       /* Enlarge on hover */
    opacity: 0.8;                 /* Slight transparency */
}

/* Active/click effect */
.btn-icon-action:active {
    transform: scale(0.95);       /* Slightly smaller on click */
}

/* SVG icon styling */
.action-icon {
    width: 24px;                  /* Icon size */
    height: 24px;                 /* Icon size */
    display: block;               /* Remove inline spacing */
    pointer-events: none;         /* Clicks pass through to button */
}

/* Remove any filters - use original SVG colors */
.btn-icon-action .action-icon {
    filter: none;                 /* Keep original icon colors */
}