/**
 * TBP Portal Dashboard Styles
 */

/* ========================================
   Design System Variables
   ======================================== */
:root {
    /* Brand Colors */
    --tbp-primary: #0B1521;
    --tbp-text: #011A29;
    --tbp-accent-1: #E73755;
    --tbp-accent-2: #5CD4D6;
    --tbp-white: #FFFFFF;
    --tbp-white-alt: #F9F9F9;

    /* Layout */
    --tbp-sidebar-width: 280px;
    --tbp-sidebar-collapsed-width: 70px;
    --tbp-topbar-height: 64px;

    /* Derived Colors */
    --tbp-border-color: #E5E7EB;
    --tbp-text-muted: #6B7280;
    --tbp-success: #10B981;
    --tbp-warning: #F59E0B;
    --tbp-error: #EF4444;

    /* Sidebar */
    --tbp-sidebar-bg: var(--tbp-primary);
    --tbp-sidebar-text: rgba(255, 255, 255, 0.7);
    --tbp-sidebar-hover: rgba(255, 255, 255, 0.1);
    --tbp-sidebar-active: var(--tbp-accent-1);

    /* Spacing */
    --tbp-space-xs: 4px;
    --tbp-space-sm: 8px;
    --tbp-space-md: 16px;
    --tbp-space-lg: 24px;
    --tbp-space-xl: 32px;

    /* Border Radius */
    --tbp-radius-sm: 4px;
    --tbp-radius-md: 8px;
    --tbp-radius-lg: 12px;
    --tbp-radius-full: 9999px;
}

/* ========================================
   Typography
   ======================================== */
body.tbp-portal-page {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset for portal pages */
body.tbp-portal-page {
    margin: 0;
    padding: 0;
    background: var(--tbp-white-alt);
    color: var(--tbp-text);
}

body.tbp-portal-page #page,
body.tbp-portal-page .site {
    max-width: none;
    padding: 0;
}

/* Portal Wrapper */
.tbp-portal-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.tbp-portal-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--tbp-sidebar-width);
    background: var(--tbp-sidebar-bg);
    color: var(--tbp-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s ease;
}

.tbp-portal-sidebar-collapsed .tbp-portal-sidebar {
    width: var(--tbp-sidebar-collapsed-width);
}

/* Sidebar Header */
.tbp-portal-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tbp-portal-logo {
    flex: 1;
    min-width: 0;
}

.tbp-portal-logo a {
    display: block;
}

.tbp-portal-logo img {
    max-width: 140px;
    height: auto;
    filter: brightness(0) invert(1);
}

.tbp-portal-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tbp-portal-sidebar-toggle {
    background: none;
    border: none;
    color: var(--tbp-sidebar-text);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.tbp-portal-sidebar-toggle:hover {
    background: var(--tbp-sidebar-hover);
}

.tbp-portal-sidebar-collapsed .tbp-portal-logo,
.tbp-portal-sidebar-collapsed .tbp-portal-user-info,
.tbp-portal-sidebar-collapsed .tbp-portal-menu span:not(.ti) {
    display: none;
}

.tbp-portal-sidebar-collapsed .tbp-portal-sidebar-user {
    justify-content: center;
    padding: 16px;
}

.tbp-portal-sidebar-collapsed .tbp-portal-sidebar-header {
    justify-content: center;
    padding: 16px;
}

/* Sidebar User */
.tbp-portal-sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tbp-portal-sidebar-user img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.tbp-portal-user-info {
    flex: 1;
    min-width: 0;
}

.tbp-portal-user-name {
    display: block;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tbp-portal-user-role {
    display: block;
    font-size: 12px;
    color: var(--tbp-sidebar-text);
}

/* Sidebar Menu */
.tbp-portal-sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.tbp-portal-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tbp-portal-menu li {
    margin: 0;
}

.tbp-portal-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--tbp-sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
}

.tbp-portal-menu a:hover {
    background: var(--tbp-sidebar-hover);
    color: #fff;
}

.tbp-portal-menu li.active > a,
.tbp-portal-menu li.current-menu-item > a {
    background: var(--tbp-sidebar-active);
    color: #fff;
}

/* Parent with active child - subtle highlight, not full accent */
.tbp-portal-menu li.has-submenu.active > a {
    background: rgba(255, 255, 255, 0.08);
}

.tbp-portal-menu .ti {
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

/* ========================================
   Sidebar Submenu Styles
   ======================================== */

/* Parent item with submenu */
.tbp-portal-menu li.has-submenu > a {
    justify-content: flex-start;
}

.tbp-portal-menu li.has-submenu > a .submenu-arrow {
    margin-left: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tbp-portal-menu li.has-submenu.is-expanded > a .submenu-arrow {
    transform: rotate(180deg);
}

/* Submenu container */
.tbp-portal-menu .submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.tbp-portal-menu li.has-submenu.is-expanded > .submenu {
    max-height: 500px;
    opacity: 1;
    padding: 4px 0;
}

/* Submenu items */
.tbp-portal-menu .submenu-item {
    margin: 0;
}

.tbp-portal-menu .submenu-item a {
    padding: 10px 20px 10px 52px;
    font-size: 14px;
    position: relative;
    transform: translateX(-8px);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.2s ease,
                color 0.2s ease;
}

.tbp-portal-menu li.has-submenu.is-expanded .submenu-item a {
    transform: translateX(0);
    opacity: 1;
}

/* Stagger animation for submenu items */
.tbp-portal-menu li.has-submenu.is-expanded .submenu-item:nth-child(1) a { transition-delay: 0.05s; }
.tbp-portal-menu li.has-submenu.is-expanded .submenu-item:nth-child(2) a { transition-delay: 0.1s; }
.tbp-portal-menu li.has-submenu.is-expanded .submenu-item:nth-child(3) a { transition-delay: 0.15s; }
.tbp-portal-menu li.has-submenu.is-expanded .submenu-item:nth-child(4) a { transition-delay: 0.2s; }
.tbp-portal-menu li.has-submenu.is-expanded .submenu-item:nth-child(5) a { transition-delay: 0.25s; }

/* Active submenu item */
.tbp-portal-menu .submenu-item.active a {
    background: rgba(231, 55, 85, 0.15);
    color: #fff;
}

.tbp-portal-menu .submenu-item.active a::before {
    content: '';
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--tbp-accent-1);
    border-radius: 50%;
}

/* Hover states */
.tbp-portal-menu .submenu-item a:hover {
    background: var(--tbp-sidebar-hover);
    color: #fff;
}

/* Collapsed sidebar - hide submenus */
.tbp-portal-sidebar-collapsed .tbp-portal-menu .submenu {
    display: none;
}

.tbp-portal-sidebar-collapsed .tbp-portal-menu .submenu-arrow {
    display: none;
}

/* Collapsed sidebar - center all menu items including those with submenus */
.tbp-portal-sidebar-collapsed .tbp-portal-menu li.has-submenu > a {
    justify-content: center;
}

/* Sidebar toggle icon */
.tbp-portal-sidebar-toggle .ti {
    font-size: 20px;
    line-height: 1;
}

/* Logout icon */
.tbp-portal-logout .ti {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.tbp-portal-sidebar-collapsed .tbp-portal-menu a {
    justify-content: center;
    padding: 12px;
}

/* Sidebar Footer */
.tbp-portal-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.tbp-portal-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--tbp-sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.tbp-portal-logout:hover {
    background: rgba(214, 54, 56, 0.2);
    color: #d63638;
}

.tbp-portal-sidebar-collapsed .tbp-portal-logout {
    justify-content: center;
}

.tbp-portal-sidebar-collapsed .tbp-portal-logout span:not(.ti) {
    display: none;
}

/* Main Content Area */
.tbp-portal-main {
    flex: 1;
    margin-left: var(--tbp-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.tbp-portal-sidebar-collapsed .tbp-portal-main {
    margin-left: var(--tbp-sidebar-collapsed-width);
}

/* Topbar */
.tbp-portal-topbar {
    position: sticky;
    top: 0;
    height: var(--tbp-topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--tbp-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 50;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tbp-portal-topbar.is-scrolled {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tbp-portal-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tbp-portal-mobile-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--tbp-text-color);
}

.tbp-portal-page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--tbp-text-color);
}

.tbp-portal-topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ========================================
   Live Search Component
   ======================================== */

.tbp-search {
    position: relative;
}

.tbp-search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--tbp-white-alt);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.tbp-search-trigger:hover {
    border-color: var(--tbp-text-muted);
    background: var(--tbp-white);
}

.tbp-search-trigger .ti-search {
    color: var(--tbp-text-muted);
    font-size: 16px;
}

.tbp-search-trigger-text {
    flex: 1;
    font-size: 14px;
    color: var(--tbp-text-muted);
    text-align: left;
}

.tbp-search-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: var(--tbp-white);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--tbp-text-muted);
}

/* Search Modal/Dropdown */
.tbp-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tbp-search-modal.is-active {
    opacity: 1;
    visibility: visible;
}

.tbp-search-container {
    width: 100%;
    max-width: 560px;
    background: var(--tbp-white);
    border-radius: var(--tbp-radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px) scale(0.95);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.tbp-search-modal.is-active .tbp-search-container {
    transform: translateY(0) scale(1);
}

.tbp-search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--tbp-border-color);
}

.tbp-search-header .ti-search {
    font-size: 20px;
    color: var(--tbp-text-muted);
}

.tbp-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    color: var(--tbp-text);
    background: transparent;
}

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

.tbp-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--tbp-white-alt);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-sm);
    cursor: pointer;
    color: var(--tbp-text-muted);
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.tbp-search-close:hover {
    background: var(--tbp-border-color);
    color: var(--tbp-text);
}

/* Search Results */
.tbp-search-results {
    max-height: 400px;
    overflow-y: auto;
}

.tbp-search-results:empty {
    display: none;
}

.tbp-search-section {
    padding: 8px 0;
}

.tbp-search-section:not(:last-child) {
    border-bottom: 1px solid var(--tbp-border-color);
}

.tbp-search-section-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tbp-text-muted);
}

.tbp-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tbp-search-item:hover,
.tbp-search-item.is-focused {
    background: var(--tbp-white-alt);
}

.tbp-search-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tbp-white-alt);
    border-radius: var(--tbp-radius-md);
    color: var(--tbp-text-muted);
    font-size: 18px;
    flex-shrink: 0;
}

.tbp-search-item-icon--user {
    background: rgba(92, 212, 214, 0.1);
    color: #3DBFC1;
}

.tbp-search-item-icon--page {
    background: rgba(231, 55, 85, 0.1);
    color: var(--tbp-accent-1);
}

.tbp-search-item-icon--doc {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
}

.tbp-search-item-content {
    flex: 1;
    min-width: 0;
}

.tbp-search-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--tbp-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tbp-search-item-title mark {
    background: rgba(92, 212, 214, 0.3);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

.tbp-search-item-meta {
    font-size: 12px;
    color: var(--tbp-text-muted);
    margin: 2px 0 0;
}

.tbp-search-item-arrow {
    color: var(--tbp-text-muted);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tbp-search-item:hover .tbp-search-item-arrow,
.tbp-search-item.is-focused .tbp-search-item-arrow {
    opacity: 1;
}

/* Search Footer */
.tbp-search-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--tbp-white-alt);
    border-top: 1px solid var(--tbp-border-color);
    font-size: 12px;
    color: var(--tbp-text-muted);
}

.tbp-search-footer-hints {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tbp-search-footer-hint {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tbp-search-footer-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    background: var(--tbp-white);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-sm);
    font-size: 11px;
    font-family: inherit;
}

/* Empty State */
.tbp-search-empty {
    padding: 40px 20px;
    text-align: center;
}

.tbp-search-empty-icon {
    font-size: 48px;
    color: var(--tbp-border-color);
    margin-bottom: 12px;
}

.tbp-search-empty-text {
    font-size: 14px;
    color: var(--tbp-text-muted);
    margin: 0;
}

/* Loading State */
.tbp-search-loading {
    padding: 30px 20px;
    text-align: center;
}

.tbp-search-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--tbp-border-color);
    border-top-color: var(--tbp-accent-2);
    border-radius: 50%;
    animation: tbp-spin 0.6s linear infinite;
    margin: 0 auto 12px;
}

.tbp-search-loading-text {
    font-size: 13px;
    color: var(--tbp-text-muted);
    margin: 0;
}

/* Responsive */
@media (max-width: 600px) {
    .tbp-search-trigger {
        min-width: auto;
        padding: 8px;
    }

    .tbp-search-trigger-text,
    .tbp-search-shortcut {
        display: none;
    }

    .tbp-search-modal {
        padding: 16px;
        padding-top: 80px;
    }

    .tbp-search-container {
        max-width: 100%;
    }
}

/* Topbar Notifications */
.tbp-portal-topbar-notifications {
    position: relative;
}

.tbp-portal-notifications-toggle {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--tbp-text-muted);
    position: relative;
}

.tbp-portal-notifications-toggle:hover {
    color: var(--tbp-text-color);
}

.tbp-portal-notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    background: #d63638;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Topbar User */
.tbp-portal-topbar-user {
    position: relative;
}

.tbp-portal-user-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
}

.tbp-portal-user-toggle img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.tbp-portal-user-toggle .ti {
    color: var(--tbp-text-muted);
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

.tbp-portal-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--tbp-border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 100;
}

.tbp-portal-user-dropdown.active {
    display: block;
}

.tbp-portal-user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--tbp-text-color);
    text-decoration: none;
    transition: background 0.2s;
}

.tbp-portal-user-dropdown a:hover {
    background: var(--tbp-bg-color);
}

.tbp-portal-user-dropdown a:first-child {
    border-radius: 8px 8px 0 0;
}

.tbp-portal-user-dropdown a:last-child {
    border-radius: 0 0 8px 8px;
}

.tbp-portal-user-dropdown hr {
    margin: 0;
    border: none;
    border-top: 1px solid var(--tbp-border-color);
}

.tbp-portal-user-dropdown .ti {
    color: var(--tbp-text-muted);
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
    flex-shrink: 0;
}

/* Topbar icons consistent sizing */
.tbp-portal-mobile-toggle .ti,
.tbp-portal-topbar-search button .ti,
.tbp-portal-notifications-toggle .ti {
    font-size: 20px;
    line-height: 1;
}

/* Main Content */
.tbp-portal-content {
    flex: 1;
    padding: 24px;
}

/* Dashboard Welcome */
.tbp-portal-welcome {
    background: var(--tbp-primary);
    color: var(--tbp-white);
    padding: var(--tbp-space-xl);
    border-radius: var(--tbp-radius-lg);
    margin-bottom: var(--tbp-space-lg);
}

.tbp-portal-welcome h2 {
    margin: 0 0 var(--tbp-space-sm);
    font-size: 28px;
    font-weight: 600;
}

.tbp-portal-welcome p {
    margin: 0;
    opacity: 0.8;
}

/* Coming Soon */
.tbp-portal-coming-soon {
    text-align: center;
    padding: 80px 40px;
    background: var(--tbp-white);
    border-radius: var(--tbp-radius-lg);
    border: 1px solid var(--tbp-border-color);
}

.tbp-portal-coming-soon .ti {
    display: block;
    font-size: 64px;
    color: var(--tbp-text-muted);
    margin: 0 auto 16px;
    line-height: 1;
}

.tbp-portal-coming-soon h2 {
    margin: 0 0 8px;
    color: var(--tbp-text);
}

.tbp-portal-coming-soon p {
    margin: 0;
    color: var(--tbp-text-muted);
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .tbp-portal-sidebar {
        transform: translateX(-100%);
    }

    .tbp-portal-sidebar.active {
        transform: translateX(0);
    }

    .tbp-portal-main {
        margin-left: 0;
    }

    .tbp-portal-mobile-toggle {
        display: block;
    }

    .tbp-portal-topbar-search input {
        width: 180px;
    }

    .tbp-portal-topbar-search input:focus {
        width: 200px;
    }
}

@media (max-width: 600px) {
    .tbp-portal-topbar {
        padding: 0 16px;
    }

    .tbp-portal-topbar-search {
        display: none;
    }

    .tbp-portal-content {
        padding: 16px;
    }

    .tbp-portal-welcome {
        padding: 24px;
    }

    .tbp-portal-welcome h2 {
        font-size: 22px;
    }
}

/* Mobile Overlay */
.tbp-portal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.tbp-portal-overlay.active {
    display: block;
}

/* ========================================
   Component System Styles
   ======================================== */

/* Icons */
.tbp-icon-sm { font-size: 16px; }
.tbp-icon-md { font-size: 20px; }
.tbp-icon-lg { font-size: 24px; }
.tbp-icon-xl { font-size: 32px; }

/* Buttons */
.tbp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tbp-space-sm);
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--tbp-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tbp-btn-sm { padding: 6px 12px; font-size: 13px; }
.tbp-btn-md { padding: 10px 18px; font-size: 14px; }
.tbp-btn-lg { padding: 14px 24px; font-size: 16px; }

.tbp-btn-primary {
    background: var(--tbp-accent-1);
    color: var(--tbp-white);
}
.tbp-btn-primary:hover {
    background: #D12E4A;
    transform: translateY(-1px);
}

.tbp-btn-secondary {
    background: var(--tbp-primary);
    color: var(--tbp-white);
}
.tbp-btn-secondary:hover {
    background: #1A2836;
}

.tbp-btn-accent {
    background: var(--tbp-accent-2);
    color: var(--tbp-primary);
}
.tbp-btn-accent:hover {
    background: #4BC5C7;
}

.tbp-btn-outline {
    background: transparent;
    border: 1px solid var(--tbp-border-color);
    color: var(--tbp-text);
}
.tbp-btn-outline:hover {
    background: var(--tbp-white-alt);
    border-color: var(--tbp-text-muted);
}

.tbp-btn-ghost {
    background: transparent;
    color: var(--tbp-text);
}
.tbp-btn-ghost:hover {
    background: var(--tbp-white-alt);
}

.tbp-btn-danger {
    background: var(--tbp-error);
    color: var(--tbp-white);
}
.tbp-btn-danger:hover {
    background: #DC2626;
}

.tbp-btn-full { width: 100%; }
.tbp-btn-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.tbp-btn-loading { position: relative; color: transparent; }
.tbp-btn-loading .tbp-btn-spinner {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: tbp-spin 0.6s linear infinite;
}
@keyframes tbp-spin {
    to { transform: rotate(360deg); }
}

/* Cards */
.tbp-card {
    background: var(--tbp-white);
    border-radius: var(--tbp-radius-lg);
    border: 1px solid var(--tbp-border-color);
    position: relative;
}

.tbp-card-no-padding { padding: 0; }
.tbp-card-hover { transition: transform 0.2s, box-shadow 0.2s; }
.tbp-card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.tbp-card-link { cursor: pointer; }
.tbp-card-link-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.tbp-card-header {
    display: flex;
    align-items: center;
    gap: var(--tbp-space-md);
    padding: var(--tbp-space-lg);
    border-bottom: 1px solid var(--tbp-border-color);
}

.tbp-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tbp-white-alt);
    border-radius: var(--tbp-radius-md);
    color: var(--tbp-accent-1);
}

.tbp-card-titles { flex: 1; min-width: 0; }
.tbp-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--tbp-text);
}
.tbp-card-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--tbp-text-muted);
}

.tbp-card-body { padding: var(--tbp-space-lg); }
.tbp-card-footer {
    padding: var(--tbp-space-md) var(--tbp-space-lg);
    border-top: 1px solid var(--tbp-border-color);
    background: var(--tbp-white-alt);
    border-radius: 0 0 var(--tbp-radius-lg) var(--tbp-radius-lg);
}

/* Alerts */
.tbp-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--tbp-space-md);
    padding: var(--tbp-space-md) var(--tbp-space-lg);
    border-radius: var(--tbp-radius-md);
    border-left: 4px solid;
}

.tbp-alert-icon { flex-shrink: 0; padding-top: 2px; }
.tbp-alert-content { flex: 1; }
.tbp-alert-title { display: block; margin-bottom: 4px; }
.tbp-alert-message { margin: 0; }
.tbp-alert-dismiss {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    opacity: 0.6;
}
.tbp-alert-dismiss:hover { opacity: 1; }

.tbp-alert-info {
    background: #EFF6FF;
    border-color: #3B82F6;
    color: #1E40AF;
}
.tbp-alert-success {
    background: #ECFDF5;
    border-color: var(--tbp-success);
    color: #065F46;
}
.tbp-alert-warning {
    background: #FFFBEB;
    border-color: var(--tbp-warning);
    color: #92400E;
}
.tbp-alert-error {
    background: #FEF2F2;
    border-color: var(--tbp-error);
    color: #991B1B;
}

/* Stats */
.tbp-stat {
    display: flex;
    align-items: center;
    gap: var(--tbp-space-md);
    padding: var(--tbp-space-lg);
    background: var(--tbp-white);
    border-radius: var(--tbp-radius-lg);
    border: 1px solid var(--tbp-border-color);
    position: relative;
}

.tbp-stat-link { cursor: pointer; transition: transform 0.2s; }
.tbp-stat-link:hover { transform: translateY(-2px); }
.tbp-stat-link-overlay { position: absolute; inset: 0; z-index: 1; }

.tbp-stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tbp-white-alt);
    border-radius: var(--tbp-radius-md);
    color: var(--tbp-accent-1);
    font-size: 24px;
}

.tbp-stat-content { flex: 1; }
.tbp-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--tbp-text);
    line-height: 1.2;
}
.tbp-stat-label {
    display: block;
    font-size: 13px;
    color: var(--tbp-text-muted);
}

.tbp-stat-change {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: var(--tbp-radius-sm);
}
.tbp-stat-change-positive {
    background: #ECFDF5;
    color: #059669;
}
.tbp-stat-change-negative {
    background: #FEF2F2;
    color: #DC2626;
}

/* Avatar */
.tbp-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--tbp-white-alt);
    color: var(--tbp-text-muted);
    overflow: hidden;
}
.tbp-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.tbp-avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.tbp-avatar-md { width: 48px; height: 48px; font-size: 16px; }
.tbp-avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.tbp-avatar-xl { width: 96px; height: 96px; font-size: 28px; }
.tbp-avatar-initials {
    font-weight: 600;
    color: var(--tbp-text);
}

/* Badge */
.tbp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    border-radius: var(--tbp-radius-full);
}
.tbp-badge-sm { padding: 2px 8px; font-size: 11px; }
.tbp-badge-md { padding: 4px 10px; font-size: 12px; }

.tbp-badge-default { background: var(--tbp-white-alt); color: var(--tbp-text-muted); }
.tbp-badge-primary { background: var(--tbp-primary); color: var(--tbp-white); }
.tbp-badge-accent { background: var(--tbp-accent-2); color: var(--tbp-primary); }
.tbp-badge-success { background: #ECFDF5; color: #059669; }
.tbp-badge-warning { background: #FFFBEB; color: #D97706; }
.tbp-badge-error { background: #FEF2F2; color: #DC2626; }

/* Empty State */
.tbp-empty-state {
    text-align: center;
    padding: var(--tbp-space-xl) var(--tbp-space-lg);
}
.tbp-empty-state-icon {
    color: var(--tbp-text-muted);
    margin-bottom: var(--tbp-space-md);
}
.tbp-empty-state-title {
    margin: 0 0 var(--tbp-space-sm);
    font-size: 18px;
    font-weight: 600;
    color: var(--tbp-text);
}
.tbp-empty-state-description {
    margin: 0 0 var(--tbp-space-lg);
    color: var(--tbp-text-muted);
}

/* Dashboard Grid */
.tbp-portal-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--tbp-space-lg);
}
