/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "DM Sans", sans-serif;
    background-color: var(--grey-100);
    font-style: normal;
    line-height: 1.5;
    color: var(--black);
    min-height: 100vh;
}

/* Auth Pages (Login, Forgot Password, Set Password) */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--ci-dark-gradient);
}

.auth-container {
    background: var(--white);
    padding: 48px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h2 {
    color: var(--black);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.auth-header .subtitle {
    color: var(--grey-700);
    font-size: 14px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--grey-800);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 12px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--grey-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--white);
    color: var(--black);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--ci-light);
    box-shadow: 0 0 0 3px rgba(39, 172, 227, 0.15);
}

.form-group input::placeholder {
    color: var(--grey-500);
}

.form-group input[readonly] {
    background-color: var(--grey-100);
    cursor: not-allowed;
    color: var(--grey-700);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--ci-dark);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--brand-dark-2);
}

.btn-secondary {
    background: var(--grey-200);
    color: var(--grey-800);
}

.btn-secondary:hover {
    background: var(--grey-300);
}

.btn-success {
    background: var(--accent-pos-dark);
    color: var(--white);
}

.btn-success:hover {
    filter: brightness(0.9);
}

.btn-danger {
    background: var(--accent-error);
    color: var(--white);
}

.btn-danger:hover {
    filter: brightness(0.9);
}

.btn-warning {
    background: var(--accent-warning);
    color: var(--white);
}

.btn-warning:hover {
    filter: brightness(0.9);
}

.btn-ghost {
    background: transparent;
    color: var(--grey-700);
    border: 1px solid var(--grey-300);
}

.btn-ghost:hover {
    background: var(--grey-100);
    border-color: var(--grey-400);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
}

.btn:disabled {
    background: var(--grey-200);
    color: var(--grey-500);
    cursor: not-allowed;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: var(--accent-error-bg);
    color: var(--accent-error);
}

.alert-success {
    background: var(--accent-success-bg);
    color: var(--accent-success);
}

.alert-info {
    background: var(--accent-info-bg);
    color: var(--accent-info);
}

.alert-warning {
    background: var(--accent-warning-bg);
    color: #92400E;
}

/* Links */
.link {
    color: var(--ci-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.link:hover {
    color: var(--ci-dark);
    text-decoration: underline;
}

.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.mt-24 {
    margin-top: 24px;
}

/* ============================================
   ADMIN PAGE STYLES
   ============================================ */

/* Topbar */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--grey-200);
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-brand h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--black);
}

.topbar-brand .logo {
    width: 32px;
    height: 32px;
    background: var(--ci-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--grey-100);
    border-radius: 8px;
}

.topbar-user-info {
    text-align: right;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
}

.topbar-user-email {
    font-size: 11px;
    color: var(--grey-600);
}

.topbar-nav a {
    color: var(--grey-700);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.topbar-nav a:hover {
    background: var(--grey-100);
    color: var(--black);
}

/* Admin Layout */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

/* Sidebar */
.admin-sidebar {
    width: 240px;
    background: var(--white);
    border-right: 1px solid var(--grey-200);
    padding: 24px 16px;
    flex-shrink: 0;
}

.sidebar-section {
    margin-bottom: 32px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--grey-500);
    margin-bottom: 12px;
    padding: 0 12px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--grey-700);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-nav-item:hover {
    background: var(--grey-100);
    color: var(--black);
}

.sidebar-nav-item.active {
    background: var(--ci-dark);
    color: var(--white);
}

.sidebar-nav-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* Retired nav entry: stays listed so the feature is still findable, but is
   inert and explains on hover where the setting lives now. The button keeps
   its default (focusable) state — `disabled` would swallow hover/focus and the
   hint would never appear — so it is neutralised via aria-disabled + no handler. */
.sidebar-nav-disabled {
    position: relative;
}

.sidebar-nav-item--disabled,
.sidebar-nav-item--disabled:hover {
    background: none;
    color: var(--grey-500);
    cursor: not-allowed;
}

.sidebar-nav-item--disabled .icon {
    filter: grayscale(1);
    opacity: 0.6;
}

.sidebar-nav-tooltip {
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    transform: translateY(-50%);
    z-index: 100;
    width: 250px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--grey-900);
    color: var(--white);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    box-shadow: 0 8px 24px rgba(17, 17, 17, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.sidebar-nav-tooltip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--grey-900);
}

.sidebar-nav-disabled:hover .sidebar-nav-tooltip,
.sidebar-nav-disabled:focus-within .sidebar-nav-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.admin-main {
    flex: 1;
    padding: 32px;
    background: var(--grey-100);
    overflow-y: auto;
}

.admin-content {
    max-width: 900px;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 4px;
}

.page-header p {
    font-size: 14px;
    color: var(--grey-600);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--grey-200);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--black);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--grey-200);
    background: var(--grey-100);
    border-radius: 0 0 12px 12px;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--grey-500);
}

.info-value {
    font-size: 14px;
    color: var(--black);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin: 2px 4px 2px 0;
}

.badge-primary {
    background: rgba(39, 172, 227, 0.15);
    color: var(--ci-dark);
}

.badge-success {
    background: var(--accent-pos-light);
    color: var(--accent-pos-dark);
}

.badge-warning {
    background: var(--accent-warning-bg);
    color: #92400E;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-bar select {
    padding: 10px 14px;
    border: 1px solid var(--grey-300);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    min-width: 140px;
}

.search-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--grey-300);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
}

.search-bar select:focus,
.search-bar input:focus {
    outline: none;
    border-color: var(--ci-light);
}

/* User List */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--grey-100);
    border-radius: 8px;
    transition: background 0.15s ease;
}

.user-list-item:hover {
    background: var(--grey-200);
}

.user-list-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-list-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--black);
}

.user-list-email {
    font-size: 12px;
    color: var(--grey-600);
}

.user-list-meta {
    font-size: 11px;
    color: var(--grey-500);
    margin-top: 4px;
}

.user-list-actions {
    display: flex;
    gap: 8px;
}

/* Permission List */
.permission-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.permission-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--grey-100);
    border-radius: 8px;
}

.permission-list-info {
    flex: 1;
}

.permission-list-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 2px;
}

.permission-list-desc {
    font-size: 12px;
    color: var(--grey-600);
}

/* Checkbox Permission Item */
.permission-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--grey-100);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.permission-checkbox:hover {
    background: var(--grey-200);
}

.permission-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--ci-dark);
}

.permission-checkbox-info {
    flex: 1;
}

.permission-checkbox-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 2px;
}

.permission-checkbox-desc {
    font-size: 12px;
    color: var(--grey-600);
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Notice Box */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
}

.notice-info {
    background: var(--accent-info-bg);
    color: var(--accent-info);
}

.notice-warning {
    background: var(--accent-warning-bg);
    color: #92400E;
}

.notice .icon {
    font-size: 16px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state .icon {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    color: var(--grey-500);
}

/* Section Tabs */
.section-content {
    display: none;
}

.section-content.active {
    display: block;
}

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--grey-200);
    margin: 24px 0;
}

/* Scrollable List */
.scrollable-list {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 8px;
}

.scrollable-list::-webkit-scrollbar {
    width: 6px;
}

.scrollable-list::-webkit-scrollbar-track {
    background: var(--grey-100);
    border-radius: 3px;
}

.scrollable-list::-webkit-scrollbar-thumb {
    background: var(--grey-300);
    border-radius: 3px;
}

.scrollable-list::-webkit-scrollbar-thumb:hover {
    background: var(--grey-400);
}

/* Readonly Notice */
.readonly-notice {
    display: none;
    font-size: 11px;
    color: var(--grey-500);
    margin-top: 4px;
}

.email-field-wrapper.edit-mode .readonly-notice {
    display: block;
}

/* Editing Indicator */
.editing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--accent-info-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--accent-info);
}

.editing-indicator strong {
    font-weight: 600;
}

/* Password Requirements */
.password-requirements {
    background: var(--grey-100);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.password-requirements h4 {
    color: var(--grey-800);
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.password-requirements ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
    color: var(--grey-700);
    font-size: 13px;
}

.password-requirements li {
    margin-bottom: 4px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    transition: color 0.15s ease;
}

/* Marker doubles as the state: bullet while untouched, tick once met.
   Fixed width so the label does not shift as the glyph changes. */
.password-requirements .req-mark {
    flex: 0 0 auto;
    width: 12px;
    text-align: center;
    color: var(--grey-500);
}

.password-requirements .req-mark::before {
    content: "•";
}

.password-requirements li.is-met {
    color: var(--accent-success);
}

.password-requirements li.is-met .req-mark {
    color: var(--accent-success);
}

.password-requirements li.is-met .req-mark::before {
    content: "✓";
}

/* Unmet is only ever shown once typing starts, so it reads as "still to do"
   rather than greeting everyone with a form full of errors. */
.password-requirements li.is-unmet {
    color: var(--grey-800);
}

.password-requirements li.is-unmet .req-mark::before {
    content: "○";
}

/* Email Display */
.email-display {
    background: var(--accent-info-bg);
    color: var(--accent-info);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    text-align: center;
    border: 1px solid var(--accent-info-border);
}

/* Responsive */
@media (max-width: 900px) {
    .admin-sidebar {
        display: none;
    }
    
    .admin-main {
        padding: 24px 16px;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 32px 24px;
    }

    .auth-header h2 {
        font-size: 20px;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .user-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .user-list-actions {
        width: 100%;
    }
    
    .user-list-actions .btn {
        flex: 1;
    }
}

/* Utility Classes */
.text-muted {
    color: var(--grey-500);
}

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.mb-16 {
    margin-bottom: 16px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Visually hidden */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
