/* ═══════════ CARDS & STATS ═══════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    transition: var(--transition);
    overflow: hidden
}

.card:hover {
    border-color: var(--border-light)
}

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

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600
}

.card-body {
    padding: 20px
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition)
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: var(--transition)
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
    box-shadow: var(--shadow-md)
}

.stat-card:hover::before {
    opacity: 1
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 14px
}

.stat-card .stat-icon.blue {
    background: var(--accent-glow);
    color: var(--accent-light)
}

.stat-card .stat-icon.green {
    background: var(--success-bg);
    color: var(--success)
}

.stat-card .stat-icon.yellow {
    background: var(--warning-bg);
    color: var(--warning)
}

.stat-card .stat-icon.red {
    background: var(--danger-bg);
    color: var(--danger)
}

.stat-card .stat-icon.cyan {
    background: var(--info-bg);
    color: var(--info)
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500
}

/* ═══════════ BUTTONS ═══════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3)
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px)
}

.btn-success {
    background: var(--success);
    color: #fff
}

.btn-success:hover {
    opacity: 0.9
}

.btn-danger {
    background: var(--danger);
    color: #fff
}

.btn-danger:hover {
    opacity: 0.9
}

.btn-warning {
    background: var(--warning);
    color: #000
}

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-color)
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary)
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem
}

/* ═══════════ FORMS ═══════════ */
.form-group {
    margin-bottom: 18px
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px
}

body[dir="rtl"] .form-label {
    text-align: right
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgb(35, 0, 44)
}

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

select.form-control {
    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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px
}

body[dir="rtl"] select.form-control {
    background-position: left 12px center;
    padding-right: 14px;
    padding-left: 32px
}

body[dir="rtl"] .form-control {
    text-align: right
}

/* ═══════════ TABLES ═══════════ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color)
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap
}

body[dir="rtl"] .data-table th {
    text-align: right
}

body[dir="rtl"] .data-table td {
    text-align: right
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle
}

.data-table tr:hover td {
    background: var(--bg-glass);
    color: var(--text-primary)
}

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

/* ═══════════ BADGES ═══════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap
}

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

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger)
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning)
}

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

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success)
}

.status-dot.offline {
    background: var(--text-muted)
}

/* ═══════════ MODAL ═══════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition)
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: var(--transition)
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0)
}

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

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition)
}

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

.modal-body {
    padding: 24px
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px
}

body[dir="rtl"] .modal-footer {
    justify-content: flex-start;
    flex-direction: row-reverse
}

/* ═══════════ TOAST ═══════════ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px
}

body[dir="rtl"] .toast-container {
    right: auto;
    left: 24px
}

.toast {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease
}

.toast.success {
    border-left: 3px solid var(--success)
}

.toast.error {
    border-left: 3px solid var(--danger)
}

body[dir="rtl"] .toast.success {
    border-left: none;
    border-right: 3px solid var(--success)
}

body[dir="rtl"] .toast.error {
    border-left: none;
    border-right: 3px solid var(--danger)
}

body[dir="rtl"] .toast {
    animation: slideInLeft 0.3s ease
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0
    }

    to {
        transform: translateX(0);
        opacity: 1
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0
    }

    to {
        transform: translateX(0);
        opacity: 1
    }
}

/* ═══════════ SPINNER ═══════════ */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite
}

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

/* ═══════════ LOGIN ═══════════ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden
}

.login-page::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15), transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
    animation: float 6s ease-in-out infinite
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 70%);
    bottom: -100px;
    left: -100px;
    border-radius: 50%;
    animation: float 8s ease-in-out infinite reverse
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0)
    }

    50% {
        transform: translate(20px, -20px)
    }
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg)
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 32px
}

.login-card .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3)
}

.login-card .login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.login-card .login-logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px
}

.login-card .form-control {
    padding: 12px 16px;
    font-size: 0.95rem
}

.login-card .btn-primary {
    width: 100%;
    padding: 13px;
    font-size: 0.95rem;
    margin-top: 8px
}

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    margin-bottom: 16px;
    display: none
}

.login-error.show {
    display: block
}

/* ═══════════ SEARCH BAR ═══════════ */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 20px
}

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    font-family: inherit
}

.search-bar input::placeholder {
    color: var(--text-muted)
}

body[dir="rtl"] .search-bar {
    flex-direction: row-reverse
}

body[dir="rtl"] .search-bar input {
    text-align: right;
    direction: rtl
}

/* ═══════════ TOGGLE ═══════════ */
.toggle {
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: var(--transition)
}

.toggle.active {
    background: var(--accent)
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition)
}

.toggle.active::after {
    left: 23px
}

body[dir="rtl"] .toggle::after {
    left: auto;
    right: 3px
}

body[dir="rtl"] .toggle.active::after {
    right: 23px
}

/* ═══════════ DOCS PAGE ═══════════ */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px
}

.doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden
}

.doc-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition)
}

.doc-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md)
}

.doc-card:hover::before {
    opacity: 1
}

.doc-card .doc-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 16px
}

.doc-card h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px
}

.doc-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5
}

.doc-section {
    margin-bottom: 32px
}

.doc-section h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color)
}

.doc-code {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--accent-light);
    overflow-x: auto;
    margin: 8px 0
}

body[dir="rtl"] .doc-code {
    direction: ltr;
    text-align: left
}

.doc-step {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color)
}

.doc-step:last-child {
    border-bottom: none
}

.doc-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0
}

.doc-step-content h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px
}

.doc-step-content p {
    font-size: 0.82rem;
    color: var(--text-muted)
}

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

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px
}

.flex {
    display: flex
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center
}

body[dir="rtl"] .flex {
    flex-direction: row
}

.gap-8 {
    gap: 8px
}

.gap-16 {
    gap: 16px
}

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

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

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

.mb-24 {
    margin-bottom: 24px
}

.text-center {
    text-align: center
}

.text-muted {
    color: var(--text-muted)
}

.text-sm {
    font-size: 0.8rem
}

/* ═══════════ EMPTY STATE ═══════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted)
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5
}

.empty-state h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px
}

.empty-state p {
    font-size: 0.85rem
}