/* Access Control Panel Styles */

/* Main container styling */
.access-control-wrapper {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#access-control-container {
    width: 100%;
}

/* Card styling */
.card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    width: 100%;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15) !important;
}

.card-header {
    border-bottom: 3px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    font-weight: 600;
}

.card-body {
    padding: 2rem;
}

/* Spinner styling for loading */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* Border styles */
.border-left-4 {
    border-left: 4px solid #0d6efd !important;
}

/* Checkbox styling */
.form-check {
    padding: 0.75rem 0;
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 0.35rem;
    cursor: pointer;
    border-radius: 4px;
    border: 2px solid #dee2e6;
    transition: all 0.2s ease;
}

.form-check-input:hover {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
    box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.1);
}

.form-check-input:focus {
    border-color: #0d6efd;
    outline: none;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    font-size: 0.95rem;
    color: #333;
}

.form-check-label:hover {
    color: #0d6efd;
}

/* Form switch (toggle) styling */
.form-switch .form-check-input {
    width: 2.5em;
    height: 1.3em;
    border-radius: 1em;
    margin-left: -2.75em;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280,0,0,.25%29'/%3e%3c/svg%3e");
    background-size: 1em 1em;
    background-position: left 0.25em center;
    transition: all 0.3s ease;
}

.form-switch .form-check-input:checked {
    background-position: right 0.25em center;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255,255,255,.25%29'/%3e%3c/svg%3e");
}

/* Reduce height (length) of Can Upload switches while keeping width the same */
.form-check.form-switch .form-check-input[id*="can-upload-"] {
    height: 0.85em;
    margin-top: 0.2rem;
}

/* Button styling */
.btn {
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0b5ed7 0%, #0a58ca 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #198754 0%, #157347 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #157347 0%, #146c43 100%);
    color: white;
}

.btn-primary:disabled,
.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading spinner animation */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

/* Select styling */
.form-select {
    border-radius: 8px;
    border: 2px solid #dee2e6;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
    outline: none;
}

.form-select-lg {
    padding: 0.9rem 1.25rem;
    font-size: 1.1rem;
}

/* Badge styling */
.badge {
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-secondary {
    background-color: #6c757d;
    color: white;
}

/* Alert styling */
.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-left: 4px solid #c3e6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #bee5eb;
}

.btn-close {
    padding: 0;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.btn-close:hover {
    opacity: 1;
}

/* Label styling */
.form-label {
    margin-bottom: 0.75rem;
    color: #333;
    font-weight: 600;
}

/* Small text styling */
.text-muted {
    color: #6c757d !important;
    font-size: 0.85rem;
}

.text-secondary {
    color: #6c757d !important;
}

/* Checkbox grid layout (scoped to Access Control only) */
.access-control-wrapper .row.g-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Page title styling */
.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 2rem !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .access-control-wrapper {
        padding: 1.5rem;
    }
}

@media (max-width: 992px) {
    .access-control-wrapper {
        padding: 1.25rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    .access-control-wrapper {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem !important;
    }
    
    .access-control-wrapper .row.g-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card-body {
        padding: 1.5rem 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .col-md-6,
    .col-lg-4 {
        flex: 0 0 100% !important;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
}

/* Background light styling */
.bg-light {
    background-color: #f8f9fa !important;
}

/* Padding utilities */
.p-2 {
    padding: 0.5rem;
}

.p-4 {
    padding: 1.5rem;
}

/* Margin utilities */
.mb-4 {
    margin-bottom: 1.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.ms-2 {
    margin-left: 0.5rem;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Animation for successful saves */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.btn.btn-success {
    animation: pulse 0.6s ease;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .col-lg-4 {
        flex: 0 0 50%;
    }
}

/* Responsive adjustments for small screens */
@media (max-width: 576px) {
    .access-control-wrapper {
        padding: 0.75rem;
    }
    
    .page-title {
        font-size: 1.25rem;
        margin-bottom: 1rem !important;
    }
    
    .card {
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .card-body {
        padding: 1rem 0.75rem;
    }
    
    .card-header {
        padding: 0.75rem;
    }
    
    .btn {
        width: 100%;
        margin-top: 1rem;
        font-size: 0.8rem;
    }
    
    .form-check {
        padding: 0.5rem 0;
    }
    
    .form-label {
        font-size: 0.9rem;
    }
    
    .text-muted {
        font-size: 0.75rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #access-control-container {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    }
    
    .card {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .form-check-label {
        color: #e0e0e0;
    }
    
    .form-label {
        color: #e0e0e0;
    }
    
    .text-muted,
    .text-secondary {
        color: #a0a0a0 !important;
    }
}

/* Prevent labels from fragmenting into single characters in tight layouts */
.access-control-wrapper .form-label,
.access-control-wrapper .card .form-label {
    white-space: normal;
    word-break: break-word;
}

/* Keep form control minimum widths so filter boxes remain usable */
.access-control-wrapper .form-select,
.access-control-wrapper .form-check .form-check-input {
    min-width: 140px;
}

/* FINAL: smaller Can Upload switch only on Access Control */
.access-control-wrapper .form-check.form-switch .form-check-input[id*="can-upload-"] {
    min-width: 0 !important;        /* override 140px */
    width: 1.8em !important;        /* length of track */
    height: 0.9em !important;       /* thickness */
    margin-left: -2.0em !important; /* Bootstrap offset */
    background-size: 0.9em 0.9em;   /* knob size */
}


/* Keep small inline labels from breaking across lines */
.access-control-wrapper .form-check-label,
.access-control-wrapper .checkbox-grid .checkbox-label span {
    white-space: nowrap;
}

/* Slightly increase select/button hit areas in small screens */
@media (max-width: 768px) {
    .access-control-wrapper .form-select,
    .access-control-wrapper .btn {
        min-width: 120px;
    }
}
/* ===== FIX USER OVERRIDES TAB LAYOUT ===== */

/* Keep the left-side "Select User" card at a normal readable width */
#user-override-container .card {
    max-width: 380px;
}

/* Fix broken splitting of label text like "Sele ct User" */
#user-override-container .form-label {
    white-space: nowrap !important;   /* keep full label on one line */
    word-break: normal !important;    /* prevent breaking inside words */
}

/* Make the dropdown box full width inside the card */
#user-override-container .form-select {
    width: 100% !important;
    min-width: 0 !important;          /* override the global 140px min-width */
}

/* Improve spacing on small screens */
@media (max-width: 768px) {
    #user-override-container .card {
        max-width: 100%;
    }
}

.access-control-content {
    width: 100%;
    min-height: 400px;
    display: block; /* default, ensures proper layout */
}
