/* ==========================================
   Design System - Premium Core Components
   ========================================== */

/* Modern scrollbars for all pages */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--background-color);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--border-radius-pill);
    transition: var(--transition-fast);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

body {
    background-color: var(--background-color);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    transition: var(--transition-normal);
    overflow-x: hidden;
}

/* Premium Card Layout with Glassmorphism */
.auth-card {
    background-color: var(--card-background);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border) !important;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium);
    transition: var(--transition-normal);
    animation: slideUpAndFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Inputs & Form Controls */
.form-control-custom {
    background-color: var(--card-background);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 0.92rem;
    transition: var(--transition-fast);
}

.form-control-custom:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 4px var(--input-focus-shadow);
    background-color: var(--card-background) !important;
    color: var(--text-primary) !important;
    outline: none;
}

/* Premium Dynamic Button with Gradients */
.btn-primary-custom {
    background: var(--primary-gradient);
    color: #ffffff !important;
    border: none;
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.2);
    transition: var(--transition-fast);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.3);
    filter: brightness(1.05);
}

.btn-primary-custom:active {
    transform: translateY(0);
}

/* Toggle Tabs for Roles */
.role-tabs {
    display: flex;
    background-color: var(--background-color);
    padding: 4px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.role-tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.role-tab-btn.active {
    background-color: var(--card-background);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Theme Toggle Button */
.theme-toggle-trigger {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-pill);
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.theme-toggle-trigger:hover {
    transform: scale(1.1) rotate(15deg);
    color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

/* Floating Theme Toggle */
.theme-toggle-float {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-premium);
    color: var(--text-secondary);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, color 0.2s ease;
    cursor: pointer;
}
.theme-toggle-float:hover {
    transform: scale(1.15) rotate(15deg) !important;
    color: var(--primary-color);
    box-shadow: var(--shadow-premium), 0 10px 20px rgba(99, 102, 241, 0.15) !important;
}

/* Page Animations */
@keyframes slideUpAndFade {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-element {
    animation: slideUpAndFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ==========================================
   User Dashboard Layout & Sidebar Styles
   ========================================== */

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

.dashboard-sidebar {
    width: 270px;
    background-color: var(--card-background);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.75rem;
    transition: var(--transition-normal);
}

.dashboard-main {
    flex: 1;
    margin-left: 270px;
    padding: 2.5rem;
    background-color: var(--background-color);
    transition: var(--transition-normal);
    min-width: 0;
}

/* Sidebar Branding & Text Gradients */
.sidebar-brand {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 2.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none !important;
}

.sidebar-brand span {
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.1rem;
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: var(--transition-fast);
}

.sidebar-menu-link i {
    font-size: 1.1rem;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.sidebar-menu-link:hover {
    background-color: var(--input-focus-shadow);
    color: var(--primary-color);
}

.sidebar-menu-link:hover i {
    transform: translateY(-2px) scale(1.15);
    color: var(--primary-color);
}

.sidebar-menu-link.active {
    background: var(--primary-gradient);
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.2);
}

.sidebar-menu-link.active i {
    color: #ffffff !important;
}

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

/* ==========================================
   Modernized Dashboard Metric Cards
   ========================================== */

.widget-card {
    background-color: var(--card-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border) !important;
    border-radius: var(--border-radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--input-focus-border) !important;
}

.widget-card .widget-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.widget-card .widget-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-primary);
}

.widget-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background-color: var(--input-focus-shadow);
    color: var(--primary-color);
    transition: var(--transition-fast);
}

.widget-card:hover .widget-icon-wrapper {
    background: var(--primary-gradient);
    color: #ffffff;
}

/* Recent Activity Timeline Styling */
.timeline-list {
    position: relative;
    padding-left: 1.5rem;
    list-style: none;
    margin: 0;
}

.timeline-list::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 4px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

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

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 2.5px solid var(--card-background);
    box-shadow: 0 0 0 3px var(--input-focus-shadow);
}

/* Responsive sidebar controls */
.sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 1100;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

@media (max-width: 991.98px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
    }
    .dashboard-sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-premium);
    }
    .dashboard-main {
        margin-left: 0;
        padding-top: 5.5rem;
    }
    .sidebar-toggle-btn {
        display: flex;
    }
}

/* Premium Empty State Layout */
.empty-state-card {
    background-color: var(--card-background) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--shadow-sm);
    padding: 4rem 2rem !important;
    transition: var(--transition-normal);
}
.empty-state-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--input-focus-border) !important;
}
.empty-state-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--input-focus-shadow);
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.08);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, color 0.2s ease;
    margin: 0 auto 1.5rem auto;
}
.empty-state-card:hover .empty-state-icon-wrapper {
    transform: scale(1.1) rotate(-8deg);
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.25);
}

/* ==========================================
   Global Theme overrides & compatibility
   ========================================== */

.text-primary {
    color: var(--text-primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.form-label, label {
    color: var(--text-primary) !important;
    font-weight: 500;
}

.form-text, .text-muted.small, .form-text span {
    color: var(--text-muted) !important;
}

.modal-content {
    background-color: var(--card-background) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border) !important;
    box-shadow: var(--shadow-premium) !important;
}

.modal-header, .modal-footer {
    border-color: var(--border-color) !important;
    background: transparent;
}

.modal-title {
    color: var(--text-primary) !important;
    font-weight: 700;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1) brightness(2) !important;
}

.form-select.form-control-custom {
    background-color: var(--card-background);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

[data-theme="dark"] .form-select.form-control-custom {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

.card {
    background-color: var(--card-background) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

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

.quick-reply-row input {
    background-color: var(--card-background);
    color: var(--text-primary);
}

.form-control-custom:focus, .form-select.form-control-custom:focus {
    background-color: var(--card-background) !important;
    color: var(--text-primary) !important;
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.8 !important;
}

/* Modern responsive table stylings */
.table {
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table th {
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    font-weight: 600;
}

.table td {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .table {
    background-color: var(--card-background) !important;
}

[data-theme="dark"] .table th, [data-theme="dark"] .table td {
    background-color: var(--card-background) !important;
}

.table-hover tbody tr {
    transition: var(--transition-fast);
}

.table-hover tbody tr:hover td {
    background-color: var(--input-focus-shadow) !important;
    color: var(--text-primary) !important;
}

/* Custom Input Group Styles */
.input-group-custom {
    display: flex;
    align-items: stretch;
    border-radius: var(--border-radius-md);
    width: 100%;
}

.input-group-custom .input-group-text {
    background-color: var(--card-background) !important;
    border: 1.5px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    display: flex;
    align-items: center;
    transition: var(--transition-fast);
}

.input-group-custom .btn {
    border: 1.5px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    background-color: var(--card-background) !important;
    transition: var(--transition-fast);
}

.input-group-custom .btn:hover {
    color: var(--primary-color) !important;
    background-color: var(--input-focus-shadow) !important;
    border-color: var(--input-focus-border) !important;
}

.input-group-custom .input-group-text + .form-control-custom {
    border-left: none !important;
}

.input-group-custom .form-control-custom + .btn {
    border-left: none !important;
}

.input-group-custom:focus-within .input-group-text,
.input-group-custom:focus-within .btn {
    border-color: var(--input-focus-border) !important;
}

/* Rounding helpers for custom inputs inside input groups */
.input-group-custom > .form-control-custom:not(:last-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group-custom > .form-control-custom:not(:first-child) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.input-group-custom > .btn:last-child {
    border-top-right-radius: var(--border-radius-md) !important;
    border-bottom-right-radius: var(--border-radius-md) !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.input-group-custom > .input-group-text:first-child {
    border-top-left-radius: var(--border-radius-md) !important;
    border-bottom-left-radius: var(--border-radius-md) !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group-custom i.bi-search {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .input-group-custom i.bi-search {
    color: var(--text-primary) !important;
}

/* Additional high-contrast dark mode overrides for Bootstrap elements */
[data-theme="dark"] .bg-light {
    background-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .badge.bg-light {
    background-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .table-light {
    --bs-table-color: var(--text-primary) !important;
    --bs-table-bg: var(--border-color) !important;
    background-color: var(--border-color) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .bg-primary-subtle {
    background-color: rgba(99, 102, 241, 0.15) !important;
    color: var(--primary-color) !important;
}
[data-theme="dark"] .text-primary {
    color: var(--primary-color) !important;
}
[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: var(--success-color) !important;
}
[data-theme="dark"] .bg-info-subtle {
    background-color: rgba(6, 182, 212, 0.15) !important;
    color: var(--info-color) !important;
}
[data-theme="dark"] .bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: var(--warning-color) !important;
}
[data-theme="dark"] .bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: var(--danger-color) !important;
}
[data-theme="dark"] .bg-secondary-subtle {
    background-color: rgba(100, 116, 139, 0.15) !important;
    color: var(--secondary-color) !important;
}
[data-theme="dark"] .text-muted {
    color: var(--text-secondary) !important;
}

