﻿/* ============================================
   SaaS Dashboard CSS - Modern Design
   ============================================ */

:root {
    /* Color Palette */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    /* Sidebar Colors */
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #4f46e5;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    /* Navbar */
    --navbar-height: 64px;
    --navbar-bg: #ffffff;
    /* Body */
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Reset & Base */
/* Global reset removed to prevent conflict with Bootstrap */

/* Body styles tailored to work WITH Bootstrap */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
}

/* ============================================
   Layout Structure
   ============================================ */

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.content-wrapper {
    flex: 1;
    padding: 24px;
    margin-top: var(--navbar-height);
}

/* ============================================
   Sidebar Styles
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    transition: width var(--transition-normal);
    overflow-x: hidden;
    overflow-y: auto;
    /* Enable vertical scrolling */
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: var(--border-color) transparent;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header / Logo */
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    height: var(--navbar-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.sidebar-logo:hover {
    color: var(--primary-color) !important;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 20px;
    font-weight: 700;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.sidebar-collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide scrollbar for Firefox */
    scrollbar-width: none;
    /* Hide scrollbar for IE and Edge */
    -ms-overflow-style: none;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sidebar-text);
    padding: 8px 12px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.sidebar-collapsed .nav-section-title {
    opacity: 0;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background: #475569;
    color: var(--sidebar-text-active);
}

.nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link-text {
    flex: 1;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.sidebar-collapsed .nav-link-text {
    opacity: 0;
    width: 0;
}

/* Nav Badge */
.nav-badge {
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    transition: opacity var(--transition-normal);
}

.sidebar-collapsed .nav-badge {
    opacity: 0;
}

/* Submenu */
.nav-submenu {
    display: none;
    padding-left: 36px;
    margin-top: 4px;
}

.nav-item.open .nav-submenu {
    display: block;
}

.nav-submenu .nav-link {
    padding: 8px 16px;
    font-size: 14px;
}

.nav-link .submenu-arrow {
    transition: transform var(--transition-fast);
}

.nav-item.open .submenu-arrow {
    transform: rotate(90deg);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--sidebar-hover);
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.sidebar-collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Navbar Styles
   ============================================ */

.navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--navbar-height);
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 999;
    transition: left var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.sidebar-collapsed .navbar {
    left: var(--sidebar-collapsed-width);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--body-bg);
    color: var(--text-primary);
}

.navbar-search {
    position: relative;
    width: 300px;
}

.navbar-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--body-bg);
    transition: all var(--transition-fast);
}

.navbar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.navbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    position: relative;
    transition: all var(--transition-fast);
}

.navbar-icon-btn:hover {
    background: var(--body-bg);
    color: var(--text-primary);
}

.navbar-icon-btn .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    margin-left: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.navbar-user:hover {
    background: var(--body-bg);
}

.navbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.navbar-user-info {
    text-align: left;
}

.navbar-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.navbar-user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Breadcrumb Styles
   ============================================ */

.breadcrumb-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 24px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 0px !important;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.breadcrumb-item:hover {
    background: var(--body-bg);
    color: var(--text-primary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
    cursor: default;
}

.breadcrumb-item i {
    font-size: 16px;
}

.breadcrumb-separator {
    font-size: 12px;
    color: var(--border-color);
}

/* ============================================
   Page Title
   ============================================ */

.page-title-main {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    margin-top: 0;
}

/* ============================================
   Card Styles
   ============================================ */

/* Card Customization - Safe Override */
.card {
    background-color: var(--card-bg);
    /* Explicit background */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    /* Custom radius */
    box-shadow: var(--shadow-sm);
    /* Custom shadow */
    margin-bottom: 24px;
    /* separation */
}

.card:hover {
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-normal);
}

.card-header {
    background-color: transparent;
    /* Remove default bootstrap grey */
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 24px;
}

/* ============================================
   Stats Cards
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.stat-icon.success {
    background: #d1fae5;
    color: var(--success-color);
}

.stat-icon.warning {
    background: #fef3c7;
    color: var(--warning-color);
}

.stat-icon.info {
    background: #dbeafe;
    color: var(--info-color);
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-change {
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* ============================================
   Page Header
   ============================================ */

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.page-header-actions {
    display: flex;
    gap: 12px;
}

/* ============================================
   Buttons
   ============================================ */

/* Button Customization - Safe Override */
/* We target standard bootstrap classes to apply our theme */
.btn {
    font-weight: 500;
    border-radius: 8px !important;
    /* Force custom radius */
    padding: 10px 20px;
    /* Custom padding */
    transition: all var(--transition-fast);
}

/* Add icons spacing */
.btn i {
    margin-right: 2px;
}

/* Custom Colors mapping to Bootstrap classes */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background-color: white;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--body-bg);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ============================================
   Tables
   ============================================ */

/* Table Customization */
.table th {
    font-size: 10px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background-color: var(--body-bg);
    border-bottom-width: 1px;
    padding: 14px 16px;
    border-top: none;
    /* Remove top border if present */
}

.table td {
    padding: 14px 16px;
    vertical-align: middle;
    color: var(--text-primary);
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

/* Hide dropdown arrow when needed */
.dropdown-toggle.no-arrow::after {
    display: none !important;
}

.table-hover tbody tr:hover {
    background-color: var(--primary-light) !important;
    /* Slight highlight */
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.info {
    background: #dbeafe;
    color: #1e40af;
}

/* ============================================
   HTMX Loading States
   ============================================ */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}

.htmx-request.htmx-indicator {
    display: inline-flex;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Content Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    .navbar-search {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: min(280px, 80vw) !important;
        /* Cap width at 280px or 80% of screen */
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        height: 100dvh;
        /* Use dynamic viewport height for mobile browsers */
        padding-bottom: 20px;
        /* Space at bottom for safe area */
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Override collapsed state on mobile */
    .sidebar-collapsed .sidebar {
        width: min(280px, 80vw) !important;
    }

    .main-content {
        margin-left: 0;
    }

    .navbar {
        left: 0;
    }

    .navbar-search {
        display: none;
    }

    .navbar-user-info {
        display: none;
    }

    /* Hide Quick Add button text on mobile */
    .btn-primary span {
        display: none;
    }

    .btn-primary {
        padding: 8px 12px !important;
    }

    /* Hide notification badges on very small screens */
    .navbar-icon-btn .badge {
        display: none;
    }

    /* Smaller page title on mobile */
    .page-title-main {
        font-size: 24px;
        margin-bottom: 12px;
    }

    /* Compact breadcrumb on mobile */
    .breadcrumb-container {
        padding: 8px 12px;
        margin-bottom: 16px;
    }

    .breadcrumb-item {
        font-size: 13px;
        padding: 2px 6px;
    }

    .content-wrapper {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Mobile Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* ============================================
   Dropdown Menus
   ============================================ */

/* Dropdown Customization */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    border: none;
    /* Shadow handles the edge */
}

.dropdown-item {
    padding: 10px 12px;
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 14px;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background-color: var(--body-bg);
    color: var(--primary-color);
}

.dropdown-item i {
    margin-right: 10px;
    color: var(--text-secondary);
}

/* ============================================
   Quick Actions
   ============================================ */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.quick-action-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action-card i {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.quick-action-card span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ============================================
   Toast Notifications
   ============================================ */

#toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.yis-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    border-left: 4px solid var(--primary-color);
    animation: toast-slide-in 0.3s ease forwards;
    transition: all 0.3s ease;
}

.yis-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.yis-toast-content i {
    font-size: 18px;
}

.yis-toast-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.yis-toast-close:hover {
    background: var(--body-bg);
    color: var(--text-primary);
}

.yis-toast-success {
    border-left-color: var(--success-color);
}

.yis-toast-success .yis-toast-content i {
    color: var(--success-color);
}

.yis-toast-error {
    border-left-color: var(--danger-color);
}

.yis-toast-error .yis-toast-content i {
    color: var(--danger-color);
}

.yis-toast-warning {
    border-left-color: var(--warning-color);
}

.yis-toast-warning .yis-toast-content i {
    color: var(--warning-color);
}

.yis-toast-info {
    border-left-color: var(--info-color);
}

.yis-toast-info .yis-toast-content i {
    color: var(--info-color);
}

.yis-toast-fade-out {
    opacity: 0;
    transform: translateX(100%);
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}