/* CRM Emikon - Custom Styles */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px;
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
}

/* Sidebar */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    min-height: 100vh;
    transition: all 0.3s;
}

#sidebar.collapsed {
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
}

#sidebar.collapsed .nav-link span,
#sidebar.collapsed .sidebar-header h5,
#sidebar.collapsed .nav-item small {
    display: none;
}

#sidebar.collapsed .nav-link {
    text-align: center;
    padding: 0.75rem;
}

#sidebar.collapsed .nav-link i {
    margin: 0 !important;
    font-size: 1.25rem;
}

#sidebar .nav-link {
    padding: 0.5rem 1rem;
    margin-bottom: 2px;
    transition: all 0.2s;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

#sidebar .nav-link.active {
    font-weight: 500;
}

/* Page wrapper */
#wrapper {
    min-height: 100vh;
}

#page-content-wrapper {
    min-width: 0;
    width: 100%;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

/* Tables */
.table th {
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Status badges */
.badge-lead { background-color: #6c757d; }
.badge-prospect { background-color: #0dcaf0; color: #212529; }
.badge-active { background-color: #198754; }
.badge-inactive { background-color: #dc3545; }

/* Category badges */
.badge-audit { background-color: #6f42c1; }
.badge-consulting { background-color: #fd7e14; }
.badge-software { background-color: #20c997; }
.badge-mixed { background-color: #0d6efd; }

/* Priority badges */
.badge-urgent { background-color: #dc3545; }
.badge-high { background-color: #fd7e14; }
.badge-medium { background-color: #0dcaf0; color: #212529; }
.badge-low { background-color: #6c757d; }

/* Invoice status badges */
.badge-draft { background-color: #6c757d; }
.badge-sent { background-color: #0dcaf0; color: #212529; }
.badge-paid { background-color: #198754; }
.badge-partial { background-color: #ffc107; color: #212529; }
.badge-overdue { background-color: #dc3545; }
.badge-cancelled { background-color: #212529; }

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Buttons */
.btn-icon {
    padding: 0.375rem 0.5rem;
}

/* Dashboard widgets */
.widget-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.widget-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.widget-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

/* Stats */
.stat-value {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
}

.stat-label {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

/* Pagination */
.pagination .page-link {
    border: none;
    margin: 0 2px;
    border-radius: 0.375rem;
}

/* Dropdown menus */
.dropdown-menu {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* HTMX loading indicator */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-request.htmx-indicator {
    opacity: 1;
}

/* ========================================
   Kanban Board Styles
   ======================================== */

.kanban-board {
    min-height: 500px;
}

.kanban-column {
    background: #f8f9fa;
    border-radius: 0.5rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem 0.5rem 0 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.kanban-column-body {
    padding: 0.5rem;
    flex: 1;
    min-height: 200px;
}

.kanban-card {
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s;
    border-left: 3px solid transparent;
}

.kanban-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.kanban-card:active {
    cursor: grabbing;
}

/* Kanban drag states */
.kanban-ghost {
    opacity: 0.4;
    background: #e3f2fd;
    border: 2px dashed #0d6efd;
    border-radius: 0.375rem;
}

.kanban-ghost .card-body {
    visibility: hidden;
}

.kanban-drag {
    transform: rotate(2deg);
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.kanban-chosen {
    box-shadow: 0 0.25rem 1rem rgba(13, 110, 253, 0.3);
}

/* ========================================
   Notification Styles
   ======================================== */

.notification-badge {
    top: 2px !important;
    right: 2px !important;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 4px;
    animation: notificationPulse 2s infinite;
}

@keyframes notificationPulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.notification-dropdown {
    max-height: 400px;
    overflow-y: auto;
}

.notification-dropdown .dropdown-item {
    white-space: normal;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.notification-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.notification-unread {
    border-left: 3px solid #0d6efd;
}

/* ========================================
   Timeline Component
   ======================================== */

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}

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

.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #0d6efd;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #0d6efd;
}

.timeline-item.timeline-success::before {
    background: #198754;
    box-shadow: 0 0 0 2px #198754;
}

.timeline-item.timeline-warning::before {
    background: #ffc107;
    box-shadow: 0 0 0 2px #ffc107;
}

.timeline-item.timeline-danger::before {
    background: #dc3545;
    box-shadow: 0 0 0 2px #dc3545;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.empty-state-description {
    color: #adb5bd;
    margin-bottom: 1.5rem;
}

/* ========================================
   Loading Skeleton
   ======================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.25rem;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text-sm {
    height: 0.75rem;
    width: 60%;
    margin-bottom: 0.5rem;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   Modal Styles
   ======================================== */

.modal-content {
    border: none;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* ========================================
   Print Styles for Invoices
   ======================================== */

@media print {
    #sidebar,
    .navbar,
    footer,
    .btn,
    .no-print,
    .toast-container,
    #modal-container {
        display: none !important;
    }

    main {
        padding: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }

    body {
        background: #fff !important;
    }

    #page-content-wrapper {
        margin: 0;
        padding: 0;
    }

    .invoice-header {
        border-bottom: 2px solid #000;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .invoice-total {
        font-size: 1.25rem;
        font-weight: 700;
    }

    @page {
        margin: 1cm;
    }
}

/* ========================================
   Responsive Sidebar (Mobile)
   ======================================== */

@media (max-width: 992px) {
    #sidebar {
        position: fixed;
        z-index: 1030;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    #sidebar.show {
        transform: translateX(0);
    }

    #page-content-wrapper {
        width: 100%;
    }

    /* Mobile overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1029;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Kanban columns stack vertically on mobile */
    .kanban-board .col-md-3 {
        margin-bottom: 1rem;
    }

    .kanban-column {
        min-height: 200px;
    }

    /* Stats shrink */
    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    main {
        padding: 1rem !important;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .widget-icon {
        width: 36px;
        height: 36px;
    }

    .kanban-card .card-body {
        padding: 0.5rem !important;
    }
}

/* ========================================
   Dark Mode Styles
   ======================================== */

[data-bs-theme="dark"] {
    --bs-body-bg: #1a1d21;
    --bs-body-color: #e9ecef;
}

[data-bs-theme="dark"] .card {
    background-color: #212529;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #e9ecef;
}

[data-bs-theme="dark"] .table th {
    color: #adb5bd;
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .kanban-column {
    background: #2b3035;
}

[data-bs-theme="dark"] .kanban-column-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .kanban-card {
    background-color: #343a40;
}

[data-bs-theme="dark"] .kanban-ghost {
    background: rgba(13, 110, 253, 0.15);
    border-color: #0d6efd;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #2b3035;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e9ecef;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .list-group-item {
    background-color: transparent;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e9ecef;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #343a40;
    border-color: rgba(255, 255, 255, 0.15);
    color: #e9ecef;
}

[data-bs-theme="dark"] .bg-white {
    background-color: #212529 !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #2b3035 !important;
}

[data-bs-theme="dark"] .border-bottom {
    border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .border-top {
    border-top-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] footer {
    background-color: #212529 !important;
}

[data-bs-theme="dark"] .navbar-light {
    background-color: #212529 !important;
}

[data-bs-theme="dark"] .timeline::before {
    background: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #343a40 25%, #495057 50%, #343a40 75%);
    background-size: 200% 100%;
}

[data-bs-theme="dark"] .notification-unread {
    background-color: rgba(13, 110, 253, 0.1) !important;
}

[data-bs-theme="dark"] .modal-content {
    background-color: #212529;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .empty-state-icon {
    color: #495057;
}

/* Dark mode toggle icon update */
[data-bs-theme="dark"] #darkModeIcon::before {
    content: "\F5A2"; /* bi-sun icon */
}

/* ========================================
   KEYBOARD SHORTCUTS STYLES
   ======================================== */

/* Command Palette */
.command-palette-modal .modal-dialog {
    max-width: 640px;
}

.command-palette-modal .modal-content {
    border-radius: 0.75rem;
    overflow: hidden;
}

.command-palette-search {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    gap: 0.75rem;
}

.command-palette-search i {
    color: #6c757d;
    font-size: 1.25rem;
}

.command-palette-search .form-control {
    border: none;
    padding: 0;
    font-size: 1rem;
    box-shadow: none !important;
}

.command-palette-search .form-control:focus {
    outline: none;
}

.command-palette-kbd {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: #e9ecef;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
}

.command-palette-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.command-palette-section {
    margin-bottom: 1rem;
}

.command-palette-section:last-child {
    margin-bottom: 0;
}

.command-palette-section-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
}

.command-palette-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    gap: 0.75rem;
}

.command-palette-item:hover,
.command-palette-item.selected {
    background: #e7f1ff;
}

.command-palette-item i {
    font-size: 1.125rem;
    color: #6c757d;
    width: 20px;
    text-align: center;
}

.command-palette-item-title {
    font-weight: 500;
    color: #212529;
}

.command-palette-item-subtitle {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.125rem;
}

.command-palette-item mark {
    background: #fff3cd;
    padding: 0 0.125rem;
    border-radius: 0.125rem;
}

.command-palette-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.command-palette-hints {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: #6c757d;
    flex-wrap: wrap;
}

.command-palette-hints kbd {
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin: 0 0.25rem;
}

/* Quick Create Modal */
.quick-create-form .nav-tabs {
    border-bottom: 2px solid #dee2e6;
}

.quick-create-form .nav-tabs .nav-link {
    border: none;
    color: #6c757d;
    padding: 0.75rem 1.25rem;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
}

.quick-create-form .nav-tabs .nav-link:hover {
    border-color: #e9ecef;
    color: #495057;
}

.quick-create-form .nav-tabs .nav-link.active {
    color: #0d6efd;
    border-color: #0d6efd;
    font-weight: 500;
}

/* Shortcuts Help Modal */
.shortcuts-section {
    margin-bottom: 2rem;
}

.shortcuts-list {
    display: grid;
    gap: 0.75rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    transition: all 0.15s;
}

.shortcut-item:hover {
    background: #e9ecef;
}

.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 200px;
}

.shortcut-kbd {
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 2px 0 #dee2e6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    min-width: 2rem;
    text-align: center;
}

.shortcut-keys .plus,
.shortcut-keys .then {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
}

.shortcut-description {
    flex: 1;
    color: #495057;
}

/* Key Sequence Feedback */
.key-sequence-feedback {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: rgba(13, 110, 253, 0.95);
    color: white;
    font-size: 2rem;
    font-weight: 600;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    animation: keySequenceFade 1.5s ease-in-out;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@keyframes keySequenceFade {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Table Row Focus */
.table-row-focused {
    background-color: rgba(13, 110, 253, 0.1) !important;
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

.table-row-focused td {
    position: relative;
}

/* Keyboard Navigation Hints */
.keyboard-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #6c757d;
    padding: 0.25rem 0.5rem;
    background: #f8f9fa;
    border-radius: 0.25rem;
}

.keyboard-hint kbd {
    font-size: 0.625rem;
    padding: 0.125rem 0.25rem;
}

/* Dark Mode Adjustments for Keyboard Shortcuts */
[data-bs-theme="dark"] .command-palette-modal .modal-content {
    background-color: #212529;
}

[data-bs-theme="dark"] .command-palette-search {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .command-palette-search i {
    color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-search .form-control {
    background: transparent;
    color: #e9ecef;
}

[data-bs-theme="dark"] .command-palette-kbd {
    background: #343a40;
    border-color: #495057;
    color: #e9ecef;
}

[data-bs-theme="dark"] .command-palette-section-title {
    color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-item:hover,
[data-bs-theme="dark"] .command-palette-item.selected {
    background: rgba(13, 110, 253, 0.2);
}

[data-bs-theme="dark"] .command-palette-item i {
    color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-item-title {
    color: #e9ecef;
}

[data-bs-theme="dark"] .command-palette-item-subtitle {
    color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-item mark {
    background: rgba(255, 193, 7, 0.3);
    color: #ffc107;
}

[data-bs-theme="dark"] .command-palette-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
    background: #1a1d21;
}

[data-bs-theme="dark"] .command-palette-hints {
    color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-hints kbd {
    background: #343a40;
    border-color: #495057;
    color: #e9ecef;
}

[data-bs-theme="dark"] .shortcut-item {
    background: #2b3035;
}

[data-bs-theme="dark"] .shortcut-item:hover {
    background: #343a40;
}

[data-bs-theme="dark"] .shortcut-kbd {
    background: #343a40;
    border-color: #495057;
    box-shadow: 0 2px 0 #495057;
    color: #e9ecef;
}

[data-bs-theme="dark"] .shortcut-description {
    color: #adb5bd;
}

[data-bs-theme="dark"] .table-row-focused {
    background-color: rgba(13, 110, 253, 0.15) !important;
    outline-color: #0d6efd;
}

[data-bs-theme="dark"] .keyboard-hint {
    background: #2b3035;
    color: #adb5bd;
}

/* Accessibility - High Contrast Focus States */
.command-palette-item:focus,
.shortcut-kbd:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Smooth transitions for all keyboard shortcut elements */
.command-palette-item,
.shortcut-item,
.table-row-focused {
    transition: all 0.15s ease-in-out;
}
