/**
 * Novish Studio Sales CRM
 * Custom Reusable Components Stylesheet (components.css)
 */

/* ==========================================================================
   1. Sidebar Styles
   ========================================================================== */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--bg-alt);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition-smooth);
}

/* Sidebar Top Controls Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem 0.5rem;
}

.sidebar-search-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-alt);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.sidebar-search-btn:hover {
    background: var(--border-color);
}

.sidebar-user-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00bcd4;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
}

/* Sidebar Section Headers */
.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 1rem 1rem 0.25rem;
    margin: 0;
}

.role-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--accent);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid var(--border-color);
}

.sidebar-menu {
    list-style: none;
    padding: 0.5rem 0.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Custom premium scrollbar for sidebar menu */
.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}
.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    color: var(--text-secondary);
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.sidebar-menu li a:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.sidebar-menu li.active a {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    font-weight: 600;
}

body.dark-mode .sidebar-menu li.active a {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* Menu icons styles */
.menu-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.sidebar-menu li a:hover .menu-icon,
.sidebar-menu li.active a .menu-icon {
    color: var(--accent);
}

.sidebar-menu li.logout-item {
    margin-top: auto;
}

/* ==========================================================================
   2. Navbar Styles
   ========================================================================== */
.navbar {
    height: 75px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.navbar-title h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 500;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Notification Bell Dropdown */
.notification-bell-container {
    position: relative;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.notification-bell-container:hover {
    background: var(--bg-alt);
    border-color: var(--border-color);
}

.bell-icon {
    font-size: 1.15rem;
}

.bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent);
    color: var(--bg);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
}

/* Notifications Dropdown Card */
.notifications-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    width: 340px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    display: none;
    flex-direction: column;
    z-index: 110;
    overflow: hidden;
}

.notifications-dropdown.active {
    display: flex;
    animation: slide-down 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-alt);
}

.notif-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
}

.notif-header button {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.75rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
}

.notif-list {
    max-height: 320px;
    overflow-y: auto;
}

.notif-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.notif-item:hover {
    background: var(--bg-alt);
}

.notif-item.unread {
    background: rgba(110, 13, 13, 0.02);
    border-left: 3px solid var(--accent);
}

.notif-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-body {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.notif-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.5rem;
}

.notif-empty {
    padding: 2.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border-radius: 6px;
    border: 1px solid transparent;
}

.user-profile-widget:hover {
    background: var(--bg-alt);
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.user-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--border-color);
    display: block;
}

.user-avatar-initials {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1.5px solid var(--border-color);
    font-family: var(--font-heading);
}

@media (max-width: 768px) {
    .user-profile-widget {
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }
    .user-profile-widget .user-name,
    .user-profile-widget .arrow-icon {
        display: none !important;
    }
}

/* ==========================================================================
   2b. Table Component Styles
   ========================================================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.crm-table thead th {
    background: var(--bg-alt);
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.crm-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}

.crm-table tbody tr:hover {
    background: rgba(110, 13, 13, 0.02);
}

.crm-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   3. Toast Notifications
   ========================================================================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast-item {
    min-width: 300px;
    max-width: 420px;
    padding: 1.15rem;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 40px rgba(110, 13, 13, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slide-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.toast-item.success { border-left: 4px solid var(--status-success); }
.toast-item.error { border-left: 4px solid var(--status-error); }
.toast-item.warning { border-left: 4px solid var(--status-warning); }
.toast-item.info { border-left: 4px solid var(--status-info); }

.toast-message {
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
}

.toast-close {
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-secondary);
    line-height: 1;
}

.toast-item.fade-out {
    animation: fade-out 0.3s forwards;
}

/* ==========================================================================
   4. Wind Speeder Preloader (from animation.md guidelines)
   ========================================================================== */
body.loading {
    overflow: hidden;
}

.preloader-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: var(--bg);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    overflow: hidden;
}

.preloader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-text {
    position: absolute;
    top: calc(50% + 60px);
    left: 0;
    width: 100%;
    text-align: center;
    font-family: var(--font-heading);
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    animation: preloader-pulse 1.8s ease-in-out infinite;
}

@keyframes preloader-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Speeder silhouette shaking */
.preloader-overlay .loader {
    position: absolute;
    top: 50%; left: 50%;
    margin-left: -50px;
    animation: speeder 0.4s linear infinite;
}

.preloader-overlay .loader > span {
    height: 5px; width: 35px;
    background: var(--accent);
    position: absolute;
    top: -19px; left: 60px;
    border-radius: 2px 10px 1px 0;
}

.preloader-overlay .base span {
    position: absolute;
    width: 0; height: 0;
    border-top: 6px solid transparent;
    border-right: 100px solid var(--accent);
    border-bottom: 6px solid transparent;
}

.preloader-overlay .base span:before {
    content: "";
    height: 22px; width: 22px;
    border-radius: 50%;
    background: var(--accent);
    position: absolute;
    right: -110px; top: -16px;
}

.preloader-overlay .base span:after {
    content: "";
    position: absolute;
    width: 0; height: 0;
    border-top: 0 solid transparent;
    border-right: 55px solid var(--accent);
    border-bottom: 16px solid transparent;
    top: -16px; right: -98px;
}

.preloader-overlay .face {
    position: absolute;
    height: 12px; width: 20px;
    background: var(--accent);
    border-radius: 20px 20px 0 0;
    transform: rotate(-40deg);
    right: -125px; top: -15px;
}

.preloader-overlay .face:after {
    content: "";
    height: 12px; width: 12px;
    background: var(--accent);
    right: 4px; top: 7px;
    position: absolute;
    transform: rotate(40deg);
    transform-origin: 50% 50%;
    border-radius: 0 0 0 2px;
}

/* Micro dust particle lines inside speeder */
.preloader-overlay .loader > span > span:nth-child(1),
.preloader-overlay .loader > span > span:nth-child(2),
.preloader-overlay .loader > span > span:nth-child(3),
.preloader-overlay .loader > span > span:nth-child(4) {
    width: 30px; height: 1px;
    background: var(--accent);
    position: absolute;
    animation: fazer1 0.2s linear infinite;
}
.preloader-overlay .loader > span > span:nth-child(2) { top: 3px; animation: fazer2 0.4s linear infinite; }
.preloader-overlay .loader > span > span:nth-child(3) { top: 1px; animation: fazer3 0.4s linear infinite; animation-delay: -1s; }
.preloader-overlay .loader > span > span:nth-child(4) { top: 4px; animation: fazer4 1s linear infinite; animation-delay: -1s; }

/* Background long streaks passing by */
.preloader-overlay .longfazers {
    position: absolute;
    width: 100%; height: 100%;
}
.preloader-overlay .longfazers span {
    position: absolute;
    height: 2px; width: 20%;
    background: var(--accent);
    opacity: 0.15;
}
.preloader-overlay .longfazers span:nth-child(1) { top: 20%; animation: lf 0.6s linear infinite; animation-delay: -5s; }
.preloader-overlay .longfazers span:nth-child(2) { top: 40%; animation: lf2 0.8s linear infinite; animation-delay: -1s; }
.preloader-overlay .longfazers span:nth-child(3) { top: 60%; animation: lf3 0.6s linear infinite; }
.preloader-overlay .longfazers span:nth-child(4) { top: 80%; animation: lf4 0.5s linear infinite; animation-delay: -3s; }

/* ==========================================================================
   5. Top Progress Loader
   ========================================================================== */
.top-progress {
    position: fixed; 
    top: 0; left: 0; 
    z-index: 200;
    height: 3px; 
    width: 0%;
    background-color: var(--accent);
    opacity: 0; 
    pointer-events: none;
    box-shadow: 0 0 12px rgba(110, 13, 13, 0.55);
    transition: width 0.32s ease, opacity 0.38s ease;
}

/* ==========================================================================
   Keyframes & Animations
   ========================================================================== */
@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fade-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

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

@keyframes speeder {
    0% { transform: translate(2px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -3px) rotate(-1deg); }
    20% { transform: translate(-2px, 0px) rotate(1deg); }
    30% { transform: translate(1px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 3px) rotate(-1deg); }
    60% { transform: translate(-1px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-2px, -1px) rotate(1deg); }
    90% { transform: translate(2px, 1px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

@keyframes fazer1 { 0% { left: 0; } 100% { left: -80px; opacity: 0; } }
@keyframes fazer2 { 0% { left: 0; } 100% { left: -100px; opacity: 0; } }
@keyframes fazer3 { 0% { left: 0; } 100% { left: -50px; opacity: 0; } }
@keyframes fazer4 { 0% { left: 0; } 100% { left: -150px; opacity: 0; } }

@keyframes lf { 0% { left: 200%; } 100% { left: -200%; opacity: 0; } }
@keyframes lf2 { 0% { left: 200%; } 100% { left: -200%; opacity: 0; } }
@keyframes lf3 { 0% { left: 200%; } 100% { left: -100%; opacity: 0; } }
@keyframes lf4 { 0% { left: 200%; } 100% { left: -100%; opacity: 0; } }

/* ==========================================================================
   Additional Layout Alignments & Clean-ups (Emoji-free & Inline-free)
   ========================================================================== */
.notification-bell-container {
    display: flex;
    align-items: center;
}

.bell-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 18px;
    color: var(--text-primary);
}

.user-avatar-icon {
    display: flex;
    align-items: center;
    color: var(--accent);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   4. Modal Component Styles
   ========================================================================== */
crm-modal {
    display: block;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(110, 13, 13, 0.15);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-appear 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-card.sm { width: 400px; }
.modal-card.md { width: 600px; }
.modal-card.lg { width: 850px; }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--accent);
}

.modal-body {
    padding: 1.5rem;
}

@keyframes modal-appear {
    from { transform: scale(0.96) translateY(8px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    .modal-card {
        width: 95% !important;
        max-height: 95vh;
    }
}

/* ==========================================================================
   Mobile Sidebar Toggle & Responsiveness overrides
   ========================================================================== */
.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin-right: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.menu-toggle-btn:hover {
    background-color: var(--bg-alt);
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
    }

    .menu-toggle-btn {
        display: flex;
    }
}

/* ==========================================================================
   Responsive Profile Section Utilities
   ========================================================================== */
@media (min-width: 1025px) {
    .desktop-hide-profile {
        display: none !important;
    }
}
@media (max-width: 1024px) {
    .mobile-hide-profile {
        display: none !important;
    }
}

/* Hide Settings menu item for interns on mobile devices */
@media (max-width: 768px) {
    .intern-settings-item {
        display: none;
    }
}