/*
  Advanced Layout Components - Professional ISP CRM
  Sidebar, Topbar, and Dashboard Enhancements
  Version: 2.0
*/

/* ====================================
   ADVANCED SIDEBAR
==================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 50%, #0b1020 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .sidebar-header h4,
.sidebar.collapsed .sidebar-header small,
.sidebar.collapsed .nav-link span:not(.badge),
.sidebar.collapsed .nav-link .ms-auto {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0;
}

.sidebar.collapsed .collapse {
    display: none !important;
}

.sidebar.collapsed .nav-link[data-bs-toggle="collapse"]::after {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Sidebar Header */
.sidebar-header {
    padding: 24px 20px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(99, 102, 241, 0.08);
    backdrop-filter: blur(10px);
}

.sidebar-header h4 {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header small {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Navigation Items */
.sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-left-color: rgba(99, 102, 241, 0.5);
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.18) 0%, rgba(99, 102, 241, 0.08) 100%);
    color: #ffffff;
    border-left-color: #6366f1;
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    margin-right: 12px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .nav-link:hover i {
    transform: scale(1.1);
}

/* Collapsible Menu Items */
.sidebar .nav-link[data-bs-toggle="collapse"] {
    position: relative;
    cursor: pointer;
}

.sidebar .nav-link[data-bs-toggle="collapse"]::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

.sidebar .nav-link[data-bs-toggle="collapse"].collapsed::after {
    transform: rotate(0deg);
}

.sidebar .nav-link[data-bs-toggle="collapse"]:not(.collapsed)::after {
    transform: rotate(180deg);
}

.sidebar .collapse {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .collapse.show {
    max-height: 1500px;
}

.sidebar .collapse .nav-link {
    padding-left: 52px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.70);
}

.sidebar .collapse .nav-link:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.06);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-footer .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
    flex-shrink: 0;
}

.sidebar-footer .user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .user-name {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer .user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    display: block;
}

/* ====================================
   ADVANCED TOPBAR
==================================== */

.topbar {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 2px 12px rgba(2, 6, 23, 0.06);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1030;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed ~ .topbar {
    left: 70px;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 70px;
}

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

.topbar-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 10px;
    color: #6366f1;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-toggle:hover {
    background: rgba(99, 102, 241, 0.15);
    transform: scale(1.05);
}

.topbar-toggle:active {
    transform: scale(0.98);
}

/* Enhanced Search Bar */
.topbar-search {
    position: relative;
    width: 420px;
    max-width: 100%;
}

.topbar-search-input {
    width: 100%;
    height: 44px;
    padding: 0 45px 0 45px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    color: #0f172a;
    transition: all 0.25s ease;
}

.topbar-search-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: #ffffff;
}

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

.topbar-search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 16px;
    pointer-events: none;
}

.topbar-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    border-radius: 8px;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-search-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Topbar Right Actions */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: nowrap;
}

.topbar-right > * {
    margin: 0;
    flex-shrink: 0;
}

.topbar-action-btn {
    position: relative;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: none;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 12px;
    color: #6366f1;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.topbar-action-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.topbar-action-btn.success {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
}

.topbar-action-btn.success:hover {
    background: rgba(16, 185, 129, 0.15);
}

.topbar-action-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.88);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Enhanced Notification Dropdown */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 380px;
    max-height: 480px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(2, 6, 23, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-dropdown.active {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(124, 58, 237, 0.05) 100%);
}

.notification-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.notification-header .mark-all-read {
    font-size: 13px;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    transition: color 0.25s ease;
}

.notification-header .mark-all-read:hover {
    color: #4f46e5;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
}

.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.2);
    border-radius: 10px;
}

.notification-item {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: background 0.25s ease;
    cursor: pointer;
}

.notification-item:hover {
    background: rgba(99, 102, 241, 0.04);
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.06);
}

.notification-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #ffffff;
    flex-shrink: 0;
}

.notification-icon.primary {
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
}

.notification-icon.success {
    background: linear-gradient(135deg, #10b981 0%, #22c55e 100%);
}

.notification-icon.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

.notification-icon.info {
    background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.notification-text {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 6px 0;
    line-height: 1.5;
}

.notification-time {
    font-size: 12px;
    color: #94a3b8;
}

.notification-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    text-align: center;
}

.notification-footer a {
    font-size: 14px;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    transition: color 0.25s ease;
}

.notification-footer a:hover {
    color: #4f46e5;
}

/* User Profile Dropdown */
.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.25s ease;
    margin: 0;
    flex-shrink: 0;
    white-space: nowrap;
    height: 44px;
}

.user-profile-btn:hover {
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.user-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #ffffff;
}

.user-profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-profile-name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
}

.user-profile-role {
    font-size: 12px;
    color: #64748b;
    line-height: 1.2;
}

/* ====================================
   MAIN CONTENT AREA
==================================== */

.main-content {
    margin-left: 280px;
    margin-top: 70px;
    padding: 32px;
    min-height: calc(100vh - 70px);
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================================
   RESPONSIVE DESIGN
==================================== */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .topbar {
        left: 0;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .topbar-search {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 16px;
    }
    
    .topbar-search {
        display: none;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .notification-dropdown {
        width: 320px;
        right: -12px;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 16px;
    }
    
    .topbar-right {
        gap: 8px;
    }
    
    .topbar-action-btn {
        width: 40px;
        height: 40px;
    }
    
    .notification-dropdown {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
        max-height: calc(100vh - 70px);
    }
}

/* ====================================
   UTILITY CLASSES
==================================== */

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.online-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

/* ====================================
   ENHANCED DASHBOARD CARDS
==================================== */

.dashboard-card-advanced {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.06);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.dashboard-card-advanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1 0%, #7c3aed 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dashboard-card-advanced:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.12);
}

.dashboard-card-advanced:hover::before {
    opacity: 1;
}

.card-header-advanced {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title-advanced {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-advanced i {
    font-size: 20px;
    color: #6366f1;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 8px;
    color: #6366f1;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.card-action-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    transform: scale(1.1);
}

