:root {
    /* Bright, professional, corporate color palette - refined to be softer */
    --primary: #2563eb; /* Softer, modern Blue */
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --bg-main: #f8fafc; /* Very light slate for main background */
    --bg-surface: #ffffff; /* Pure white for cards/surfaces */
    
    --text-main: #1e293b; /* Softer dark for main text */
    --text-muted: #64748b; /* Slate 500 */
    
    --border-color: #e2e8f0; /* Soft border */
    
    /* Status Colors */
    --status-good: #10b981; /* Emerald */
    --status-warning: #f59e0b; /* Amber */
    --status-danger: #ef4444; /* Red */
    --status-info: #3b82f6; /* Blue */
    
    /* Shadows for depth */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 340px; /* Increased width to accommodate complex menu */
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    margin-left: -340px; /* Slide to the left completely */
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
    font-size: 24px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

/* Tenant Switcher */
.tenant-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 20px;
    padding: 10px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
}

.tenant-switcher:hover {
    border-color: #cbd5e1;
    background-color: #f1f5f9;
}

.tenant-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tenant-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.tenant-details {
    display: flex;
    flex-direction: column;
}

.tenant-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.tenant-plan {
    font-size: 11px;
    color: var(--text-muted);
}

.tenant-selector-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Sidebar Complex Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav-accordion {
    margin-bottom: 2px;
}

.nav-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background-color: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.nav-accordion-header svg {
    width: 18px;
    height: 18px;
}

.nav-accordion-content {
    padding: 12px 16px;
    display: none;
}

.nav-accordion.active .nav-accordion-content {
    display: block;
}

.nav-accordion.active .nav-accordion-header {
    background-color: transparent;
    color: var(--primary);
}

.nav-complex-item {
    display: flex;
    gap: 12px;
    padding: 16px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    transition: background-color 0.2s;
    align-items: flex-start;
}

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

.nav-complex-item .item-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

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

.item-title {
    font-weight: 600;
    font-size: 14px;
}

.item-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Sub-links grid inside complex item */
.sub-links-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-top: 12px;
    padding-left: 32px;
}

.sub-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.sub-link:hover {
    text-decoration: underline;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-main);
}

.nav-item.active {
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: 21px;
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Top Header */
.top-header {
    height: 72px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border-radius: 8px;
    padding: 8px 16px;
    width: 400px;
    border: 1px solid var(--border-color);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    padding-left: 8px;
    font-family: inherit;
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--status-danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Dashboard Content */
.dashboard-content {
    padding: 32px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-muted);
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

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

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.kpi-title {
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.kpi-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* Status Utilities */
.status-good { color: var(--status-good); }
.status-warning { color: var(--status-warning); }
.status-danger { color: var(--status-danger); }
.status-info { color: var(--status-info); }

/* Widgets Grid */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.widget-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

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

.widget-title {
    font-size: 16px;
    font-weight: 600;
}

.view-all {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.widget-body {
    padding: 24px;
}

/* Update List */
.update-list, .task-list {
    list-style: none;
}

.update-item {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.update-item:last-child {
    margin-bottom: 0;
}

.update-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}
.update-indicator.status-warning { background-color: var(--status-warning); }
.update-indicator.status-info { background-color: var(--status-info); }
.update-indicator.status-good { background-color: var(--status-good); }

.update-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.update-content p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.update-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Task List */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bg-main);
}

.task-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.task-item input[type="checkbox"] {
    margin-top: 4px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.task-item label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.task-name {
    font-size: 14px;
    font-weight: 500;
}

.badge-danger { background-color: var(--status-danger); }
.badge-warning { background-color: var(--status-warning); color: #fff; }
.badge-info { background-color: var(--status-info); }

.task-item label .badge {
    position: static;
    display: inline-block;
    width: fit-content;
}

/* Task New Layouts */
.task-header-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-assignee {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.avatar-sm {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

/* Super Admin UI Styles */
.super-admin-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 8px 12px;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.table-filters select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-main);
    background-color: var(--bg-main);
    outline: none;
}

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

.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-main);
}

.data-table tbody tr:hover {
    background-color: var(--bg-main);
}

.tenant-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.good { background-color: var(--status-good); }
.status-dot.warning { background-color: var(--status-warning); }
.status-dot.danger { background-color: var(--status-danger); }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    margin-right: 4px;
}
.icon-btn:hover {
    background-color: var(--border-color);
    color: var(--primary);
}
.icon-btn.danger:hover {
    color: var(--status-danger);
    background-color: #fee2e2;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Auth & Registration Forms */
.auth-body {
    background-color: #f1f5f9;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
}

.auth-container {
    background-color: var(--bg-surface);
    width: 100%;
    max-width: 680px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 40px;
    border: 1px solid var(--border-color);
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-main);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
}

.auth-logo .logo-icon {
    color: var(--text-muted);
}

.auth-logo .logo-text {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    line-height: 1.1;
}

.auth-form .form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background-color: white;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-input::placeholder {
    color: #94a3b8;
}

/* Subdomain Group */
.subdomain-group {
    display: flex;
    gap: 12px;
}

.subdomain-input {
    flex: 1;
}

.subdomain-suffix {
    flex: 1;
    background-color: var(--bg-main);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border-color);
}

/* Select Wrapper */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    cursor: pointer;
    color: #94a3b8;
}
.select-wrapper select:valid, .select-wrapper select option {
    color: var(--text-main);
}

.select-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* AI Assistant */
.ai-assistant-widget {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 100;
}

.ai-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary);
    border: none;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.ai-fab:hover {
    transform: scale(1.05);
}

.fab-icon {
    font-size: 28px;
}

.ai-chatbox {
    display: none;
    width: 360px;
    height: 500px;
    background-color: var(--bg-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    flex-direction: column;
    overflow: hidden;
}

.ai-chatbox.active {
    display: flex;
}

.ai-chat-header {
    padding: 16px 20px;
    background-color: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-title h4 {
    font-size: 15px;
    font-weight: 600;
}

.ai-chat-title p {
    font-size: 11px;
    opacity: 0.8;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-main);
}

.message {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    max-width: 85%;
    line-height: 1.5;
}

.ai-message {
    background-color: white;
    border: 1px solid var(--border-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user-message {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-input {
    padding: 16px;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.ai-chat-input input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 16px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
}

.ai-chat-input input:focus {
    border-color: var(--primary);
}

.send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
