/* ============================================================
   AccessDmRoomHub — Main Stylesheet
   Direction: RTL | Font: YekanBakh | Theme: Red
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    --primary: #ca2c24;
    --primary-light: #ca2c240d;
    --primary-dark: #a02018;
    --primary-accent: #e05850;

    --bg: #f8f8f8;
    --surface: #ffffff;
    --surface-2: #fafafa;

    --border: #e5e7eb;
    --border-focus: #e05850;

    --text: #1f2937;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --text-inverse: #ffffff;

    --success: #059669;
    --success-bg: #ecfdf5;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #ca2c24;
    --info-bg: #ca2c240d;

    --shadow-sm: 0 1px 3px rgba(202, 44, 36, 0.08);
    --shadow: 0 4px 16px rgba(202, 44, 36, 0.12);
    --shadow-lg: 0 8px 32px rgba(202, 44, 36, 0.16);

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --font: 'YekanBakh', sans-serif;

    --header-h: 60px;
    --sidebar-w: 220px;
    --transition: 0.2s ease;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    font-size: 14px;
    line-height: 1.7;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

ul,
ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 0.5rem;
    font-weight: 700;
    line-height: 1.3;
}

p {
    margin: 0 0 1rem;
}

/* ---------- Layout Grid ---------- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
        'header header'
        'sidebar content';
    min-height: 100vh;
}

/* ---------- Header ---------- */
.header {
    grid-area: header;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo:hover {
    text-decoration: none;
    color: var(--primary-dark);
}

.header-logo i {
    font-size: 20px;
}

.header-breadcrumb {
    font-size: 13px;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.header-breadcrumb span {
    color: var(--text-2);
}

.header-search {
    flex: 1;
    max-width: 400px;
    margin: 0 auto;
    position: relative;
    min-width: 0;
}

.header-search input {
    width: 100%;
    padding: 0.4375rem 2.5rem 0.4375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
    direction: rtl;
}

.header-search input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(202, 44, 36, 0.15);
}

.header-search .search-icon {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 13px;
    pointer-events: none;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 200;
    max-height: 360px;
    overflow-y: auto;
    display: none;
}

.search-dropdown.open {
    display: block;
}

.search-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    padding: 0.625rem 1rem 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13px;
}

.search-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.search-item i {
    width: 16px;
    text-align: center;
    color: var(--text-3);
    flex-shrink: 0;
}

.search-item:hover i {
    color: var(--primary-accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: auto;
}

.header-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition:
        background var(--transition),
        color var(--transition);
    font-size: 16px;
}

.header-icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.notif-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    min-width: 16px;
    height: 16px;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.notif-badge:empty,
.notif-badge[data-count='0'] {
    display: none;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    transition: background var(--transition);
}

.user-menu-trigger:hover {
    background: var(--primary-light);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
    display: none;
}

.user-menu-dropdown.open {
    display: block;
}

.user-menu-dropdown a,
.user-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--transition);
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.user-menu-dropdown hr {
    margin: 0.25rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* ---------- Sidebar ---------- */
.sidebar {
    grid-area: sidebar;
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.75rem 1.25rem 0.25rem;
}

.sidebar-nav {
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-2);
    text-decoration: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-left: 0.75rem;
    transition:
        background var(--transition),
        color var(--transition);
    font-size: 13.5px;
    position: relative;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    right: -0.75px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 999px 0 0 999px;
}

.nav-badge {
    margin-right: auto;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.25rem;
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-3);
}

/* ---------- Main Content ---------- */
.main-content {
    grid-area: content;
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 0;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.page-title i {
    color: var(--primary);
    font-size: 18px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--primary);
}

/* ---------- Stat Cards ---------- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: var(--primary-light);
    color: var(--primary);
}
.stat-icon.green {
    background: var(--success-bg);
    color: var(--success);
}
.stat-icon.yellow {
    background: var(--warning-bg);
    color: var(--warning);
}
.stat-icon.red {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 0.25rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition:
        background var(--transition),
        color var(--transition),
        border-color var(--transition),
        box-shadow var(--transition);
    border: none;
    font-family: var(--font);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
}

.btn:hover {
    text-decoration: none;
}

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

.btn i {
    font-size: 13px;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    color: var(--text-inverse);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-accent);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success);
}

.btn-success:hover:not(:disabled) {
    background: var(--success);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 13px;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 15px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius);
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 0.375rem;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
    direction: rtl;
    appearance: none;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(202, 44, 36, 0.15);
}

.form-control::placeholder {
    color: var(--text-3);
}

.form-control:disabled {
    background: var(--surface-2);
    color: var(--text-3);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-valid {
    border-color: var(--success);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    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='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.875rem center;
    padding-left: 2rem;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-hint {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 0.25rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    flex: 1;
    border-radius: var(--radius) 0 0 var(--radius);
}

.input-addon {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
}

.input-addon:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    gap: 0.25rem;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.4;
    font-family: var(--font);
    transition:
        filter var(--transition),
        opacity var(--transition);
}
button.badge:hover {
    filter: brightness(0.92);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}
.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}
.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}
.badge-info {
    background: var(--info-bg);
    color: var(--info);
}
.badge-neutral {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    background: var(--surface-2);
    white-space: nowrap;
}

.table thead tr th:first-child {
    border-radius: 0 var(--radius-lg) 0 0;
}

.table thead tr th:last-child {
    border-radius: var(--radius-lg) 0 0 0;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    justify-content: flex-end;
}

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 16px;
    transition:
        background var(--transition),
        color var(--transition);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ---------- Credential Cards ---------- */
.credential-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.25rem;
    transition:
        box-shadow var(--transition),
        border-color var(--transition);
}

.credential-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-accent);
}

.credential-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.credential-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.credential-title i {
    color: var(--primary);
    font-size: 14px;
}

.credential-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    padding: 0.375rem 0.625rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 13px;
}

.credential-field-label {
    font-size: 11px;
    color: var(--text-3);
    font-weight: 500;
    min-width: 70px;
    flex-shrink: 0;
}

.credential-field-value {
    flex: 1;
    color: var(--text-2);
    font-family: monospace;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: right;
}

.credential-field-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.credential-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* ---------- Project Cards ---------- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.project-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.25rem;
    transition:
        box-shadow var(--transition),
        border-color var(--transition);
    cursor: pointer;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-accent);
    text-decoration: none;
}

.project-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: var(--primary-light);
    color: var(--primary);
    flex-shrink: 0;
}

.project-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.project-desc {
    font-size: 13px;
    color: var(--text-3);
    line-height: 1.6;
    flex: 1;
}

.project-meta {
    display: flex;
    gap: 1rem;
    font-size: 12px;
    color: var(--text-3);
    align-items: center;
}

.project-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ---------- Alert Variants ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert i {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(5, 150, 105, 0.2);
}
.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(217, 119, 6, 0.2);
}
.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.2);
}
.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(124, 58, 237, 0.2);
}

/* ---------- Filter Bar ---------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* ---------- Tag Filter Chips ---------- */
.tag-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    line-height: 1.5;
}

.filter-bar .form-control {
    min-width: 160px;
    flex: 1;
}

/* ---------- OTP Inputs ---------- */
.otp-inputs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    direction: ltr;
}

.otp-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
    font-family: monospace;
}

.otp-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(202, 44, 36, 0.15);
}

.otp-input.filled {
    border-color: var(--primary-accent);
    background: var(--primary-light);
}

/* ---------- Color Picker ---------- */
.color-picker-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition:
        border-color var(--transition),
        transform var(--transition);
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary);
}

/* ---------- Dividers ---------- */
.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

/* ---------- Empty State ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    color: var(--text-3);
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 1rem;
    color: var(--primary-accent);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--text-2);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 1.25rem;
}

/* ---------- Utilities ---------- */
.d-flex {
    display: flex;
}
.align-center {
    align-items: center;
}
.justify-between {
    justify-content: space-between;
}
.gap-1 {
    gap: 0.25rem;
}
.gap-2 {
    gap: 0.5rem;
}
.gap-3 {
    gap: 0.75rem;
}
.gap-4 {
    gap: 1rem;
}
.mt-1 {
    margin-top: 0.25rem;
}
.mt-2 {
    margin-top: 0.5rem;
}
.mt-3 {
    margin-top: 0.75rem;
}
.mt-4 {
    margin-top: 1rem;
}
.mb-1 {
    margin-bottom: 0.25rem;
}
.mb-2 {
    margin-bottom: 0.5rem;
}
.mb-3 {
    margin-bottom: 0.75rem;
}
.mb-4 {
    margin-bottom: 1rem;
}
.mb-5 {
    margin-bottom: 1.5rem;
}
.text-sm {
    font-size: 13px;
}
.text-xs {
    font-size: 11px;
}
.text-muted {
    color: var(--text-3);
}
.text-primary {
    color: var(--primary);
}
.text-danger {
    color: var(--danger);
}
.text-success {
    color: var(--success);
}
.text-warning {
    color: var(--warning);
}
.fw-500 {
    font-weight: 500;
}
.fw-600 {
    font-weight: 600;
}
.fw-700 {
    font-weight: 700;
}
.w-100 {
    width: 100%;
}
.hidden {
    display: none !important;
}
.ltr {
    direction: ltr;
}
.rtl {
    direction: rtl;
}

/* ---------- Hamburger (mobile) ---------- */
.hamburger {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    font-size: 18px;
    border-radius: var(--radius);
}

.hamburger:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ---------- Category badge / group ---------- */
.category-group {
    margin-bottom: 2rem;
}

.category-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-group-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ---------- Password strength meter ---------- */
.strength-meter {
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    margin-top: 0.375rem;
}

.strength-bar {
    height: 100%;
    border-radius: 999px;
    transition:
        width 0.3s ease,
        background 0.3s ease;
    width: 0%;
}

/* ---------- Loading spinner ---------- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- IP address chips ---------- */
.ip-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    font-family: monospace;
    color: var(--text-2);
}

.ip-chip .remove-ip {
    color: var(--text-3);
    cursor: pointer;
    font-size: 10px;
    border: none;
    background: none;
    padding: 0;
    display: flex;
    align-items: center;
}

.ip-chip .remove-ip:hover {
    color: var(--danger);
}

/* ============================================================
   Responsive — Tablet (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 200px;
    }

    .main-content {
        padding: 1.25rem;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* two-col grids to single */
    [style*='grid-template-columns:1fr 1fr'],
    [style*='grid-template-columns: 1fr 1fr'] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================
   Responsive — Tablet narrow (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
    /* Report show sidebar a bit narrower so 1fr gets enough room */
    [style*='grid-template-columns:1fr 300px'],
    [style*='grid-template-columns: 1fr 300px'] {
        grid-template-columns: 1fr 240px !important;
    }
}

/* ============================================================
   Responsive — Mobile (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
    /* Layout */
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-h) 1fr;
        grid-template-areas:
            'header'
            'content';
    }

    /* Sidebar — slide-in drawer */
    .sidebar {
        position: fixed;
        top: var(--header-h);
        right: 0;
        height: calc(100vh - var(--header-h));
        z-index: 80;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-right: none;
        border-left: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .hamburger {
        display: flex;
    }

    /* Header */
    .header {
        padding: 0 1rem;
        gap: 0.625rem;
    }
    .header-search {
        display: none;
    }
    .header-breadcrumb {
        display: none;
    }
    .header-logo span {
        display: none;
    }

    /* Content */
    .main-content {
        padding: 1rem;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .page-header > div,
    .page-header > a,
    .page-header > button,
    .page-header > form {
        width: 100%;
    }
    .page-header > div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Stat cards */
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Filter bar */
    .filter-bar {
        flex-wrap: wrap;
        gap: 0.625rem;
    }
    .filter-bar .form-control,
    .filter-bar input,
    .filter-bar select {
        max-width: 100% !important;
        width: 100% !important;
        flex: 1 1 140px;
    }

    /* Tables */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-lg);
    }
    .table {
        min-width: 600px;
    }
    .table-actions {
        flex-wrap: nowrap;
    }

    /* Cards */
    .card {
        border-radius: var(--radius);
    }

    /* Card header stack on small screens */
    .card-header {
        flex-wrap: wrap;
        gap: 0.625rem;
    }

    /* Modals */
    .modal {
        min-width: unset;
        width: 95vw;
        max-width: 95vw;
        margin: 0 auto;
    }

    /* Forms */
    .form-row,
    [style*='display:grid'][style*='grid-template-columns'],
    [style*='display: grid'][style*='grid-template-columns'] {
        grid-template-columns: 1fr !important;
    }

    /* OTP */
    .otp-inputs {
        gap: 0.375rem;
    }
    .otp-input {
        width: 40px;
        height: 48px;
        font-size: 18px;
    }

    /* Two-col grids in user/project show */
    [style*='grid-template-columns:1fr 1fr'],
    [style*='grid-template-columns: 1fr 1fr'] {
        grid-template-columns: 1fr !important;
    }

    /* Project cards */
    .project-card {
        padding: 1rem;
    }

    /* Buttons in header */
    .page-header .btn {
        font-size: 13px;
    }

    /* Access matrix */
    .access-matrix {
        font-size: 12px;
    }
    .access-matrix th,
    .access-matrix td {
        padding: 0.5rem 0.375rem;
    }

    /* ── Touch targets — بزرگ‌تر کردن دکمه‌های آیکونی برای انگشت ── */
    .btn-icon.btn-sm {
        width: 36px;
        height: 36px;
    }

    /* ── User-menu dropdown — جلوگیری از overflow روی صفحه کوچک ── */
    .user-menu-dropdown {
        max-width: calc(100vw - 2rem);
    }

    /* ── Credential cards — field rows کمی فضای بیشتر ── */
    .credential-field {
        padding: 0.5rem 0;
    }
    .credential-field-label {
        width: 58px;
    }
}

/* ============================================================
   Responsive — Small Mobile (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    /* Stack page-header buttons vertically */
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* ── Touch targets — بزرگ‌تر روی صفحه‌های خیلی کوچک ── */
    .btn-icon.btn-sm {
        width: 40px;
        height: 40px;
    }

    /* ── Credential cards روی صفحه ۳۲۰px ── */
    .credential-field-label {
        width: 52px;
        font-size: 10px;
    }

    /* Shrink table further */
    .table {
        min-width: 480px;
        font-size: 12px;
    }
    .table th,
    .table td {
        padding: 0.5rem 0.625rem;
    }

    /* Full-width selects in filter */
    .filter-bar {
        flex-direction: column;
    }
    .filter-bar .form-control,
    .filter-bar input,
    .filter-bar select {
        width: 100% !important;
        max-width: 100% !important;
        flex: none;
    }

    /* Chart height reduction */
    #activity-chart,
    #user-activity-chart {
        min-height: 200px !important;
    }
}

[x-cloak] {
    display: none !important;
}

/* SweetAlert2 RTL */
.swal-rtl {
    direction: rtl;
    font-family: 'YekanBakh', sans-serif !important;
}
.swal-rtl .swal2-title {
    font-family: 'YekanBakh', sans-serif !important;
    font-size: 18px;
}
.swal-rtl .swal2-html-container {
    font-family: 'YekanBakh', sans-serif !important;
    font-size: 14px;
    color: var(--text-2);
}
.swal-rtl .swal2-actions {
    gap: 0.5rem;
}
.swal2-popup {
    border-radius: var(--radius-lg) !important;
}
