/**
 * Authentication Styles
 * Login, Register, and User Management UI
 * Styled to match Operations Center modal design
 */

/* =====================================================
   AUTH MODAL STYLES
   ===================================================== */

.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.auth-modal.active {
    display: flex;
}

.auth-modal-dialog {
    width: 100%;
    max-width: 420px;
    animation: authModalSlideIn 0.3s ease-out;
}

.auth-modal-content {
    background: linear-gradient(180deg, #1a1a2e 0%, #141422 100%);
    border-radius: 16px;
    border: 1px solid rgba(79, 116, 229, 0.3);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset,
                0 0 60px rgba(79, 116, 229, 0.15);
    overflow: hidden;
}

@keyframes authModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal Header */
.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(180deg, rgba(15, 15, 26, 0.95) 0%, rgba(15, 15, 26, 0.8) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-modal-header h2,
.auth-modal-header h3 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.auth-modal-header p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    margin: 4px 0 0 0;
}

.auth-modal-header .header-text {
    display: flex;
    flex-direction: column;
}

/* Close Button */
.auth-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 8px;
    color: #a0a0b0;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.auth-modal-close:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* Modal Body */
.auth-modal-body {
    padding: 1.5rem;
}

/* Form Styles */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-form-group label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    font-weight: 500;
}

.auth-form-group input,
.auth-form-group select,
.auth-form-group textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.625rem 0.875rem;
    color: #fff;
    font-size: 0.875rem;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.auth-form-group input:focus,
.auth-form-group select:focus,
.auth-form-group textarea:focus {
    outline: none;
    border-color: rgba(79, 116, 229, 0.5);
    box-shadow: 0 0 0 2px rgba(79, 116, 229, 0.15);
    background: rgba(0, 0, 0, 0.4);
}

.auth-form-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Select/Dropdown Styling */
.auth-form-group 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='%23a0a0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.auth-form-group select option {
    background: #1a1a2e;
    color: #fff;
    padding: 0.5rem;
}

/* Checkbox styling */
.auth-form-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    accent-color: #4f74e5;
}

.auth-form-group label.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Error message */
.auth-form-error {
    color: #e74c3c;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
    padding: 0.5rem;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
}

.auth-form-error.visible {
    display: block;
}

/* Buttons */
.auth-btn {
    background: linear-gradient(135deg, #4f74e5 0%, #3d5dc9 100%);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-btn:hover {
    background: linear-gradient(135deg, #5b82f0 0%, #4668d0 100%);
    transform: translateY(-1px);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: none;
}

.auth-btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.auth-btn-danger:hover {
    background: linear-gradient(135deg, #ec5e4f 0%, #d14436 100%);
}

/* Button group */
.auth-btn-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.auth-btn-group .auth-btn {
    flex: 1;
}

/* Toggle between login/register */
.auth-toggle {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-toggle span {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
}

.auth-toggle a {
    color: #4f74e5;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.auth-toggle a:hover {
    color: #6b8ef0;
    text-decoration: underline;
}

/* =====================================================
   ACCOUNT DROPDOWN TOOLBAR BUTTON
   ===================================================== */

button.account-avatar-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    background: linear-gradient(135deg, #4f74e5 0%, #3b5cbd 100%);
    border: 2px solid rgba(79, 116, 229, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
    flex-shrink: 0;
    gap: 0;
}

button.account-avatar-btn:hover {
    background: linear-gradient(135deg, #5a82f0 0%, #4568d0 100%);
    border-color: var(--primary-blue);
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(79, 116, 229, 0.4);
}

button.account-avatar-btn.active {
    background: linear-gradient(135deg, #5a82f0 0%, #4568d0 100%);
    border-color: #fff;
    box-shadow: 0 0 12px rgba(79, 116, 229, 0.5);
}

#account-dropdown .dropdown-menu {
    right: 0;
    left: auto;
    min-width: 220px;
}

/* =====================================================
   USER INFO IN ACCOUNT DROPDOWN
   ===================================================== */

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0 -8px 8px -8px;
    padding-left: 24px;
}

.dropdown-user-info .user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4f74e5 0%, #3b5cbd 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.dropdown-user-info .user-info-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-user-info .user-name {
    color: #fff;
    font-weight: 500;
    font-size: 14px;
}

.dropdown-user-info .user-role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-transform: capitalize;
}

/* =====================================================
   ADMIN PANEL MODAL
   ===================================================== */

.admin-panel-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.admin-panel-modal.active {
    display: flex;
}

.admin-panel-content {
    background: linear-gradient(180deg, #1a1a2e 0%, #141422 100%);
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(79, 116, 229, 0.3);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset,
                0 0 60px rgba(79, 116, 229, 0.15);
    animation: authModalSlideIn 0.3s ease-out;
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(180deg, rgba(15, 15, 26, 0.95) 0%, rgba(15, 15, 26, 0.8) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-panel-header h2 {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-panel-header h2 i {
    color: #4f74e5;
}

/* Admin Panel Tabs */
.admin-panel-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-panel-tab {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    padding: 0.625rem 1rem;
    color: #808090;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-panel-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #a0a0b0;
}

.admin-panel-tab.active {
    background: rgba(79, 116, 229, 0.15);
    color: #fff;
}

.admin-panel-tab i {
    font-size: 0.8125rem;
}

/* Admin Panel Body */
.admin-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.admin-panel-body h3 {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
}

.admin-panel-body p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    margin: 0 0 1.25rem 0;
}

/* User List */
.user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.user-list-header h3 {
    margin: 0;
}

#user-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    transition: all 0.2s;
}

.user-item:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.12);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.user-name {
    color: #fff;
    font-weight: 500;
    font-size: 0.9375rem;
}

.user-email {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8125rem;
}

.user-role {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.6875rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.user-role.role-admin {
    background: rgba(79, 116, 229, 0.2);
    color: #6b8ef0;
}

.user-role.role-user {
    background: rgba(75, 192, 186, 0.2);
    color: #5dd3cc;
}

.user-status {
    font-size: 0.6875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
}

.user-status.active {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.user-status.inactive {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.user-actions button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    color: #808090;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.user-actions .btn-delete:hover {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

/* Permission Table */
.permission-matrix {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.permission-matrix th,
.permission-matrix td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.permission-matrix th {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.permission-matrix td {
    color: #fff;
    font-size: 0.875rem;
}

.permission-matrix tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #4f74e5;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* =====================================================
   USER CREATE/EDIT MODAL
   ===================================================== */

#user-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

#user-modal.active,
#user-modal[style*="flex"] {
    display: flex;
}

#user-modal .modal-content {
    background: linear-gradient(180deg, #1a1a2e 0%, #141422 100%);
    border-radius: 16px;
    width: 100%;
    max-width: 450px;
    border: 1px solid rgba(79, 116, 229, 0.3);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset,
                0 0 60px rgba(79, 116, 229, 0.15);
    animation: authModalSlideIn 0.3s ease-out;
    overflow: hidden;
}

#user-modal .modal-content h3 {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(180deg, rgba(15, 15, 26, 0.95) 0%, rgba(15, 15, 26, 0.8) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#user-modal #user-form {
    padding: 1.5rem;
}

#user-modal .auth-form-group {
    margin-bottom: 1rem;
}

#user-modal .auth-form-group:last-of-type {
    margin-bottom: 0;
}

/* Hidden elements */
[data-auth-hidden="true"] {
    display: none !important;
}

/* =====================================================
   RESPONSIVE ADJUSTMENTS
   ===================================================== */

@media (max-width: 600px) {
    .auth-modal-dialog {
        max-width: calc(100% - 2rem);
        margin: 1rem;
    }

    .auth-modal-body {
        padding: 1.25rem;
    }

    .admin-panel-content {
        width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
    }

    .admin-panel-body {
        padding: 1rem;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .user-item {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .user-actions {
        justify-content: flex-end;
    }
}
