/* Rabta — global UI polish: toolbar, dropdowns, modals, empty states, progress */

/* ── Collapsible sidebar layout ── */
html[data-sidebar="collapsed"] .sidebar {
    width: 68px !important;
}

html[data-sidebar="expanded"] .sidebar {
    width: 296px !important;
}

.sidebar {
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-sidebar="expanded"] .tw-nav-label {
    opacity: 1 !important;
    max-width: none !important;
    flex: 1;
}

html[data-sidebar="collapsed"] .tw-sidebar-identity,
html[data-sidebar="collapsed"] .tw-nav-label {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    pointer-events: none;
    margin: 0;
    padding: 0;
    flex: 0;
}

html[data-sidebar="collapsed"] .tw-nav-divider {
    display: none;
}

html[data-sidebar="collapsed"] .tw-sidebar-header {
    padding: 1rem 0.45rem;
}

html[data-sidebar="collapsed"] .tw-brand-card {
    justify-content: center;
    padding: 0.55rem;
    gap: 0;
}

html[data-sidebar="collapsed"] .tw-sidebar-identity {
    display: none;
}

html[data-sidebar="collapsed"] .tw-brand-logo-frame {
    width: 46px;
    height: 46px;
    padding: 2px;
}

html[data-sidebar="collapsed"] .tw-brand-logo-frame .rabta-logo-svg,
html[data-sidebar="collapsed"] .tw-brand-logo-frame .tw-brand-logo-mark {
    width: 40px;
    height: 40px;
}

html[data-sidebar="collapsed"] .tw-nav-link,
html[data-sidebar="collapsed"] .tw-sidebar-logout {
    justify-content: center;
    padding: 0.5rem;
}

html[data-sidebar="collapsed"] .tw-nav-icon {
    width: 40px;
    height: 40px;
    margin-left: 0 !important;
}

html[data-sidebar="collapsed"] .tw-nav-link-active::before {
    height: 20px;
    left: 0;
}

html[data-sidebar="collapsed"] .tw-sidebar-edge-icon {
    transform: rotate(180deg);
}

html[data-sidebar="collapsed"] .tw-sidebar-edge-toggle {
    left: -13px;
}

/* Collapsed sidebar — allow floating tooltips outside nav */
html[data-sidebar="collapsed"] .tw-sidebar-nav {
    overflow: visible !important;
}

/* Legacy CSS tooltips disabled — JS floating tooltips used instead */
html[data-sidebar="collapsed"] .tw-nav-link[data-tooltip]::after,
html[data-sidebar="collapsed"] .tw-sidebar-logout[data-tooltip]::after {
    display: none !important;
}

/* Modern floating sidebar tooltip (SidebarTooltips.js) */
.tw-sidebar-floating-tip {
    position: fixed;
    z-index: 10000;
    padding: 0.5rem 0.9rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 229, 212, 0.2);
}

.tw-sidebar-floating-tip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1e293b;
}

.tw-sidebar-floating-tip.visible {
    opacity: 1;
    transform: translateX(0);
}

/* ── Modern top bar ── */
.tw-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 3.75rem;
    padding: 0.55rem 1.25rem;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(10, 117, 173, 0.1);
    box-shadow: 0 4px 20px rgba(10, 117, 173, 0.06);
    position: sticky;
    top: 0;
    z-index: 50;
}

.tw-topbar-welcome {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    flex: 1;
}

.tw-welcome-text {
    font-size: 0.88rem;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tw-welcome-sub {
    font-size: 0.75rem;
    color: #64748b;
}

.tw-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
}

.tw-topbar-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tw-topbar-divider {
    width: 1px;
    height: 28px;
    background: linear-gradient(180deg, transparent, rgba(10, 117, 173, 0.2), transparent);
}

.tw-top-toolbar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.rabta-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rabta-icon.small {
    width: 14px;
    height: 14px;
}

.tw-nav-icon .rabta-icon {
    width: 20px;
    height: 20px;
    color: #fff;
}

.tw-page-header .rabta-icon,
.row.text-white.rounded-lg .rabta-icon,
.tw-section-header .rabta-icon,
.tw-stat-icon .rabta-icon,
.tw-mini-stat-icon .rabta-icon {
    color: currentColor;
}

.tw-stat-icon .rabta-icon,
.tw-mini-stat-icon .rabta-icon {
    width: 22px;
    height: 22px;
}

.tw-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 38px;
    height: 38px;
    padding: 0 0.6rem;
    border: 1px solid rgba(10, 117, 173, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.75);
    color: #334155;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tw-toolbar-btn:hover {
    background: #fff;
    border-color: rgba(0, 229, 212, 0.4);
    color: #0a75ad;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(10, 117, 173, 0.14);
}

.tw-toolbar-btn:hover .rabta-icon {
    transform: scale(1.12);
}

.tw-toolbar-btn-theme:hover .rabta-icon {
    animation: rabta-icon-spin 0.55s ease;
}

@keyframes rabta-icon-spin {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(180deg) scale(1.12); }
}

.tw-lang-badge {
    font-size: 0.62rem;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    background: linear-gradient(135deg, #0a75ad, #00e5d4);
    color: #fff;
    font-weight: 700;
}

.tw-toolbar-btn-guide { color: #0a75ad; }
.tw-toolbar-btn-workflow { color: #65a30d; }
.tw-toolbar-btn-pages { color: #c2410c; }
.tw-toolbar-btn-api { color: #6d28d9; }
.tw-toolbar-btn-settings {
    color: #0a75ad;
    border-color: rgba(0, 229, 212, 0.28);
    background: linear-gradient(135deg, rgba(10, 117, 173, 0.08), rgba(0, 229, 212, 0.1));
    padding-inline: 0.75rem;
    min-width: auto;
}

.tw-toolbar-btn-settings:hover {
    background: linear-gradient(135deg, rgba(10, 117, 173, 0.14), rgba(0, 229, 212, 0.18));
    border-color: rgba(0, 229, 212, 0.5);
    color: #047857;
}

.tw-settings-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

@media (max-width: 1100px) {
    .tw-settings-label {
        display: none;
    }

    .tw-toolbar-btn-settings {
        min-width: 38px;
        padding-inline: 0.6rem;
    }
}
.tw-toolbar-btn-package { color: #0891b2; }
.tw-toolbar-btn-key { color: #2563eb; }
.tw-toolbar-btn-lang { color: #059669; }
.tw-toolbar-btn-logout { color: #dc2626; }

.tw-toolbar-btn .badge {
    font-size: 0.62rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: linear-gradient(135deg, #0a75ad, #00e5d4);
    color: #fff;
    font-weight: 700;
}

.tw-toolbar-btn-notify {
    position: relative;
}

.tw-toolbar-btn-notify.has-alerts {
    background: linear-gradient(135deg, #ef4444, #f97316);
    border-color: transparent;
    color: #fff;
    animation: pulse-glow 2s ease-in-out infinite;
}

.tw-toolbar-btn-notify .tw-notify-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #fff;
    color: #ef4444;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Notifications dropdown */
.tw-notifications-wrap {
    position: relative;
    display: inline-block;
}

.tw-notifications-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 320px;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid rgba(10, 117, 173, 0.12);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    z-index: 1050;
    overflow: hidden;
    animation: fadeInScale 0.25s ease-out;
}

.tw-notifications-header {
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, #0a1628, #0d2137);
    color: #f8fafc;
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tw-notifications-header .oi {
    color: #00e5d4;
}

.tw-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    transition: background 0.2s;
    text-decoration: none !important;
}

.tw-notification-item:hover {
    background: rgba(0, 229, 212, 0.06);
}

.tw-notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.tw-notification-icon.danger { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.tw-notification-icon.warning { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.tw-notification-icon.info { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }

.tw-notification-text {
    font-size: 0.82rem;
    color: #334155;
    line-height: 1.45;
}

.tw-notification-text strong {
    font-weight: 700;
}

/* ── Modals ── */
.blazored-modal-overlay {
    z-index: 3000 !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    background: rgba(3, 7, 18, 0.55) !important;
}

.bm-container {
    z-index: 3000 !important;
}

.blazored-modal {
    border-radius: 18px !important;
    border: 1px solid rgba(0, 229, 212, 0.15) !important;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35) !important;
    overflow: hidden;
    animation: fadeInScale 0.3s ease-out;
}

.tw-modal {
    padding: 1.5rem 1.75rem 1.25rem;
    text-align: center;
}

.tw-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
}

.tw-modal-icon.success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.tw-modal-icon.error { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.tw-modal-icon.info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.tw-modal-icon.warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.tw-modal-icon.question { background: rgba(99, 102, 241, 0.15); color: #6366f1; }

.tw-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.65rem;
}

.tw-modal-message {
    font-size: 0.95rem;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.tw-modal-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: center;
    flex-wrap: wrap;
}

.tw-modal-btn {
    min-width: 100px;
    padding: 0.55rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.25s;
}

.tw-modal-btn-primary {
    background: linear-gradient(135deg, #0a75ad, #00e5d4);
    color: #fff;
}

.tw-modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(10, 117, 173, 0.3);
}

.tw-modal-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.tw-modal-btn-danger:hover {
    background: #ef4444;
    color: #fff;
}

/* Empty states — see rabta-empty-states.css */

/* ── Dashboard progress & KPI rings ── */
.tw-mini-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.tw-mini-stat {
    background: var(--tw-card, #fff);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(10, 117, 173, 0.08);
    box-shadow: 0 4px 16px rgba(10, 117, 173, 0.06);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tw-mini-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.tw-mini-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.tw-mini-stat-label {
    font-size: 0.72rem;
    color: #64748b;
}

.tw-progress-panel {
    background: var(--tw-card, #fff);
    border-radius: var(--tw-radius, 16px);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(10, 117, 173, 0.08);
    box-shadow: var(--tw-shadow, 0 10px 40px rgba(10, 117, 173, 0.12));
}

.tw-progress-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tw-progress-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.85rem;
    align-items: center;
}

.tw-progress-item:last-child { margin-bottom: 0; }

.tw-progress-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    grid-column: 1;
}

.tw-progress-value {
    font-size: 0.82rem;
    font-weight: 700;
    color: #0a75ad;
    grid-column: 2;
    grid-row: 1;
}

.tw-progress-track {
    grid-column: 1 / -1;
    height: 10px;
    background: rgba(10, 117, 173, 0.08);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}

.tw-progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #0a75ad, #00e5d4);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tw-progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: shimmer 2s infinite;
    background-size: 200% 100%;
}

.tw-progress-fill.alt-1 { background: linear-gradient(90deg, #6366f1, #a78bfa); }
.tw-progress-fill.alt-2 { background: linear-gradient(90deg, #10b981, #34d399); }
.tw-progress-fill.alt-3 { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.tw-progress-fill.alt-4 { background: linear-gradient(90deg, #ef4444, #f87171); }
.tw-progress-fill.alt-5 { background: linear-gradient(90deg, #0891b2, #22d3ee); }

/* Circular KPI rings */
.tw-kpi-rings-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tw-kpi-ring {
    background: var(--tw-card, #fff);
    border-radius: 14px;
    padding: 1rem;
    text-align: center;
    border: 1px solid rgba(10, 117, 173, 0.08);
    box-shadow: 0 4px 16px rgba(10, 117, 173, 0.06);
}

.tw-kpi-ring-svg {
    width: 90px;
    height: 90px;
    margin: 0 auto 0.5rem;
    transform: rotate(-90deg);
}

.tw-kpi-ring-bg {
    fill: none;
    stroke: rgba(10, 117, 173, 0.1);
    stroke-width: 8;
}

.tw-kpi-ring-fg {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.tw-kpi-ring-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e293b;
}

.tw-kpi-ring-label {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 0.15rem;
}

/* Dark theme overrides */
html[data-app-theme="dark"] .tw-toolbar-btn {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(0, 229, 212, 0.12);
    color: #e2e8f0;
}

html[data-app-theme="dark"] .tw-toolbar-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    color: #00e5d4;
}

html[data-app-theme="dark"] .tw-notifications-dropdown {
    background: #0f172a;
    border-color: rgba(0, 229, 212, 0.15);
}

html[data-app-theme="dark"] .tw-notification-text { color: #cbd5e1; }
html[data-app-theme="dark"] .tw-notification-item:hover { background: rgba(0, 229, 212, 0.08); }

html[data-app-theme="dark"] .tw-modal-message { color: #94a3b8; }
html[data-app-theme="dark"] .tw-progress-panel,
html[data-app-theme="dark"] .tw-mini-stat,
html[data-app-theme="dark"] .tw-kpi-ring {
    background: #1e293b;
    border-color: rgba(0, 229, 212, 0.1);
}

html[data-app-theme="dark"] .tw-progress-panel-title,
html[data-app-theme="dark"] .tw-mini-stat-value,
html[data-app-theme="dark"] .tw-kpi-ring-value { color: #f1f5f9; }

html[data-app-theme="dark"] .tw-progress-label { color: #94a3b8; }

html[data-app-theme="dark"] .tw-topbar {
    background: rgba(10, 21, 37, 0.94) !important;
    border-bottom-color: rgba(0, 229, 212, 0.12) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

html[data-app-theme="dark"] .tw-welcome-text { color: #e2e8f0 !important; }
html[data-app-theme="dark"] .tw-welcome-sub { color: #94a3b8 !important; }
html[data-app-theme="dark"] .tw-topbar-divider {
    background: linear-gradient(180deg, transparent, rgba(0, 229, 212, 0.25), transparent);
}

/* ── Toasts ── */
.blazored-toast {
    border-radius: 12px !important;
    border: 1px solid rgba(10, 117, 173, 0.12) !important;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15) !important;
    font-family: inherit;
}

.success-toast-override .blazored-toast-icon,
.info-toast-override .blazored-toast-icon,
.warning-toast-override .blazored-toast-icon,
.error-toast-override .blazored-toast-icon {
    border-radius: 10px;
}

html[data-app-theme="dark"] .blazored-toast {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: rgba(0, 229, 212, 0.15) !important;
}

/* Partner / entity avatars */
img[src*="rabta-supplier-icon"],
img[src*="rabta-retailer-icon"] {
    object-fit: cover;
    border: 2px solid rgba(0, 229, 212, 0.2);
    box-shadow: 0 4px 12px rgba(10, 117, 173, 0.15);
}
