/* ============================================
   SWAMP v3 - Application Styles
   ============================================ */

/* Sidebar */
#sidebar {
    min-width: 230px;
    max-width: 230px;
    min-height: 100vh;
    height: 100vh;
    background: #1a2035;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
}

#sidebar.collapsed {
    min-width: 60px;
    max-width: 60px;
}

.sidebar-header {
    padding: 14px 16px;
    background: #151c2e;
    border-bottom: 1px solid #2d3a5a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #a8b3cf;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-toggle:hover { color: #fff; background: #2d3a5a; }

#sidebar .nav {
    padding: 8px;
    flex: 1;
}

#sidebar .nav-link {
    color: #a8b3cf;
    padding: 9px 12px;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
}

#sidebar .nav-link:hover {
    color: #fff;
    background: #2d3a5a;
}

#sidebar .nav-link.active {
    color: #fff;
    background: #2563eb;
}

#sidebar .nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-section-label {
    color: #4a5568;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 12px 4px;
    white-space: nowrap;
}

.sidebar-footer {
    border-top: 1px solid #2d3a5a;
    padding: 12px 16px;
    color: #a8b3cf;
    font-size: 0.8rem;
}

.sidebar-footer .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    background: #2d3a5a;
}

/* Content wrapper */
#content-wrapper {
    flex: 1;
    min-height: 100vh;
    background: #f3f4f6;
    min-width: 0;
}

/* Top bar */
.top-bar {
    height: 52px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

.top-bar .page-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

/* Main content area */
.main-content {
    padding: 24px;
}

/* Stat cards */
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: #111827;
}

.stat-label {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

/* Cards */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: none;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    padding: 12px 16px;
}

/* Tables */
.table th {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #cbd5e1;
    background: #f1f5f9;
    padding: 10px 12px;
}

.table td {
    padding: 10px 12px;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9fafb; }

/* Closed budget row */
.table tr.row-closed td {
    background: #dee2e6 !important;
    color: #6c757d !important;
    border-left-color: #adb5bd;
}
.table tr.row-closed td:first-child {
    border-left: 3px solid #adb5bd;
}
.table tr.row-closed .badge.bg-secondary {
    background: #6c757d !important;
    font-size: 0.6rem;
}

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: #111827 !important; }

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

/* Permit category badges */
.badge-jd          { background: #dbeafe; color: #1d4ed8; }
.badge-coe         { background: #d1fae5; color: #065f46; }
.badge-vadeq       { background: #ede9fe; color: #5b21b6; }
.badge-vamrc       { background: #fef3c7; color: #92400e; }
.badge-usfish      { background: #fee2e2; color: #991b1b; }
.badge-vsmp        { background: #e0f2fe; color: #0369a1; }
.badge-lwb         { background: #fce7f3; color: #9d174d; }
.badge-misceng     { background: #f0fdf4; color: #166534; }
.badge-generalinfo { background: #f5f3ff; color: #6d28d9; }

/* Expiration coloring */
.expires-critical { color: #dc2626; font-weight: 600; }
.expires-warning  { color: #d97706; font-weight: 600; }
.expires-ok       { color: #374151; }

/* Report table rows */
.permit-row { font-size: 0.85rem; }

/* Project permit navigation */
.project-row:hover { background: #f9fafb; }

.permit-section-header {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0.25rem;
}

.permit-state-header {
    font-size: 0.82rem;
    padding: 0.35rem 0;
    color: #4b5563;
    display: flex;
    align-items: center;
}
.permit-state-header:hover { color: #111827; }

.permit-nav-item {
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
}
.permit-nav-item:hover { background: #e5e7eb; }

/* Buttons */
.btn-xs {
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: 4px;
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a2035 0%, #2563eb 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
    font-size: 2rem;
    font-weight: 800;
    color: #1a2035;
    letter-spacing: 2px;
}

/* Search bar */
.search-bar .form-control,
.search-bar .form-select {
    border-radius: 6px;
    font-size: 0.875rem;
}

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 10px 10px;
    font-size: 0.8rem;
    color: #6b7280;
}

/* Map container */
#map-container {
    width: 100%;
    height: calc(100vh - 52px - 48px);
    position: relative;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #2d3a5a; border-radius: 4px; }

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -230px;
        z-index: 300;
    }
    #sidebar.mobile-open {
        left: 0;
    }
}

/* Report filters */
.report-filter-bar {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Loading overlay */
.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

/* Employee avatar */
.emp-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.emp-avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
}

.employee-card:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}

/* Demo badge */
.demo-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Modal overlay */
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-card-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Large editor modal */
.modal-card-editor {
    width: 90vw;
    max-width: 960px;
    height: 85vh;
    display: flex;
    flex-direction: column;
}
.modal-card-editor .modal-card-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}
.modal-card-editor .ql-container {
    height: calc(100% - 42px); /* subtract toolbar height */
}
.modal-card-editor .ql-editor {
    height: 100%;
    overflow-y: auto;
    font-size: 0.95rem;
    padding: 1rem 1.25rem;
}

/* Quill editor inside modals */
.ql-container { font-size: 0.9rem; font-family: inherit; }
.ql-toolbar.ql-snow { border-radius: 4px 4px 0 0; border-color: #dee2e6; background: #f8f9fa; }
.ql-container.ql-snow { border-radius: 0 0 4px 4px; border-color: #dee2e6; }
.ql-editor { min-height: 120px; }
.ql-editor p { margin-bottom: 0.25em; }

.modal-card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Markdown / article rendered content */
.markdown-body {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #1f2937;
    max-width: 52rem;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #111827;
}
.markdown-body h1 { font-size: 1.4rem; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.35rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5rem; }
.markdown-body li { margin-bottom: 0.15em; }
.markdown-body code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #d946689e;
}
.markdown-body pre {
    background: #f3f4f6;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
}
.markdown-body blockquote {
    border-left: 3px solid #6366f1;
    padding-left: 1rem;
    color: #6b7280;
    margin: 0.75rem 0;
    background: #f9fafb;
    padding: 0.5rem 1rem;
    border-radius: 0 4px 4px 0;
}
.markdown-body hr { border-color: #e5e7eb; }
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.5rem 0;
}
/* Reset ql-editor min-height when used for display only */
.markdown-body.ql-editor { min-height: unset; border: none; padding: 0; }

/* ── Sales & Budget Dashboard ────────────────────────────── */
.sales-info-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    border-left: 3px solid #6c757d;
}
.sales-info-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6c757d;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}
.sales-info-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: #212529;
}

.budget-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    text-align: center;
}
.budget-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6c757d;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.budget-amount {
    font-size: 1.25rem;
    font-weight: 700;
}

.sales-task-table th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom-width: 2px;
}
.sales-task-table td {
    vertical-align: middle;
}
.sales-task-table tfoot td {
    border-top: 2px solid #dee2e6;
}

/* ── Scheduler / Calendar ────────────────────────────────── */
.sched-toolbar {
    position: relative;
    z-index: 10;
}
.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}
.cal-header-cell {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cal-grid-week {
    min-height: 400px;
}
.cal-cell {
    min-height: 165px;
    min-width: 0;
    border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
    padding: 4px;
    cursor: pointer;
    transition: background 0.1s;
    overflow: hidden;
}
.cal-cell:hover {
    background: #f8fafc;
}
.cal-cell:nth-child(7n) {
    border-right: none;
}
.cal-cell-other {
    background: #fafafa;
}
.cal-cell-other .cal-day-num {
    color: #c0c0c0;
}
.cal-cell-today {
    background: #eff6ff !important;
}
.cal-cell-today .cal-day-num {
    background: #2563eb;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-cell-week.cal-cell-today .cal-day-num {
    display: inline-flex;
    border-radius: 12px;
    width: auto;
    padding: 0 8px;
}
.cal-cell-week.cal-cell-today .cal-day-num small {
    color: #fff !important;
}
.cal-cell-week {
    min-height: 400px;
}
.cal-day-num {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
    padding: 2px 4px;
}
.cal-entries {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.cal-chip {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
    cursor: pointer;
    overflow: hidden;
    transition: opacity 0.15s;
    max-width: 100%;
}
.cal-chip:hover {
    opacity: 0.8;
}
.cal-chip-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.cal-chip-overflow {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6b7280;
    padding: 1px 6px;
    cursor: default;
}
.cal-chip-week {
    padding: 4px 8px;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

/* Choices.js sizing override to match Bootstrap sm */
.choices-sm .choices__inner {
    min-height: 31px;
    padding: 2px 4px;
    font-size: 0.82rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #fff;
}
.choices-sm .choices__input {
    font-size: 0.82rem;
    padding: 2px 4px;
    margin-bottom: 0;
}
.choices-sm .choices__list--multiple .choices__item {
    font-size: 0.75rem;
    padding: 2px 6px;
    margin-bottom: 1px;
    border-radius: 3px;
    background: #2563eb;
    border: none;
}
.choices-sm .choices__list--dropdown .choices__item {
    font-size: 0.82rem;
    padding: 6px 10px;
}
.choices-sm .choices__list--dropdown {
    z-index: 1060;
}

/* AI Insights content */
.insights-content h3, .insights-content h4, .insights-content h5 {
    color: #1e293b;
}
.insights-content table {
    width: 100%;
}
.insights-content table th {
    font-size: 0.75rem !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.insights-content table td {
    vertical-align: middle;
}
.insights-content strong {
    color: #dc2626;
}
.insights-content p {
    color: #334155;
}

/* Drag-and-drop highlight */
.cal-cell-dragover {
    background: #eff6ff !important;
    outline: 2px dashed #3b82f6;
    outline-offset: -2px;
}
/* Resize target highlight */
.cal-cell-resize-target {
    background: #fef9c3 !important;
    outline: 2px dashed #eab308;
    outline-offset: -2px;
}

/* Resize handle on calendar chips */
.cal-chip-resizable {
    position: relative;
}
.cal-chip-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    border-radius: 0 3px 3px 0;
}
.cal-chip-handle:hover {
    background: rgba(0,0,0,0.12);
}

/* Compact view chips */
.cal-chip-compact {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
    cursor: pointer;
    overflow: hidden;
    transition: opacity 0.15s;
}
.cal-chip-compact:hover {
    opacity: 0.8;
}
.cal-chip-count {
    font-weight: 700;
    opacity: 0.8;
}

/* Small schedule avatar */
.sched-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ── Gantt View ─────────────────────────────────────────── */
.gantt-grid {
    width: 100%;
    overflow-x: auto;
}
.gantt-header {
    display: grid;
    grid-template-columns: 200px repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 2;
}
.gantt-label-col {
    grid-row: 1;
    grid-column: 1;
    padding: 6px 8px;
    border-right: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    min-width: 200px;
    overflow: hidden;
}
.gantt-day-col {
    padding: 6px 4px;
    text-align: center;
    border-right: 1px solid #f0f0f0;
}
.gantt-day-col:last-child {
    border-right: none;
}
.gantt-dept-header {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 0.82rem;
}
.gantt-dept-header:hover {
    background: #f3f4f6;
}
.gantt-row {
    display: grid;
    grid-template-columns: 200px repeat(7, 1fr);
    min-height: 40px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}
.gantt-day-cell {
    border-right: 1px solid #f0f0f0;
    cursor: pointer;
    min-height: 40px;
}
.gantt-day-cell:hover {
    background: #f8fafc;
}
.gantt-day-cell:last-child {
    border-right: none;
}
.gantt-bar {
    position: absolute;
    height: 26px;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    overflow: hidden;
    z-index: 1;
    transition: opacity 0.15s;
}
.gantt-bar:hover {
    opacity: 0.85;
}
.gantt-bar-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.gantt-bar-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    border-radius: 0 4px 4px 0;
}
.gantt-bar-handle:hover {
    background: rgba(0,0,0,0.1);
}

/* ── Floating AI Assistant Button ───────────────────────── */
.swamp-assistant-fab {
    width: 48px;
    height: 48px;
    bottom: 1.5rem;
    right: -20px;          /* tucked: only ~28px visible */
    z-index: 1040;
    transition: right 0.25s ease, opacity 0.25s ease, box-shadow 0.25s ease;
    opacity: 0.55;
}
.swamp-assistant-fab:hover,
.swamp-assistant-fab:focus {
    right: 1.5rem;         /* slide fully into view */
    opacity: 1;
}

/* Auto-filled field indicator — left border accent */
.autofill-highlight {
    border-left: 3px solid #2563eb !important;
    background-color: #eff6ff !important;
    transition: border-color 0.3s, background-color 0.3s;
}
