/* FLOW Design System Tokens - Linear/Vercel Style */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --flow-font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --flow-font-mono: 'JetBrains Mono', monospace;

    /* Light Theme Tokens */
    --flow-bg-canvas: #f8fafc;
    --flow-bg-surface: #ffffff;
    --flow-bg-subtle: #f1f5f9;
    --flow-border-subtle: #e2e8f0;
    --flow-border-strong: #cbd5e1;
    --flow-text-primary: #0f172a;
    --flow-text-secondary: #475569;
    --flow-text-muted: #94a3b8;

    /* Brand & Accents */
    --flow-accent-primary: #3b82f6;
    --flow-accent-focus: rgba(59, 130, 246, 0.15);
    --flow-shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --flow-shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --flow-shadow-drag: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] {
    --flow-bg-canvas: #090d16;
    --flow-bg-surface: #111827;
    --flow-bg-subtle: #1e293b;
    --flow-border-subtle: #1f2937;
    --flow-border-strong: #374151;
    --flow-text-primary: #f8fafc;
    --flow-text-secondary: #94a3b8;
    --flow-text-muted: #64748b;

    --flow-accent-primary: #60a5fa;
    --flow-accent-focus: rgba(96, 165, 250, 0.2);
    --flow-shadow-card: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --flow-shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
    --flow-shadow-drag: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

body {
    font-family: var(--flow-font-sans);
    background-color: var(--flow-bg-canvas);
    color: var(--flow-text-primary);
    -webkit-font-smoothing: antialiased;
    position: relative;
    min-height: 100vh;
}

/* Subtle Modern Moving Dotted Pattern for Dark Mode */
[data-bs-theme="dark"] body {
    background-color: #080c14;
    background-image: 
        radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
        radial-gradient(rgba(59, 130, 246, 0.10) 1.5px, transparent 1.5px);
    background-size: 32px 32px, 64px 64px;
    background-position: 0 0, 16px 16px;
    animation: flowDottedGridDrift 45s linear infinite;
}

@keyframes flowDottedGridDrift {
    0% {
        background-position: 0 0, 16px 16px;
    }
    50% {
        background-position: 32px 32px, 48px 48px;
    }
    100% {
        background-position: 64px 64px, 80px 80px;
    }
}

/* Container Full Fluid for Dashboard - Consistent Large Canvas */
.flow-main-wrapper {
    max-width: 1720px;
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1.25rem 2rem 1.25rem;
}

.flow-dashboard-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0.5rem 0;
}

/* Pills Breadcrumbs Style */
.breadcrumb {
    display: inline-flex;
    align-items: center;
    background: var(--flow-bg-surface);
    border: 1px solid var(--flow-border-subtle);
    padding: 0.3rem 0.85rem;
    border-radius: 9999px; /* Pill shape */
    box-shadow: var(--flow-shadow-card);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.85rem !important;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: var(--flow-text-muted);
    padding: 0 0.4rem;
    font-size: 0.95rem;
    line-height: 1;
}

.breadcrumb-item a {
    color: var(--flow-text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.breadcrumb-item a:hover {
    color: var(--flow-accent-primary);
}

.breadcrumb-item.active {
    color: var(--flow-text-primary);
    font-weight: 600;
}

/* Toolbar & Switcher */
.flow-toolbar {
    background: var(--flow-bg-surface);
    border: 1px solid var(--flow-border-subtle);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: var(--flow-shadow-card);
}

.flow-view-toggle .btn {
    font-size: 0.825rem;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--flow-text-secondary);
    transition: all 0.15s ease-in-out;
}

.flow-view-toggle .btn:hover {
    color: var(--flow-text-primary);
    background: var(--flow-bg-subtle);
}

.flow-view-toggle .btn.active {
    background: var(--flow-bg-subtle);
    color: var(--flow-accent-primary);
    border-color: var(--flow-border-subtle);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

/* Kanban Board Layout */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(280px, 1fr));
    gap: 1.25rem;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 2rem;
}

@media (max-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(4, 300px);
    }
}

.kanban-column {
    background: var(--flow-bg-surface);
    border: 1px solid var(--flow-border-subtle);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 230px);
    box-shadow: var(--flow-shadow-card);
}

.kanban-column-header {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--flow-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-column-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--flow-text-primary);
}

.kanban-column-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.kanban-column-dot.backlog { background-color: #94a3b8; }
.kanban-column-dot.progress { background-color: #3b82f6; }
.kanban-column-dot.review { background-color: #f59e0b; }
.kanban-column-dot.done { background-color: #10b981; }

.kanban-card-list {
    padding: 0.75rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 120px;
}

/* Task Card (Linear / Vercel Aesthetic) */
.flow-task-card {
    background: var(--flow-bg-surface);
    border: 1px solid var(--flow-border-subtle);
    border-radius: 10px;
    padding: 0.9rem;
    box-shadow: var(--flow-shadow-card);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    user-select: none;
    position: relative;
}

.flow-task-card:hover {
    transform: translateY(-2px);
    border-color: var(--flow-border-strong);
    box-shadow: var(--flow-shadow-hover);
}

.flow-task-card.is-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.flow-task-card.is-overdue {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.02);
}

.flow-task-code-badge {
    font-family: var(--flow-font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--flow-text-secondary);
    background: var(--flow-bg-subtle);
    border: 1px solid var(--flow-border-subtle);
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.flow-task-code-badge:hover {
    background: var(--flow-border-subtle);
    color: var(--flow-text-primary);
}

.flow-memo-chip {
    font-size: 0.7rem;
    font-weight: 500;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-task-title {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--flow-text-primary);
    margin: 0.5rem 0;
}

/* Micro Progress Bar */
.flow-progress-track {
    height: 5px;
    background: var(--flow-bg-subtle);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.flow-progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #3b82f6 0%, #6366f1 100%);
    transition: width 0.3s ease;
}

.flow-progress-fill.done {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

/* Git Commit Chip */
.flow-git-chip {
    font-family: var(--flow-font-mono);
    font-size: 0.7rem;
    color: var(--flow-text-secondary);
    background: var(--flow-bg-subtle);
    border-radius: 5px;
    padding: 0.2rem 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Avatar Badge */
.flow-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #cbd5e1;
    color: #1e293b;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--flow-border-subtle);
}

/* High-Density List View */
.flow-table-container {
    background: var(--flow-bg-surface);
    border: 1px solid var(--flow-border-subtle);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--flow-shadow-card);
}

.flow-table {
    margin-bottom: 0;
    width: 100%;
    font-size: 0.85rem;
}

.flow-table thead th {
    background: var(--flow-bg-subtle);
    color: var(--flow-text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--flow-border-subtle);
}

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

.flow-table tbody tr {
    transition: background 0.12s ease;
}

.flow-table tbody tr:hover {
    background: var(--flow-bg-subtle);
}

/* Calendar Card */
.flow-calendar-container {
    background: var(--flow-bg-surface);
    border: 1px solid var(--flow-border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--flow-shadow-card);
}

/* Priority Badges */
.badge-priority-top-urgent { background: linear-gradient(135deg, #dc2626, #991b1b); color: #fff; box-shadow: 0 1px 3px rgba(220, 38, 38, 0.4); }
.badge-priority-urgent { background-color: #f97316; color: #fff; }
.badge-priority-normal { background-color: #3b82f6; color: #fff; }
.badge-priority-low { background-color: #64748b; color: #fff; }

/* =========================================================================
   Interactive Animations, Preloaders, and Micro-interactions
   ========================================================================= */

/* Global Page Transition */
.flow-page-enter {
    animation: flowFadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes flowFadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Navbar Links & Tab Micro-Interactions */
.navbar-nav .nav-link {
    position: relative;
    font-size: 0.8rem;
    font-weight: 500;
    transition: color 0.2s ease, transform 0.15s ease, background-color 0.15s ease;
    border-radius: 6px;
    padding: 0.32rem 0.65rem !important;
    display: inline-flex;
    align-items: center;
}

.navbar-nav .nav-link i {
    font-size: 0.82rem;
}

.navbar-nav .nav-link:hover {
    transform: translateY(-1px);
    color: #ffffff !important;
}

.navbar-nav .nav-link:active {
    transform: scale(0.97);
}

/* Compact Proportional Notification Bell Badge */
#flow-notif-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 4px !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    line-height: 16px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 9999px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

#flow-notif-badge.d-none {
    display: none !important;
}

.flow-view-toggle .btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flow-view-toggle .btn:active {
    transform: scale(0.95);
}

/* Tab Transition */
.flow-view-content {
    animation: flowViewSwitch 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes flowViewSwitch {
    from {
        opacity: 0;
        transform: scale(0.99) translateY(4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Global Top Progress / Lazy Preloader Bar */
#flow-top-loader {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    z-index: 99999;
    transition: width 0.3s ease, opacity 0.4s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
    pointer-events: none;
}

/* Processing Overlay Preloader */
#flow-process-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

#flow-process-overlay.active {
    display: flex;
}

.flow-spinner-glow {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: flowSpin 0.75s linear infinite;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.flow-process-text {
    margin-top: 1rem;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

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

/* SweetAlert2 Theme Customization matching FLOW */
.swal2-popup,
.swal2-popup.flow-swal-modal {
    border-radius: 16px !important;
    background: var(--flow-bg-surface) !important;
    color: var(--flow-text-primary) !important;
    border: 1px solid var(--flow-border-subtle) !important;
    box-shadow: var(--flow-shadow-drag) !important;
    font-family: var(--flow-font-sans) !important;
}

.swal2-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: var(--flow-text-primary) !important;
}

.swal2-html-container {
    color: var(--flow-text-secondary) !important;
    font-size: 0.88rem !important;
}

.swal2-input,
.swal2-textarea,
.swal2-select {
    background-color: var(--flow-bg-subtle) !important;
    border: 1px solid var(--flow-border-subtle) !important;
    color: var(--flow-text-primary) !important;
    border-radius: 8px !important;
    font-size: 0.875rem !important;
}

.swal2-input:focus,
.swal2-textarea:focus,
.swal2-select:focus {
    border-color: var(--flow-accent-primary) !important;
    box-shadow: 0 0 0 3px var(--flow-accent-focus) !important;
}

.flow-swal-confirm-btn {
    border-radius: 8px !important;
    padding: 0.5rem 1.25rem !important;
    font-weight: 600 !important;
    margin-right: 0.75rem !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.flow-swal-cancel-btn {
    border-radius: 8px !important;
    padding: 0.5rem 1.25rem !important;
    font-weight: 600 !important;
    margin-left: 0.75rem !important;
}

/* Ensure swal actions container has gap */
.swal2-actions {
    gap: 0.75rem !important;
}

/* Toast Customization: Compact, elegant, bottom-right */
.flow-toast {
    border-radius: 10px !important;
    border: 1px solid var(--flow-border-subtle) !important;
    box-shadow: var(--flow-shadow-hover) !important;
    font-family: var(--flow-font-sans) !important;
    padding: 0.5rem 0.85rem !important;
    max-width: 320px !important;
    margin-bottom: 1rem !important;
    margin-right: 1rem !important;
}

.flow-toast .swal2-title {
    font-size: 0.825rem !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    padding: 0 0 0 0.4rem !important;
}

.flow-toast .swal2-icon {
    font-size: 0.55rem !important;
    width: 1.35rem !important;
    height: 1.35rem !important;
    margin: 0 !important;
}

.flow-toast .swal2-timer-progress-bar {
    height: 2px !important;
}

/* Bootstrap Modal & Backdrop Stacking Fix */
.modal-backdrop {
    z-index: 1050 !important;
}

.modal {
    z-index: 1055 !important;
}

/* Secure PDF Viewer Container */
.flow-pdf-container {
    background-color: #2b2b2b;
    border-radius: 0 0 1rem 1rem;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.flow-pdf-container iframe {
    pointer-events: auto;
}

/* Multi-select inputs */
select[multiple].form-select {
    min-height: 110px;
    background-image: none;
    padding: 0.5rem;
}

select[multiple].form-select optgroup {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--flow-text-secondary);
    padding: 4px 6px;
    background: var(--flow-bg-subtle);
}

select[multiple].form-select option {
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px 0;
    font-size: 0.85rem;
}

/* Tab Preloader Overlay - Adaptive Dark/Light Mode */
.flow-tab-loader-overlay {
    background: rgba(248, 250, 252, 0.75);
    z-index: 100;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

[data-bs-theme="dark"] .flow-tab-loader-overlay {
    background: rgba(17, 24, 39, 0.75);
}

/* FullCalendar - Remove all underlines and modernize calendar typography */
.fc a,
.fc-col-header-cell-cushion,
.fc-daygrid-day-number,
.fc-event,
.fc-event-title,
.fc-toolbar-title {
    text-decoration: none !important;
}

.fc-col-header-cell-cushion:hover,
.fc-daygrid-day-number:hover {
    text-decoration: none !important;
}

.fc-col-header-cell-cushion {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--flow-text-secondary) !important;
    padding: 8px 4px !important;
}

.fc-daygrid-day-number {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--flow-text-primary) !important;
    padding: 4px 8px !important;
}

.fc-theme-standard td, 
.fc-theme-standard th {
    border-color: var(--flow-border-subtle) !important;
}

.fc-theme-standard .fc-scrollgrid {
    border-color: var(--flow-border-subtle) !important;
    border-radius: 0.75rem;
    overflow: hidden;
}

/* Form Alignment & Input Heights Standardizing */
.select2-container--krajee-bs5 .select2-selection--single,
.select2-container--bootstrap-5 .select2-selection--single,
.select2-container--default .select2-selection--single {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0.375rem 0.75rem !important;
    display: flex !important;
    align-items: center !important;
    border-radius: 0.5rem !important;
    font-size: 0.875rem !important;
}

.select2-container--krajee-bs5 .select2-selection--single .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal !important;
    padding-left: 0 !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--krajee-bs5 .select2-selection--single .select2-selection__arrow,
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow,
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    top: 0 !important;
    right: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* DatePicker input group perfectionist alignment & theme */
.input-group.date {
    height: 38px;
    align-items: stretch;
}

.input-group.date > .form-control {
    height: 38px !important;
    border-top-left-radius: 0.5rem !important;
    border-bottom-left-radius: 0.5rem !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    font-size: 0.875rem;
}

.input-group.date .input-group-text,
.input-group.date .kv-date-picker,
.input-group.date .kv-date-remove {
    background-color: var(--flow-bg-subtle) !important;
    border-color: var(--flow-border-subtle) !important;
    color: var(--flow-text-primary) !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 38px !important;
    padding: 0 0.75rem !important;
    line-height: 1 !important;
    margin: 0 !important;
}

.input-group.date .kv-date-remove {
    border-left: 0 !important;
    border-right: 0 !important;
}

.input-group.date .kv-date-picker {
    border-top-right-radius: 0.5rem !important;
    border-bottom-right-radius: 0.5rem !important;
}

.input-group.date .input-group-text i,
.input-group.date .kv-date-picker i,
.input-group.date .kv-date-remove i {
    font-size: 0.95rem !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
}

/* Dark mode button & badge enhancements */
[data-bs-theme="dark"] .btn-outline-secondary {
    color: var(--flow-text-secondary) !important;
    border-color: var(--flow-border-strong) !important;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    color: #ffffff !important;
    background-color: var(--flow-border-strong) !important;
    border-color: var(--flow-border-strong) !important;
}
