/* DBControl -- Core CSS (layout, scrollbars, tooltips, avatar, page system) */

[x-cloak] { display: none !important; }

/* Slim scrollbars -- Chrome / Safari / Edge */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5c5c5; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* Slim scrollbars -- Firefox */
* { scrollbar-width: thin; scrollbar-color: #c5c5c5 transparent; }

/* Smooth transitions */
.sidebar-transition { transition: width 300ms ease; }

/* Progress bar animation */
.progress-bar { transition: width 0.5s ease-in-out; }

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #1f2937;
    color: white;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 50;
}

/* ============================================================ */
/* Standard page layout system                                  */
/* ============================================================ */

.page-layout {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    width: 100%;
    min-height: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem 12px 1.25rem;
    height: 48px;
}

.page-header h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
    margin: 0;
    display: flex;
    align-items: center;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-actions button,
.page-actions select,
.page-actions label {
    font-size: 0.8rem;
}

/* Standard button for page header */
.page-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: 0.5rem;
    transition: all 150ms;
    border: none;
    cursor: pointer;
    margin-top: -6px;
    margin-bottom: -6px;
}

.page-header-btn-primary {
    background-color: #2563eb;
    color: #ffffff;
}

.page-header-btn-primary:hover {
    background-color: #1d4ed8;
}

.page-header-btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.page-header-btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

.page-header-btn-secondary:hover {
    background-color: #e5e7eb;
}

.page-header-btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
}

.page-header-btn svg {
    width: 1rem;
    height: 1rem;
}

.page-body {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
    padding: 0 1.25rem;
}

.page-body-scroll {
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 8px;
    padding: 0 1.25rem;
}

/* Standardized page footer */
.page-footer {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    padding: 6px 1.25rem;
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 36px;
}

.page-footer .footer-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-footer .footer-stat strong {
    color: #1f2937;
    font-weight: 600;
}

.page-footer .footer-divider {
    width: 1px;
    height: 14px;
    background: #d1d5db;
}

/* ============================================================
   Avatar / Portrait
   ============================================================ */
.avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
    font-size: 0.6rem;
    line-height: 1;
}
.avatar-circle-sm { width: 28px; height: 28px; font-size: 0.6rem; }
.avatar-circle-md { width: 36px; height: 36px; font-size: 0.7rem; }
.avatar-circle-lg { width: 64px; height: 64px; font-size: 1.25rem; }

/* ============================================================
   Tabulator overrides for DBControl theme
   ============================================================ */
.tabulator {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #fff;
}

.tabulator .tabulator-header {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #4b5563;
}

.tabulator .tabulator-header .tabulator-col {
    border-right: 1px solid #e5e7eb;
    padding: 8px 12px;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
    padding: 0;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 4px 8px;
    font-size: 0.75rem;
    outline: none;
    width: 100%;
    margin-top: 4px;
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter select {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 4px 8px;
    font-size: 0.75rem;
    outline: none;
    width: 100%;
    margin-top: 4px;
    background: white;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row {
    border-bottom: 1px solid #f3f4f6;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover {
    background-color: #eff6ff !important;
    cursor: pointer;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row .tabulator-cell {
    padding: 10px 12px;
    border-right: none;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-row-even {
    background: #fafafa;
}

/* ============================================================
   Kanban styles
   ============================================================ */
.kanban-container {
    display: flex;
    gap: 1rem;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.5rem;
}

.kanban-column {
    flex-shrink: 0;
    width: 18rem;
    display: flex;
    flex-direction: column;
    background: #f3f4f6;
    border-radius: 0.75rem;
    height: 100%;
    overflow: hidden;
}

.kanban-column-header {
    padding: 0.75rem;
    flex-shrink: 0;
    border-radius: 0.75rem 0.75rem 0 0;
}

.kanban-column-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.kanban-column-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    background: #d1d5db;
    font-size: 0.75rem;
    font-weight: 700;
    color: #374151;
}

.kanban-column-cards {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    min-height: 0;
}

.kanban-card {
    background: white;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    cursor: grab;
    transition: box-shadow 150ms;
}

.kanban-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.kanban-column-summary {
    font-size: 0.7rem;
    color: #6b7280;
    padding: 0.25rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.kanban-column-summary .overdue-count {
    color: #ef4444;
    font-weight: 600;
}

.overdue-card {
    border-left: 4px solid #ef4444 !important;
}

.overdue-date {
    color: #ef4444;
    font-weight: 700;
}

.overdue-count {
    color: #ef4444;
    font-weight: 700;
}

/* ============================================================
   View tabs
   ============================================================ */
.view-tabs {
    display: flex;
    gap: 0.25rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.25rem;
    width: fit-content;
    flex-shrink: 0;
}

/* When view-tabs are inside page-actions (header), remove bottom margin and align vertically */
.page-actions .view-tabs {
    margin-top: -6px;
    margin-bottom: -6px;
}

.view-tab {
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 150ms;
    cursor: pointer;
    border: none;
}

.view-tab-active {
    background: #2563eb;
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.view-tab-inactive {
    color: #6b7280;
    background: transparent;
}

.view-tab-inactive:hover {
    background: #f3f4f6;
}

/* ============================================================
   Stage breadcrumb
   ============================================================ */
.stage-breadcrumb {
    display: flex;
    gap: 2px;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.stage-arrow {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem 0.5rem 1.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f3f4f6;
    color: #6b7280;
    position: relative;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
    transition: all 0.15s;
    white-space: nowrap;
}

.stage-arrow:first-child {
    padding-left: 1rem;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
    border-radius: 0.375rem 0 0 0.375rem;
}

.stage-arrow:last-child {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%);
    border-radius: 0 0.375rem 0.375rem 0;
}

.stage-arrow.active {
    background: #2563eb;
    color: white;
}

.stage-arrow.completed {
    background: #dbeafe;
    color: #1d4ed8;
}

.stage-arrow:hover:not(.active) {
    background: #e5e7eb;
}

/* Star rating */
.star-rating { display: inline-flex; gap: 2px; }
.star-rating svg {
    transition: color 0.1s, fill 0.1s;
}
.star-rating svg:hover {
    transform: scale(1.15);
}

/* ============================================================
   Two-panel form layout
   ============================================================ */
.form-two-panel {
    display: flex;
    gap: 0;
    min-height: 450px;
}

.form-two-panel.grid-cols-1-only {
    display: grid;
    grid-template-columns: 1fr;
}

.form-left-panel {
    width: 50%;
    flex-shrink: 0;
    padding: 1.25rem;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
}

.form-right-panel {
    width: 50%;
    flex-shrink: 0;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   Activity log
   ============================================================ */
.activity-log {
    border-left: 2px solid #e5e7eb;
    padding-left: 1.5rem;
}

.activity-log-entry {
    position: relative;
    padding-bottom: 0.75rem;
}

.activity-log-entry::before {
    content: '';
    position: absolute;
    left: -1.8rem;
    top: 0.3rem;
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
}

.activity-log-entry.note-entry::before {
    background: #f59e0b;
}

/* ============================================================
   History / Cronologia timeline
   ============================================================ */
.history-timeline {
    border-left: 2px solid #e5e7eb;
    padding-left: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}
.history-timeline-entry {
    position: relative;
    padding-bottom: 0.625rem;
    font-size: 0.75rem;
}
.history-timeline-entry::before {
    content: '';
    position: absolute;
    left: -1.65rem;
    top: 0.25rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    z-index: 1;
}
.history-timeline-entry.ht-commit::before { background: #8b5cf6; }
.history-timeline-entry.ht-stage::before { background: #3b82f6; }
.history-timeline-entry.ht-message::before { background: #10b981; }
.history-timeline-entry.ht-phone::before { background: #f59e0b; }
.history-timeline-entry.ht-email::before { background: #ef4444; }

/* ============================================================
   Calendar styles
   ============================================================ */
.cal-cell {
    overflow-y: auto;
    min-width: 0;
}

.cal-today {
    background-color: #eff6ff;
}

.cal-day-cell {
    min-height: 60px;
    border-bottom: 1px solid #e5e7eb;
    min-width: 0;
    overflow: hidden;
}

.cal-day-cell:hover {
    background-color: #f0f9ff;
    cursor: pointer;
}

.cal-week-cell {
    min-height: 50px;
    min-width: 0;
    overflow: hidden;
}

.cal-week-cell:hover {
    background-color: #f0f9ff;
    cursor: pointer;
}

.cal-week-cell, .cal-day-cell {
    position: relative;
}

.cal-quarter-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #3b82f6;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 10;
}

.cal-week-cell:hover .cal-quarter-indicator,
.cal-day-cell:hover .cal-quarter-indicator {
    opacity: 1;
}

.fullday-bar {
    min-height: 26px;
}

/* Calendar appointment items — fixed width, no overflow */
.cal-appointment {
    display: block;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

/* ============================================================
   Quill Editor overrides
   ============================================================ */
.ql-container {
    font-size: 0.875rem;
    font-family: inherit;
}
.ql-editor {
    min-height: 120px;
    line-height: 1.6;
}
.ql-toolbar.ql-snow {
    border-color: #d1d5db;
    border-radius: 0.5rem 0.5rem 0 0;
}
.ql-container.ql-snow {
    border-color: #d1d5db;
    border-radius: 0 0 0.5rem 0.5rem;
}
.ql-editor.ql-blank::before {
    font-style: normal;
    color: #9ca3af;
}
.ql-snow .ql-editor h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #111827;
}
.ql-snow .ql-editor h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}
.ql-snow .ql-editor p {
    margin-bottom: 0.5rem;
}
.ql-snow .ql-editor ul,
.ql-snow .ql-editor ol {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}
.ql-snow .ql-editor li {
    margin-bottom: 0.25rem;
}
.ql-snow .ql-editor blockquote {
    border-left: 4px solid #d1d5db;
    padding-left: 1rem;
    color: #6b7280;
    margin: 0.5rem 0;
}
.ql-snow .ql-editor strong {
    font-weight: 700;
}
.ql-snow .ql-editor em {
    font-style: italic;
}
.ql-snow .ql-editor a {
    color: #2563eb;
    text-decoration: underline;
}
.ql-snow .ql-editor pre.ql-syntax {
    background-color: #1f2937;
    color: #e5e7eb;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
    margin: 0.5rem 0;
}

/* ============================================================
   Toggle switch
   ============================================================ */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #d1d5db; transition: 0.2s; border-radius: 20px; }
.toggle-slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: 0.2s; border-radius: 50%; }
.toggle-switch input:checked + .toggle-slider { background-color: #3b82f6; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }

/* ============================================================
   SLA scadenza change highlight
   ============================================================ */
@keyframes sla-highlight {
    0%, 100% { background-color: transparent; }
    25%, 75% { background-color: rgba(245, 158, 11, 0.3); }
}
.sla-scadenza-changed {
    animation: sla-highlight 0.6s ease 3;
    border-radius: 4px;
}

/* ============================================================
   Environment indicators (test / development)
   ============================================================ */

/* Sidebar env line — colored stripe on right edge via ::after, no layout impact */
.sidebar-env-glow-test,
.sidebar-env-glow-dev { position: relative; }
.sidebar-env-glow-test::after,
.sidebar-env-glow-dev::after {
    content: '';
    position: absolute;
    top: 0;
    right: -3px;
    width: 3px;
    height: 100%;
    z-index: 10;
}
.sidebar-env-glow-test::after { background: #ef4444; }
.sidebar-env-glow-dev::after  { background: #f59e0b; }

/* Sidebar header (hamburger + logo) */
.logo-header {
    position: relative;
    overflow: visible !important;
}

/* Env pill badge on header */
.logo-env-pill {
    position: absolute;
    bottom: -3px;
    right: 4px;
    z-index: 20;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 9999px;
    line-height: 1.4;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    animation: env-badge-pulse 2s ease-in-out infinite;
}
.logo-env-pill-test { background: #dc2626; }
.logo-env-pill-dev  { background: #d97706; }

@keyframes env-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}
