/* static/css/style.css */

/* --- Base Styles --- */
body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

/* --- Navbar --- */
.main-navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand img {
    margin-top: -5px;
}

.navbar-nav .nav-link i {
    width: 1.2em;
    text-align: center;
}

/* --- Footer --- */
.footer-custom {
    font-size: 0.9em;
    background-color: #f8f9fa !important;
}

/* --- Authentication Forms Container --- */
.auth-form-container {
    background-color: #ffffff;
    padding: 2rem 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    margin-top: 2rem;
    position: relative;
    overflow: hidden;
    text-align: center;
    min-height: 400px;
}

.auth-form-container::before {
    content: "";
    display: block;
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
    z-index: 1;
}

.auth-logo {
    max-width: 150px; 
    height: auto; 
    display: block;
    position: absolute; 
    top: 40px; 
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    filter: brightness(0) invert(1);
}

.auth-form-content-wrapper {
    margin-top: 120px; /* CHANGED FROM 100px to 120px */
    padding-top: 1rem; /* ADDED: Extra padding at the top */
}

/* --- User Form Containers (Cards) --- */
.user-form-container.card {
     border: 1px solid rgba(0,0,0,.125);
     border-radius: 0.75rem;
     overflow: hidden;
}

.user-form-container .card-header {
    font-weight: 500;
    padding: 1rem 1.5rem;
}

.user-form-container .card-body {
     padding: 2rem;
}

/* --- Home Dashboard --- */
.home-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Notifications --- */
.notifications-section {
    animation: slideInDown 0.5s ease-out;
}

.notification-card {
    border-left: 4px solid currentColor;
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease-in;
}

.notification-icon {
    flex-shrink: 0;
}

.notification-content {
    line-height: 1.6;
}

.notification-meta {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.notification-preview {
    background-color: rgba(255,255,255,0.3);
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

/* --- App Widgets --- */
.app-widget {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 2px solid #e9ecef;
    border-radius: 1rem;
    background: #ffffff;
    position: relative;
}

.app-widget:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.app-widget .card-img-top-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 180px;
    transition: background 0.3s ease;
}

.app-widget:hover .card-img-top-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.app-widget .app-widget-icon {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.app-widget:hover .app-widget-icon {
    transform: scale(1.1);
    filter: brightness(0) invert(1);
}

.app-widget .card-body {
    background-color: #fff;
    padding: 1.25rem;
    border-top: 1px solid #e9ecef;
}

.app-widget .card-title {
    color: #343a40;
    margin-bottom: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* --- Favorite Star Button --- */
.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.favorite-btn:hover {
    background: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.favorite-btn i {
    color: #ffc107;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.favorite-btn.active i {
    color: #ffc107;
}

.favorite-btn:not(.active) i {
    color: #dee2e6;
}

/* --- 2FA Setup --- */
.qr-code-container img {
    max-width: 220px;
    height: auto;
    border: 2px solid #dee2e6;
    padding: 10px;
    border-radius: 0.5rem;
    background: #fff;
}

.secret-key-display {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1em;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.secret-key-display code {
    padding-right: 10px;
    text-align: left;
    font-weight: 600;
}

.copy-button {
    padding: 0.375rem 0.75rem;
    font-size: 0.9em;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.copy-button:hover {
    transform: scale(1.05);
}

/* --- Admin Tables --- */
.table th {
    font-weight: 600;
    background-color: #f8f9fa;
}

.table-sm th, .table-sm td {
    padding: 0.5rem;
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
}

.table th.sortable:hover {
    background-color: rgba(0,0,0,0.05);
}

.table th i.fa-sort {
    font-size: 0.8em;
    margin-left: 5px;
}

.action-buttons .btn {
    vertical-align: middle;
}

.table td .badge {
    vertical-align: middle;
    font-size: 0.8em;
    padding: 0.35em 0.65em;
}

.user-roles-cell .badge {
    font-size: 0.78em;
    padding: 0.3em 0.6em;
}

.table th.sortable a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.table th.sortable a:hover {
    color: var(--bs-primary);
}

/* --- Role Selection Table --- */
.roles-table-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
}

.roles-table th {
    font-weight: 600;
    font-size: 0.85em;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0.75rem 0.5rem;
    background-color: #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1;
}

.roles-table td {
    vertical-align: middle;
    padding: 0.5rem;
    font-size: 0.9em;
}

.roles-table th:first-child, .roles-table td:first-child {
    width: 40%;
}

.roles-table th.text-center, .roles-table td.text-center {
    width: 20%;
}

.roles-table .form-check.d-inline-flex {
    min-height: 1.5rem;
    align-items: center;
    padding-left: 0;
}

.roles-table .form-check-input {
    float: none;
    margin-left: 0;
    margin-right: 0;
    height: 1.2em;
    width: 1.2em;
    cursor: pointer;
}

/* --- Flash Messages (Toasts) --- */
.flashes-container {
    z-index: 1060;
}

.toast {
    width: 350px;
    max-width: 100%;
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Utility Classes --- */
.fa-xs {
    font-size: 0.75em;
}

.fa-lg {
    font-size: 1.33em;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .app-widget .card-img-top-container {
        height: 140px;
        padding: 1.5rem;
    }
    
    .favorite-btn {
        width: 35px;
        height: 35px;
    }
    
    .favorite-btn i {
        font-size: 1rem;
    }
    
    .notification-card {
        padding: 1rem;
    }
    
    .notification-icon {
        display: none;
    }
}

/* --- Form Enhancements --- */
.form-floating > label {
    padding-left: 1rem;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* --- Button Enhancements --- */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #65408b 100%);
}

/* --- Card Enhancements --- */
.card {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card-header {
    border-top-left-radius: 0.75rem !important;
    border-top-right-radius: 0.75rem !important;
    border-bottom: none;
}

/* --- Alert Enhancements --- */
.alert {
    border-radius: 0.5rem;
    border: none;
}

/* --- Modal Enhancements --- */
.modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
}

/* --- Password Strength Feedback --- */
.password-strength-feedback {
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    border-left: 3px solid #dee2e6;
}

.password-strength-feedback div {
    padding: 0.15rem 0;
    font-size: 0.875rem;
}

.password-strength-feedback i {
    width: 1.2em;
}

.form-control.is-valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
}

.form-control.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
}


/* --- User Management Table Improvements --- */
.user-management-table td {
    vertical-align: middle;
}

.user-management-table .badge {
    font-size: 0.75rem;
    padding: 0.25em 0.5em;
}

/* --- Target Checkboxes Container --- */
.target-checkboxes-container {
    padding: 0.75rem;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.target-checkboxes-container .form-check {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.target-checkboxes-container .form-check:hover {
    background-color: #f8f9fa;
}

.target-checkboxes-container .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
    cursor: pointer;
    border: 2px solid #6c757d;
}

.target-checkboxes-container .form-check-input:checked {
    background-color: #667eea;
    border-color: #667eea;
}

.target-checkboxes-container .form-check-label {
    cursor: pointer;
    user-select: none;
    margin-left: 0.5rem;
    font-size: 0.95rem;
    color: #495057;
}

.target-checkboxes-container::-webkit-scrollbar {
    width: 8px;
}

.target-checkboxes-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.target-checkboxes-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.target-checkboxes-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* --- Notification Preview Improvements --- */
.notification-preview {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* --- Form Section Headers --- */
.card-body h5 {
    color: #495057;
    font-weight: 600;
}

.card-body h5 i {
    color: #667eea;
}

/* --- Badge Improvements --- */
.badge-sm {
    font-size: 0.7rem;
    padding: 0.2em 0.4em;
}

/* Required field indicator for select fields */
select[required]:invalid {
    color: #6c757d;
}

select[required]:valid {
    color: #212529;
}

/* Style for placeholder option in select */
select option[value=""] {
    color: #6c757d;
    font-style: italic;
}

select option:not([value=""]) {
    color: #212529;
    font-style: normal;
}