/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #3d4f63 #121a24;
}

/* Variabili CSS */
:root {
    --primary: #137fec;
    --background-light: #f6f7f8;
    --background-dark: #101922;
    --foreground-light: #101922;
    --foreground-dark: #f6f7f8;
    --border-light: #e0e5ea;
    --border-dark: #2a3643;
    --muted-light: #6b7a8a;
    --muted-dark: #93a3b4;
    --card-light: #ffffff;
    --card-dark: #18232e;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--foreground-light);
    background-color: var(--background-light);
}

.dark body {
    color: var(--foreground-dark);
    background-color: var(--background-dark);
}

/* ===== Scrollbar globale (sidebar, pagine, overflow) ===== */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: #121a24;
    border-radius: 99px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4a6078 0%, #3a4d60 100%);
    border-radius: 99px;
    border: 2px solid #121a24;
    background-clip: padding-box;
    min-height: 40px;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #137fec 0%, #0f6bc7 100%);
    border: 2px solid #121a24;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:active {
    background: #137fec;
    border: 2px solid #121a24;
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

.sidebar,
.sidebar nav,
.sidebar .overflow-y-auto {
    scrollbar-gutter: stable;
}

/* Rimuove i punti elenco di default e lo spazio interno per tutte le liste */
ul, ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Sicurezza: per nav in sidebar assicurarsi che non ci siano punti o padding residui */
.sidebar nav ul,
.nav ul,
nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ===== Toast (global notifications) ===== */
.edp-toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.edp-toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(24, 35, 46, 0.92);
    color: #f6f7f8;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transform: translateY(8px);
    opacity: 0;
    transition: opacity 160ms ease, transform 160ms ease;
}

.edp-toast.edp-toast--show {
    transform: translateY(0);
    opacity: 1;
}

.edp-toast__title {
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    margin-bottom: 4px;
}

.edp-toast__msg {
    font-size: 13px;
    line-height: 1.35;
    color: rgba(246, 247, 248, 0.92);
}

.edp-toast--success { border-color: rgba(34, 197, 94, 0.35); }
.edp-toast--info { border-color: rgba(59, 130, 246, 0.35); }
.edp-toast--warning { border-color: rgba(245, 158, 11, 0.35); }
.edp-toast--error { border-color: rgba(239, 68, 68, 0.35); }

/* Container e Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.min-h-screen {
    min-height: 100vh;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
    gap: 15px;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-1\.5 {
    gap: 0.375rem;
}

.gap-x-2 {
    column-gap: 0.5rem;
}

.gap-y-1 {
    row-gap: 0.25rem;
}

.gap-y-1\.5 {
    row-gap: 0.375rem;
}

.col-span-2 {
    grid-column: span 2 / span 2;
}

.mt-0\.5 {
    margin-top: 0.125rem;
}

.leading-none {
    line-height: 1;
}

.leading-relaxed {
    line-height: 1.625;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.break-words {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.whitespace-pre-wrap {
    white-space: pre-wrap;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.gap-8 {
    gap: 2rem;
}

.space-y-1 > * + * {
    margin-top: 0.25rem;
}

.space-y-2 > * + * {
    margin-top: 0.5rem;
}

.space-y-6 > * + * {
    margin-top: 1.5rem;
}

/* Grid */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
    .sm\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .sm\:p-8 {
        padding: 2rem;
    }
    .sm\:px-6 {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    .sm\:table-cell {
        display: table-cell;
    }
    .sm\:inline {
        display: inline;
    }
    .sm\:block {
        display: block;
    }
    .sm\:hidden {
        display: none;
    }
}

/* Classi per gestire visibilità responsive nelle tabelle */
.mobile-hidden {
    display: none;
}

@media (min-width: 640px) {
    .mobile-hidden {
        display: table-cell !important;
    }
}

.desktop-hidden {
    display: block;
}

@media (min-width: 640px) {
    .desktop-hidden {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .lg\:px-8 {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Padding e Margin */
.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.p-3 {
    padding: 0.75rem;
}

.p-8 {
    padding: 2rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.px-6 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.mb-1\.5 {
    margin-bottom: 0.375rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-8 {
    margin-top: 2rem;
}

.mt-auto {
    margin-top: auto;
}

.ml-64 {
    margin-left: 16rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.ml-auto {
    margin-left: auto;
}

.mr-1 {
    margin-right: 0.25rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.pt-4 {
    padding-top: 1rem;
}

/* Width e Height */
.w-full {
    width: 100%;
}

.w-6 {
    width: 1.5rem;
}

.w-10 {
    width: 2.5rem;
}

.w-20 {
    width: 5rem;
}

.w-64 {
    width: 16rem;
}

.h-6 {
    height: 1.5rem;
}

.h-8 {
    height: 2rem;
}

.h-10 {
    height: 2.5rem;
}

.h-16 {
    height: 4rem;
}

.h-full {
    height: 100%;
}

.max-w-md {
    max-width: 28rem;
}

.size-10 {
    width: 2.5rem;
    height: 2.5rem;
}

/* Text */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.text-base {
    font-size: 1rem;
    line-height: 1.5rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.text-3xl {
    font-size: 1.875rem;
    line-height: 2.25rem;
}

.text-4xl {
    font-size: 2.25rem;
    line-height: 2.5rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.text-white {
    color: #ffffff;
}

.text-primary {
    color: var(--primary);
}

.text-gray-200 {
    color: #e5e7eb;
}

.text-gray-300 {
    color: #d1d5db;
}

.text-gray-400 {
    color: #9ca3af;
}

.dark .text-muted-light {
    color: var(--muted-dark);
}

.text-muted-light {
    color: var(--muted-light);
}

.text-green-500 {
    color: #10b981;
}

.text-green-400 {
    color: #22c55e;
}

.text-red-500 {
    color: #ef4444;
}

.text-red-400 {
    color: #f87171;
}

.text-red-300 {
    color: #fca5a5;
}

.text-blue-400 {
    color: #60a5fa;
}

.text-yellow-400 {
    color: #fbbf24;
}

.text-yellow-500 {
    color: #eab308;
}

.text-gray-500 {
    color: #6b7280;
}

/* Background colors */
.bg-red-100 {
    background-color: #fee2e2;
}

.bg-red-900\/30 {
    background-color: rgba(127, 29, 29, 0.3);
}

.bg-blue-500\/20 {
    background-color: rgba(59, 130, 246, 0.2);
}

.bg-yellow-500\/20 {
    background-color: rgba(234, 179, 8, 0.2);
}

.bg-green-500\/20 {
    background-color: rgba(34, 197, 94, 0.2);
}

.bg-red-600 {
    background-color: #dc2626;
}

.hover\:bg-red-700:hover {
    background-color: #b91c1c;
}

.bg-gray-800 {
    background-color: #1f2937;
}

.bg-gray-800\/30 {
    background-color: rgba(31, 41, 55, 0.3);
}

.bg-gray-700 {
    background-color: #374151;
}

.bg-gray-700\/30 {
    background-color: rgba(55, 65, 81, 0.3);
}

.bg-gray-700\/20 {
    background-color: rgba(55, 65, 81, 0.2);
}

.bg-gray-600\/30 {
    background-color: rgba(75, 85, 99, 0.3);
}

/* Background */
.dark .bg-background-light {
    background-color: var(--background-dark);
}

.bg-background-light {
    background-color: var(--background-light);
}

.bg-background-dark {
    background-color: var(--background-dark);
}

.dark .bg-card-light {
    background-color: var(--card-dark);
}

.bg-card-light {
    background-color: var(--card-light);
}

.bg-card-dark {
    background-color: var(--card-dark);
}

.bg-card-dark\/50 {
    background-color: rgba(26, 36, 46, 0.5);
}

.bg-primary {
    background-color: var(--primary);
}

.bg-primary\/20 {
    background-color: rgba(19, 127, 236, 0.2);
}

.bg-primary\/30 {
    background-color: rgba(19, 127, 236, 0.3);
}

.bg-cover {
    background-size: cover;
}

.bg-center {
    background-position: center;
}

/* Border */
.border {
    border-width: 1px;
}

.border-b {
    border-bottom-width: 1px;
}

.border-r {
    border-right-width: 1px;
}

.border-t {
    border-top-width: 1px;
}

.dark .border-border-light {
    border-color: var(--border-dark);
}

.border-border-light {
    border-color: var(--border-light);
}

.border-gray-800 {
    border-color: #1f2937;
}

.border-gray-700 {
    border-color: #374151;
}

.border-gray-600\/30 {
    border-color: rgba(75, 85, 99, 0.3);
}

.border-red-400 {
    border-color: #f87171;
}

.border-red-700 {
    border-color: #b91c1c;
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-full {
    border-radius: 9999px;
    height: 10px;
    width: 10px;
    padding: 20px;
}

.rounded-t-lg {
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

/* Shadow */
.shadow-sm {
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* Form Elements */
input[type="text"],
input[type="email"],
input[type="password"],
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background-color: var(--background-light);
    color: var(--foreground-light);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dark input[type="text"],
.dark input[type="email"],
.dark input[type="password"],
.dark .form-input {
    border-color: var(--border-dark);
    background-color: var(--background-dark);
    color: var(--foreground-dark);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

input::placeholder,
.form-input::placeholder {
    color: var(--muted-light);
}

.dark input::placeholder,
.dark .form-input::placeholder {
    color: var(--muted-dark);
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--foreground-light);
}

.dark label {
    color: var(--foreground-dark);
}

/* Button */
button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    padding: 0.75rem 1.5rem !important;
    font-size: 0.875rem;
    font-weight: 600;
    color: white !important;
    background: linear-gradient(135deg, #137fec 0%, #0d6ecc 100%) !important;
    border: none !important;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(19, 127, 236, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0d6ecc 0%, #0a5cb8 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(19, 127, 236, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(19, 127, 236, 0.25);
}

/* Links */
a {
    color: inherit;
    text-decoration: none;
}

a.text-primary {
    color: var(--primary);
}

a.text-primary:hover {
    text-decoration: underline;
}

/* Sidebar: niente sottolineatura (anche su text-primary attivo/hover) */
.sidebar a,
.sidebar a:hover,
.sidebar a.text-primary,
.sidebar a.text-primary:hover {
    text-decoration: none !important;
}

a.hover\:text-primary:hover {
    color: var(--primary);
}

a.hover\:bg-primary\/20:hover {
    background-color: rgba(19, 127, 236, 0.2);
}

/* Sidebar */
.sidebar {
    background-color: var(--card-dark);
    border-right: 1px solid #1f2937;
    width: 16rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    color: var(--primary);
    height: 2rem;
    width: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    color: #9ca3af;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: rgba(19, 127, 236, 0.2);
    color: var(--primary);
}

.nav-link.active {
    background-color: rgba(19, 127, 236, 0.2);
    color: var(--primary);
    font-weight: 500;
}

/* Header */
.header {
    background-color: rgba(26, 36, 46, 0.5);
    border-bottom: 1px solid #1f2937;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
    height: 4rem;
    display: flex;
    align-items: center;
    /* Padding orizzontale gestito dalle utility px-* nelle pagine.
       Qui lasciamo solo safe-area per evitare “titoli troppo a destra”. */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: 0;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    backdrop-filter: blur(8px);
}

@media (min-width: 640px) {
    .header {
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

/* Cards */
.card {
    background-color: var(--card-dark);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* Flex utilities */
.flex-1 {
    flex: 1 1 0%;
}

.flex-grow {
    flex-grow: 1;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

.min-w-0 {
    min-width: 0;
}

/* Position */
.fixed {
    position: fixed;
}

.sticky {
    position: sticky;
}

.inset-y-0 {
    top: 0;
    bottom: 0;
}

.left-0 {
    left: 0;
}

.top-0 {
    top: 0;
}

.z-10 {
    z-index: 10;
}

.z-40 {
    z-index: 40;
}

/* Transition */
.transition-colors {
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-opacity {
    transition-property: opacity;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.hover\:opacity-90:hover {
    opacity: 0.9;
}

.backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

/* Material Icons */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}

/* Object Fit */
.object-cover {
    object-fit: cover;
}

/* Container responsive */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* Items end */
.items-end {
    align-items: flex-end;
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: var(--card-dark);
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.3);
    max-width: 600px;
    width: 100%;
    z-index: 1001;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #2a3643;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.modal-header button:not(.btn-primary):not(.btn-secondary) {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s;
    padding: 0;
}

.modal-header button:not(.btn-primary):not(.btn-secondary):hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.modal-body {
    padding: 1.5rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #2a3643;
    background-color: rgba(16, 25, 34, 0.5);
}

/* Badge Styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.badge-high {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge-medium {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.badge-low {
    background-color: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.badge-open {
    background-color: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.badge-progress {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.badge-closed {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--background-dark);
}

th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
}

tbody tr {
    border-bottom: 1px solid #2a3643;
}

tbody tr:hover {
    background-color: var(--background-dark);
}

.divide-y > * + * {
    border-top: 1px solid #2a3643;
}

/* Overflow */
.overflow-x-auto {
    overflow-x: auto;
}

.overflow-y-auto {
    overflow-y: auto;
}

.overflow-hidden {
    overflow: hidden;
}

/* Button Secondary */
.btn-secondary {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #9ca3af;
    background-color: transparent;
    border: 1px solid #2a3643;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background-color: rgba(19, 127, 236, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* Button utilities */
.w-full {
    width: 100%;
}

/* Select Styles */
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background-color: var(--background-light);
    color: var(--foreground-light);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dark select {
    border-color: var(--border-dark);
    background-color: var(--background-dark);
    color: var(--foreground-dark);
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

.calendar-technician-filter-wrap {
    display: flex;
    align-items: center;
}

.calendar-technician-filter {
    height: 36px;
    max-width: 220px;
    padding: 0 10px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-dark);
    background-color: var(--background-dark);
    color: var(--foreground-dark);
    font-size: 0.75rem;
    cursor: pointer;
}

.calendar-technician-filter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.15);
}

@media (min-width: 640px) {
    .calendar-technician-filter {
        height: 38px;
        font-size: 0.8125rem;
        max-width: 240px;
    }
}

/* Textarea Styles */
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background-color: var(--background-light);
    color: var(--foreground-light);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
}

.dark textarea {
    border-color: var(--border-dark);
    background-color: var(--background-dark);
    color: var(--foreground-dark);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

textarea::placeholder {
    color: var(--muted-light);
}

.dark textarea::placeholder {
    color: var(--muted-dark);
}

/* Uppercase */
.uppercase {
    text-transform: uppercase;
}

/* Letter Spacing */
.tracking-wide {
    letter-spacing: 0.025em;
}

.tracking-wider {
    letter-spacing: 0.05em;
}

/* Justify End */
.justify-end {
    justify-content: flex-end;
}

/* Utilities */
.align-middle {
    vertical-align: middle;
}

.inline-block {
    display: inline-block;
}

/* Max height */
.max-h-90vh {
    max-height: 90vh;
}

/* Animazioni */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Transizioni smooth per i commenti */
#commentsContainer > div {
    transition: all 0.2s ease;
    margin: 10px 0;
}

/* Hover effect per commenti */
.group:hover .group-hover\:opacity-100 {
    opacity: 1;
}

/* Focus ring per textarea in modifica */
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Stili per il container di modifica commento */
.edit-comment-container {
    background: rgba(31, 41, 55, 0.3);
    border: 1px solid rgba(59, 130, 246, 0.3);
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Comment Button Styles */
.comment-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-width: 1px;
    background-color: rgba(42, 54, 67, 0.3);
    color: #93a3b4;
    border-color: rgba(42, 54, 67, 0.5);
}

.comment-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    background-color: rgba(42, 54, 67, 0.5);
    color: #f6f7f8;
}

.comment-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Comment Button - Edit Variant (Blue) */
.comment-btn.bg-blue-600\/10 {
    background-color: rgba(37, 99, 235, 0.1);
    color: #60a5fa;
    border-color: rgba(37, 99, 235, 0.2);
}

.comment-btn.bg-blue-600\/10:hover {
    background-color: rgba(37, 99, 235, 0.2);
    color: #93c5fd;
}

/* Comment Button - Delete Variant (Red) */
.comment-btn.bg-red-600\/10 {
    background-color: rgba(220, 38, 38, 0.1);
    color: #f87171;
    border-color: rgba(220, 38, 38, 0.2);
}

.comment-btn.bg-red-600\/10:hover {
    background-color: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

/* Comment Button Icon Size */
.comment-btn .material-symbols-outlined {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Comment Submit/Cancel Button Styles */
.comment-btn-sub {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
}

.comment-btn-sub:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.comment-btn-sub:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.comment-btn-sub:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Comment Button - Cancel Variant (Gray) */
.comment-btn-sub.bg-gray-600\/20 {
    background-color: rgba(75, 85, 99, 0.2);
    color: #d1d5db;
    border: 1px solid rgba(75, 85, 99, 0.3);
}

.comment-btn-sub.bg-gray-600\/20:hover {
    background-color: rgba(75, 85, 99, 0.3);
    color: #ffffff;
}

/* Comment Button - Submit Variant (Blue) */
.comment-btn-sub.bg-blue-600 {
    background-color: #2563eb;
    color: #ffffff;
}

.comment-btn-sub.bg-blue-600:hover {
    background-color: #1d4ed8;
}

.comment-btn-sub.bg-blue-600:active {
    background-color: #1e40af;
}

/* Comment Button Icon Size for submit buttons */
.comment-btn-sub .material-symbols-outlined {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Opacity Utilities */
.opacity-50 {
    opacity: 0.5;
}

.opacity-100 {
    opacity: 1;
}

/* Cursor Utilities */
.cursor-not-allowed {
    cursor: not-allowed !important;
}

.cursor-pointer {
    cursor: pointer;
}

/* Disabled Button Styles */
button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover,
.btn-primary:disabled:hover,
.btn-secondary:disabled:disabled:hover {
    opacity: 0.5;
    transform: none;
}

/* Assignment Dropdown Styles */
#assignedToHeaderContainer {
    position: relative;
}

#assignDropdownContainer {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animazione per riga inline dei ticket (comparsa elegante) */
tr[data-inline-for] {
    animation: slideDown 0.18s ease-out;
}

#toggleAssignBtn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

#toggleAssignBtn:hover {
    opacity: 1;
}

/* Dropdown priorità */
#priorityHeaderContainer {
    position: relative;
}

#priorityDropdownContainer {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

#togglePriorityBtn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

#togglePriorityBtn:hover {
    opacity: 1;
}

/* Dropdown stato */
#statusHeaderContainer {
    position: relative;
}

#statusDropdownContainer {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

#toggleStatusBtn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

#toggleStatusBtn:hover {
    opacity: 1;
}

/* Dropdown tipo */
#typeHeaderContainer {
    position: relative;
}

#typeDropdownContainer {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

#toggleTypeBtn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

#toggleTypeBtn:hover {
    opacity: 1;
}

/* Relative positioning utility */
.relative {
    position: relative;
}

/* ============== TAB NAVIGATION (Settings Page) ============== */

/* Tab buttons */
.tab-button {
    background: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
    padding: 20px;
}

.tab-button:hover {
    background-color: rgba(19, 127, 236, 0.05);
}

.tab-button.active,
.tab-button:focus {
    outline: none;
}

/* Tab content */
.tab-content {
    animation: fadeIn 0.3s ease-in;
}

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

/* Hidden class for tabs */
.hidden {
    display: none !important;
}

/* ============== PAGINATION STYLES ============== */

/* Pagination container */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding: 1rem 1.5rem;
    background-color: rgba(42, 54, 67, 0.3);
    border-radius: 0.5rem;
    border-top: 1px solid rgba(107, 114, 128, 0.2);
}

.pagination-container .flex {
    display: flex;
    align-items: center;
}

.pagination-container .gap-1 {
    gap: 0.25rem;
}

.pagination-container .gap-2 {
    gap: 0.5rem;
}

/* Pagination buttons */
.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #ffffff;
    background-color: #374151;
    border: 1px solid #4b5563;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-width: 2.5rem;
    height: 2.5rem;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #4b5563;
    border-color: #6b7280;
    color: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pagination-btn:disabled {
    background-color: #374151;
    color: #6b7280;
    cursor: not-allowed;
    opacity: 0.5;
    border-color: #4b5563;
}

.pagination-btn:disabled:hover {
    transform: none;
    box-shadow: none;
    background-color: #374151;
    color: #6b7280;
}

/* Active pagination button (current page) */
.pagination-btn.active,
.pagination-btn.bg-primary {
    background: linear-gradient(135deg, #137fec 0%, #0d6ecc 100%);
    border-color: #137fec;
    color: #ffffff;
    font-weight: 600;
}

.pagination-btn.active:hover,
.pagination-btn.bg-primary:hover {
    background: linear-gradient(135deg, #0d6ecc 0%, #0a5cb8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(19, 127, 236, 0.3);
}

/* Pagination ellipsis */
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: #6b7280;
    font-size: 0.875rem;
    user-select: none;
}

/* Page size selector */
.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #9ca3af;
    font-size: 0.875rem;
}

.page-size-selector select {
    background-color: var(--background-dark);
    border: 1px solid #4b5563;
    border-radius: 0.375rem;
    color: #ffffff;
    font-size: 0.875rem;
    padding: 0.375rem 0.5rem;
    cursor: pointer;
}

.page-size-selector select:hover {
    border-color: #6b7280;
}

.page-size-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(19, 127, 236, 0.2);
}

/* Pagination info text */
.pagination-info {
    color: #9ca3af;
    font-size: 0.875rem;
    margin: 0;
}

/* Navigation buttons (Previous/Next) */
.pagination-nav {
    background-color: #374151;
    color: #d1d5db;
    border: 1px solid #4b5563;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.pagination-nav:hover:not(:disabled) {
    background-color: #4b5563;
    color: #ffffff;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .pagination-container > div {
        justify-content: center;
    }
    
    .pagination-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        min-width: 2rem;
        height: 2rem;
    }
    
    .page-size-selector {
        justify-content: center;
    }
    
    /* Hide some page numbers on mobile */
    .pagination-btn:not(.active):not(.pagination-nav):nth-child(n+6) {
        display: none;
    }
}

/* Search and filter styles for pagination pages */
.search-filters {
    background-color: var(--background-dark);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.search-filters .flex-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.search-filters .flex-1 {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.search-filters label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

.search-filters input[type="text"] {
    width: 100%;
    background-color: var(--background-dark);
    border: 1px solid #4b5563;
    border-radius: 0.5rem;
    color: #ffffff;
    padding: 0.625rem 1rem;
    padding-right: 3rem;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-filters input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

.search-filters input[type="text"]::placeholder {
    color: #6b7280;
}

.search-filters .relative {
    position: relative;
}

.search-filters .absolute {
    position: absolute;
}

.search-filters .right-2 {
    right: 0.5rem;
}

.search-filters .top-2 {
    top: 50%;
    transform: translateY(-50%);
}

.search-filters button.absolute {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.search-filters button.absolute:hover {
    color: var(--primary);
    background-color: rgba(19, 127, 236, 0.1);
}

/* Global positioning utilities (used in settings.php) */
.absolute {
    position: absolute;
}

.right-2 {
    right: 0.5rem;
}

.top-2 {
    top: 50%;
    transform: translateY(-50%);
}

/* Search icon button inside inputs */
.search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: color 0.15s, background-color 0.15s, transform 0.15s;
}

.search-btn:hover {
    color: #ffffff;
    background-color: rgba(19, 127, 236, 0.08);
    transform: translateY(-1px);
}

.search-btn .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}

/* Reset / clear search button */
.reset-btn {
    min-width: 9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: #4b5563;
    color: #ffffff;
    border: 1px solid #4b5563;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
}

.reset-btn:hover {
    background-color: #374151;
}

/* Filter select styling */
.search-filters select {
    background-color: var(--background-dark);
    border: 1px solid #4b5563;
    border-radius: 0.5rem;
    color: #ffffff;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 150px;
}

.search-filters select:hover {
    border-color: #6b7280;
}

.search-filters select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(19, 127, 236, 0.2);
}

/* Reset filters button */
.search-filters .bg-gray-600 {
    background-color: #4b5563;
    color: #ffffff;
    border: 1px solid #6b7280;
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.search-filters .bg-gray-600:hover {
    background-color: #374151;
    border-color: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-filters .bg-gray-600:active {
    transform: translateY(0);
}

/* Utility classes for pagination */
.flex-wrap {
    flex-wrap: wrap;
}

.min-w-64 {
    min-width: 16rem;
}

.bg-background {
    background-color: var(--background-dark);
}

.border-gray-600 {
    border-color: #4b5563;
}

.rounded {
    border-radius: 0.25rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.px-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Block display */
.block {
    display: block;
}

/* Label styling in filters */
.search-filters > div > div > label,
.bg-background-dark label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

/* Responsive adjustments for search filters */
@media (max-width: 768px) {
    .search-filters .flex-wrap {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-filters .flex-1 {
        min-width: 100%;
        max-width: 100%;
    }
    
    .search-filters select,
    .search-filters .bg-gray-600 {
        width: 100%;
    }
}

/* ============== FORM ELEMENTS ============== */

/* Checkbox styling */
.form-checkbox {
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 0.25rem;
    border: 1px solid #2a3643;
    background-color: #101922;
    cursor: pointer;
    transition: all 0.2s;
}

.form-checkbox:checked {
    background-color: #137fec;
    border-color: #137fec;
}

.form-checkbox:hover {
    border-color: #137fec;
}

.form-checkbox:focus {
    outline: none;
    border-color: #137fec;
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

/* Tom Select integration - dark theme overrides */
/* Wrapper input */
.ts-control {
    background-color: var(--background-dark) !important;
    border: 1px solid var(--border-dark) !important;
    color: var(--foreground-dark) !important;
    border-radius: 0.5rem !important;
    padding: 0.45rem 0.75rem !important;
    min-height: 2.5rem;
}

.ts-control .item {
    background: rgba(59,130,246,0.08);
    color: #dbeafe;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    margin-right: 0.35rem;
}

.ts-control input {
    background: transparent !important;
    color: var(--foreground-dark) !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
}

/* Dropdown menu */
.ts-dropdown {
    background-color: var(--card-dark) !important;
    border: 1px solid #26343f !important;
    color: var(--foreground-dark) !important;
    box-shadow: 0 8px 24px rgba(2,6,23,0.6) !important;
    border-radius: 0.5rem !important;
    overflow: hidden;
}

.ts-dropdown .ts-dropdown-content {
    max-height: 240px;
    overflow: auto;
}

.ts-dropdown .ts-result,
.ts-dropdown .ts-option,
.ts-dropdown .option {
    padding: 0.6rem 0.75rem !important;
    border-bottom: 1px solid rgba(42,54,67,0.06);
    cursor: pointer;
    color: #e5e7eb !important;
    background: transparent !important;
}

.ts-dropdown .ts-result:hover,
.ts-dropdown .ts-option:hover,
.ts-dropdown .ts-result.ts-highlighted,
.ts-dropdown .ts-option.ts-highlighted,
.ts-dropdown .option:hover,
.ts-dropdown .option.active,
.ts-dropdown .active {
    background-color: rgba(19,127,236,0.28) !important;
    color: #ffffff !important;
}

.ts-control:focus-within {
    box-shadow: 0 0 0 3px rgba(19,127,236,0.12) !important;
    border-color: var(--primary) !important;
}

/* Small devices - make select inputs taller and full width */
@media (max-width: 640px) {
    .ts-control {
        padding: 0.6rem 0.8rem !important;
    }
    
    /* FORZA: Previeni completamente scroll orizzontale */
    body {
        overflow-x: hidden !important;
    }
    
    * {
        max-width: 100vw;
    }
    
    /* Disabilita overflow-x-auto su mobile */
    .overflow-x-auto {
        overflow-x: visible !important;
        overflow: visible !important;
    }
    
    /* Tabelle: forza a stare dentro lo schermo */
    table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: auto !important;
        display: table !important;
    }
    
    table td,
    table th {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        white-space: normal !important;
    }
    
    /* Contenuto espanso inline */
    tr[data-inline-for] td {
        overflow: visible !important;
        max-width: 100vw !important;
    }
    
    tr[data-inline-for] td > div {
        max-width: calc(100vw - 2rem) !important;
        overflow: hidden !important;
    }
}

/* Ensure native select (fallback) matches style */
select.ts-native {
    background-color: var(--background-dark);
    color: var(--foreground-dark);
    border: 1px solid var(--border-dark);
}

/* Highlight per la slot oraria corrente (FullCalendar) */
.fc-current-slot-highlight {
    background-color: rgba(19,127,236,0.08) !important;
    border-left: 3px solid rgba(19,127,236,0.22) !important;
}

/* Color picker styling */
input[type="color"] {
    border: 1px solid #2a3643;
    background-color: #101922;
    cursor: pointer;
    transition: border-color 0.2s;
}

input[type="color"]:hover {
    border-color: #137fec;
}

input[type="color"]:focus {
    outline: none;
    border-color: #137fec;
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* ============== MOBILE FIRST - BASE STYLES ============== */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: relative;
    z-index: 50;
    background-color: transparent;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background-color: rgba(19, 127, 236, 0.1);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--foreground-dark);
    display: block;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ============== TABLET (max-width: 1024px) ============== */
@media (max-width: 1024px) {
    
    /* Layout adjustments */
    .container {
        padding: 0 1rem;
    }
    
    /* Grid adjustments */
    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Modal specific grids - sempre una colonna */
    .modal .grid,
    .modal .grid-cols-2,
    .modal .grid-cols-3,
    .modal .grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    /* Text sizing */
    .text-2xl {
        font-size: 1.375rem;
        line-height: 1.875rem;
    }
    
    .text-xl {
        font-size: 1.125rem;
        line-height: 1.625rem;
    }
    
    /* Cards */
    .card {
        padding: 1rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        max-width: 90%;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* ============== MOBILE (max-width: 768px) ============== */
@media (max-width: 768px) {
    
    /* Utility: Hide on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-overlay {
        display: block;
    }
    
    /* Sidebar adjustments */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: none;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }
    
    /* Main content - no left margin on mobile */
    .ml-64 {
        margin-left: 0;
    }
    
    /* Main content container - ridotto padding su mobile */
    main.flex-grow {
        padding: 0.5rem !important;
    }
    
    /* Container mx-auto - ridotto padding */
    main .container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Header adjustments */
    .header {
        padding-left: 1rem;
        padding-right: 1rem;
        height: 3.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: nowrap;
    }

    /* Quando il toggle viene inserito via JS come primo figlio,
       evita che `justify-between` spinga il titolo a destra. */
    header.has-mobile-toggle {
        justify-content: flex-start !important;
    }

    /* Il blocco subito dopo l'hamburger “occupa” lo spazio e mantiene le azioni a destra */
    header.has-mobile-toggle > .mobile-menu-toggle + * {
        margin-right: auto;
    }
    
    .header h1,
    .header h2 {
        font-size: 1.125rem;
        line-height: 1.5rem;
        flex-shrink: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Header buttons and controls - make them compact */
    .header button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .header button span:not(.material-symbols-outlined) {
        display: none; /* Nascondi il testo dei pulsanti, mostra solo icone */
    }

    /* Mostra la label del toggle specifico (toggleShowAllBtn) su mobile
       perché viene nascosta dalla regola generale sopra */
    #toggleShowAllBtn span {
        display: inline-block !important;
    }

    /* Stile compatto per il bottone nel header (mobile) */
    #toggleShowAllBtn {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.35rem 0.6rem;
        border-radius: 0.5rem;
        background-color: rgba(19,127,236,0.12);
        border: 1px solid rgba(19,127,236,0.18);
        color: var(--primary);
    }
    
    .header select {
        font-size: 0.875rem;
        padding: 0.375rem 0.5rem;
    }
    
    .header .flex.gap-4 {
        gap: 0.5rem;
    }
    
    /* Nascondi elementi secondari dell'header */
    .header .text-sm:not(.material-symbols-outlined) {
        display: none;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Charts container */
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    /* Filters and search sections */
    .bg-card-dark .flex.flex-col,
    .bg-card-dark .flex.sm\\:flex-row {
        flex-direction: column !important;
    }
    
    .bg-card-dark select,
    .bg-card-dark input[type="text"],
    .bg-card-dark input[type="search"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Compact cards */
    .bg-card-dark {
        padding: 1rem;
    }
    
    /* Table responsive wrapper */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Non usare margini negativi su mobile per evitare overflow della pagina */
        margin: 0;
        padding: 0;
    }
    
    table {
        min-width: 100%;
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.75rem 0.5rem;
        /* Allow content to wrap so rows don't force horizontal scroll on small screens */
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    
    /* Allow text wrap in subject column */
    table td:nth-child(2) {
        white-space: normal;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Compact badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
        white-space: nowrap;
    }
    
    /* Show limited columns on mobile for better readability */
    /* Hide columns 4, 5, 6 on mobile (usually priority, client, date, etc.) */
    table thead th:nth-child(4),
    table tbody td:nth-child(4),
    table thead th:nth-child(5),
    table tbody td:nth-child(5) {
        display: none;
    }
    
    /* Alternative: Make table scrollable horizontally (disabled on mobile by forcing full width)
       Avoid forcing a minimum width which causes horizontal scrolling on small devices */
    .overflow-x-auto table {
        min-width: 0;
        width: 100%;
    }
    
    /* Card-style table for mobile (optional) */
    table.mobile-card {
        min-width: 100%;
    }
    
    table.mobile-card thead {
        display: none;
    }
    
    table.mobile-card tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-dark);
        border-radius: 0.5rem;
        padding: 1rem;
    }
    
    table.mobile-card tbody td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
    }
    
    table.mobile-card tbody td::before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        color: var(--muted-dark);
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    /* Stack form elements */
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100% !important;
    }
    
    /* Filter sections - full width elements */
    .flex-1 {
        width: 100%;
    }
    
    .flex-1 input,
    .flex-1 select {
        width: 100% !important;
    }
    
    /* Select dropdowns full width */
    select {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Input fields full width */
    input[type="text"],
    input[type="search"],
    input[type="email"] {
        width: 100% !important;
    }
    
    /* Button groups */
    .button-group {
        flex-direction: column;
    }
    
    .button-group button {
        width: 100%;
    }
    
    /* Modal full screen on mobile */
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 1rem 1rem 0 0;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background-color: var(--card-dark);
        z-index: 10;
        border-bottom: 1px solid var(--border-dark);
    }
    
    .modal-header h3 {
        font-size: 1.125rem;
    }
    
    .modal-body {
        padding: 1rem;
        font-size: 0.875rem;
    }
    
    .modal-body .form-group {
        margin-bottom: 1rem;
    }
    
    .modal-body label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }
    
    .modal-body input,
    .modal-body select,
    .modal-body textarea {
        font-size: 1rem; /* Previene zoom su iOS */
        padding: 0.625rem;
    }
    
    .modal-body textarea {
        min-height: 100px;
        max-height: 200px;
    }
    
    .modal-footer {
        padding: 1rem;
        position: sticky;
        bottom: 0;
        background-color: var(--card-dark);
        border-top: 1px solid var(--border-dark);
        flex-direction: column-reverse;
        gap: 0.5rem;
        z-index: 10; /* Ensure it stays above scrolling content */
    }
    
    .modal-footer button {
        width: 100%;
        padding: 0.75rem;
    }
    
    /* Ticket cards */
    .ticket-card {
        margin: 0 -0.5rem;
    }
    
    /* Calendar adjustments */
    .fc-toolbar {
        flex-direction: column !important;
        gap: 0.75rem;
    }
    
    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
    
    /* FullCalendar header controls */
    .fc-toolbar-title {
        font-size: 1rem !important;
    }
    
    .fc-button {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Priority and status badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Header action buttons - compact version */
    .header .btn-primary,
    .header .btn-secondary {
        min-width: auto;
        padding: 0.5rem;
    }
    
    /* Show only icons in header buttons on mobile */
    .header .btn-primary span:not(.material-symbols-outlined),
    .header .btn-secondary span:not(.material-symbols-outlined) {
        display: none;
    }
    
    /* Keep icons visible */
    .header .material-symbols-outlined {
        display: inline-block !important;
        margin: 0 !important;
    }
    
    /* Header select dropdowns - make compact */
    .header select {
        max-width: 120px;
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    /* Header legends and info boxes */
    .header .flex.items-center.gap-2:not(:has(button)) {
        display: none; /* Hide info boxes but keep button containers */
    }
    
    /* Filter section on ticket page */
    #searchTicket {
        font-size: 0.875rem;
    }
    
    .header + main .bg-card-dark:first-child {
        padding: 1rem;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        position: fixed;
        left: 1rem;
        right: 1rem;
        width: auto;
    }
    
    /* Empty state messages */
    .text-center.py-8,
    .text-center.p-8 {
        padding: 2rem 1rem !important;
    }
    
    .text-center .material-symbols-outlined {
        font-size: 48px !important;
    }
    
    .text-center p {
        font-size: 0.875rem;
    }
    
    /* Settings page tabs */
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
        white-space: nowrap;
        min-width: auto;
    }
    
    .tab-button .flex {
        flex-direction: column;
        gap: 0.25rem;
        align-items: center;
    }
    
    .tab-button .material-symbols-outlined {
        font-size: 20px !important;
    }
    
    .tab-button span:last-child {
        font-size: 0.7rem;
        text-align: center;
        line-height: 1.2;
    }
    
    /* Tab navigation scrollable */
    nav.flex {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    nav.flex::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }

    /* ============== CALENDAR MOBILE OPTIMIZATIONS ============== */
    
    /* Forza il container principale a utilizzare tutto lo spazio */
    body.font-display {
        overflow-x: hidden;
    }
    
    /* Container calendario: rimuovi padding extra su mobile */
    .bg-card-dark {
        padding: 0.5rem !important;
        margin: 0 !important;
    }
    
    /* Calendario: usa tutto lo spazio disponibile */
    #calendar.calendar-mobile-optimized {
        min-height: calc(100vh - 200px);
        height: calc(100vh - 200px);
        overflow: visible;
        width: 100%;
    }
    
    /* FullCalendar: forza rendering corretto su mobile */
    .calendar-mobile-optimized .fc {
        height: 100% !important;
        width: 100%;
    }
    
    .calendar-mobile-optimized .fc-view-harness {
        height: 100% !important;
        min-height: calc(100vh - 240px);
    }
    
    .calendar-mobile-optimized .fc-view {
        height: 100% !important;
    }
    
    /* Legenda tecnici più compatta */
    #techniciansLegend > div {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.7rem !important;
    }
    
    #techniciansLegend .text-xs {
        font-size: 0.65rem !important;
    }
    
    /* FullCalendar mobile adjustments */
    .calendar-mobile-optimized .fc-header-toolbar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
        margin-bottom: 0.5rem !important;
        padding: 0 !important;
    }
    
    .calendar-mobile-optimized .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        width: 100%;
        margin: 0 !important;
        flex: 1 1 auto;
    }
    
    .calendar-mobile-optimized .fc-toolbar-title {
        font-size: 0.95rem !important;
        margin: 0 !important;
        padding: 0.25rem 0 !important;
    }
    
    .calendar-mobile-optimized .fc-button {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.75rem !important;
        line-height: 1 !important;
    }
    
    .calendar-mobile-optimized .fc-button .fc-icon {
        font-size: 1rem !important;
    }
    
    /* Eventi più compatti su mobile */
    .calendar-mobile-optimized .fc-event {
        font-size: 0.7rem !important;
        padding: 2px 3px !important;
        margin-bottom: 1px !important;
    }
    
    .calendar-mobile-optimized .fc-event-title {
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .calendar-mobile-optimized .fc-event-time {
        font-weight: 600;
        display: block;
    }
    
    .calendar-mobile-optimized .fc-timegrid-slot {
        height: 2.5rem !important;
    }
    
    .calendar-mobile-optimized .fc-timegrid-slot-label {
        font-size: 0.7rem !important;
        padding: 0 0.25rem !important;
    }
    
    .calendar-mobile-optimized .fc-col-header-cell-cushion {
        padding: 0.375rem 0.25rem !important;
        font-size: 0.7rem !important;
    }
    
    .calendar-mobile-optimized .fc-daygrid-day-number {
        font-size: 0.8rem !important;
        padding: 0.25rem !important;
    }
}

/* ============== SMALL MOBILE (max-width: 480px) ============== */
@media (max-width: 480px) {
    
    /* Container tighter padding */
    .container {
        padding: 0 0.75rem;
    }
    
    main {
        padding: 1rem 0.75rem !important;
    }
    
    .px-4,
    .px-6,
    .px-8 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .py-8 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    /* Header */
    .header {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        height: 3.5rem;
    }
    
    .header h1,
    .header h2 {
        font-size: 1rem;
        line-height: 1.25rem;
    }
    
    /* Mobile menu toggle smaller */
    .mobile-menu-toggle {
        padding: 0.375rem;
        margin-right: 0.5rem;
    }
    
    .mobile-menu-toggle svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Header buttons even more compact */
    .header button {
        padding: 0.375rem;
    }
    
    .header select {
        max-width: 100px;
        font-size: 0.7rem;
        padding: 0.25rem 0.375rem;
    }
    
    /* Completely hide text in all header buttons */
    .header button > span:not(.material-symbols-outlined) {
        display: none !important;
    }
    
    .header .material-symbols-outlined {
        font-size: 20px !important;
    }
    
    /* Single column for all grids */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    /* Text sizing */
    .text-2xl {
        font-size: 1.25rem;
        line-height: 1.75rem;
    }
    
    .text-xl {
        font-size: 1rem;
        line-height: 1.5rem;
    }
    
    .text-lg {
        font-size: 0.9375rem;
        line-height: 1.375rem;
    }
    
    /* Cards */
    .card {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    /* Buttons */
    .btn,
    .btn-primary,
    .btn-secondary {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Form elements */
    input,
    select,
    textarea {
        font-size: 1rem; /* Prevent zoom on iOS */
    }
    
    /* Table - even more compact */
    table {
        font-size: 0.8125rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
    
    /* Modal adjustments */
    .modal-header h3 {
        font-size: 1.125rem;
    }
    
    .modal-body {
        padding: 1rem 0.75rem;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .modal-body .grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .modal-body .form-group {
        margin-bottom: 0.75rem;
    }
    
    .modal-body label {
        font-size: 0.8125rem;
    }
    
    .modal-body input,
    .modal-body select,
    .modal-body textarea {
        padding: 0.5rem;
        font-size: 1rem;
    }
    
    .modal-body textarea {
        min-height: 80px;
        max-height: 150px;
    }
    
    .modal-footer {
        padding: 0.75rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    .modal-content {
        max-height: 80vh;
    }
    
    /* Sidebar */
    .sidebar {
        width: 85vw;
        max-width: 280px;
    }
    
    /* Tab buttons - even more compact */
    .tab-button {
        padding: 0.625rem 0.375rem;
        min-width: 60px;
    }
    
    .tab-button .material-symbols-outlined {
        font-size: 18px !important;
    }
    
    .tab-button span:last-child {
        font-size: 0.65rem;
    }
    
    /* Spacing adjustments */
    .gap-8 {
        gap: 1rem;
    }
    
    .gap-6 {
        gap: 0.75rem;
    }
    
    .gap-4 {
        gap: 0.5rem;
    }
    
    .gap-2 {
        gap: 0.375rem;
    }
    
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }
    
    .space-y-4 > * + * {
        margin-top: 0.75rem !important;
    }
    
    .space-y-2 > * + * {
        margin-top: 0.5rem !important;
    }
    
    /* Padding adjustments */
    .p-8 {
        padding: 1.5rem;
    }
    
    .p-6 {
        padding: 1rem;
    }
    
    .p-4 {
        padding: 0.75rem;
    }
    
    /* Comments section */
    .comment-item {
        padding: 0.75rem;
    }
    
    .comment-avatar {
        width: 2rem;
        height: 2rem;
    }
    
    /* User avatar */
    .user-avatar {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
    }
    
    /* ============== CALENDAR EXTRA SMALL MOBILE ============== */
    
    /* Nascondi testo bottoni calendario su schermi piccoli */
    .calendar-mobile-optimized .fc-button-group .fc-button {
        padding: 0.375rem !important;
    }
    
    .calendar-mobile-optimized .fc-toolbar-title {
        font-size: 0.875rem !important;
    }
    
    /* Stack toolbar su più righe se necessario */
    .calendar-mobile-optimized .fc-header-toolbar {
        gap: 0.375rem;
    }
    
    /* Nascondi nomi giorni della settimana (mostra solo iniziali) */
    .calendar-mobile-optimized .fc-col-header-cell-cushion {
        font-size: 0.65rem !important;
    }
    
    .calendar-mobile-optimized .fc-timegrid-slot-label {
        font-size: 0.65rem !important;
    }
    
    /* Login page */
    .max-w-md {
        max-width: 100%;
    }
    
    .login-container {
        padding: 1rem;
    }
}

/* ============== LANDSCAPE MOBILE (max-height: 500px) ============== */
@media (max-height: 500px) and (orientation: landscape) {
    
    /* Reduce vertical spacing */
    .py-8 {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    .py-6 {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    /* Sidebar more compact */
    .sidebar {
        padding: 0.75rem;
    }
    
    .nav-link {
        padding: 0.375rem 0.75rem;
    }
    
    /* Header smaller */
    .header {
        height: 3rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        max-height: 95vh;
    }
}

/* ============== TOUCH DEVICE IMPROVEMENTS ============== */
@media (hover: none) and (pointer: coarse) {
    
    /* Larger tap targets */
    button:not(.inline-touch-reset),
    [role="button"]:not(.inline-touch-reset),
    .btn,
    .btn-primary,
    .btn-secondary,
    .nav-link,
    .mobile-menu-toggle,
    .pagination-btn,
    .pagination-nav,
    .tab-button,
    .search-btn,
    .header button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }

    .sidebar .sidebar-nav-summary {
        min-height: 44px;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .header button,
    .mobile-menu-toggle {
        box-sizing: border-box;
    }
    
    /* Remove hover effects on touch devices */
    .nav-link:hover,
    .btn:hover,
    button:hover {
        transform: none;
    }
    
    /* Active states instead of hover */
    .nav-link:active {
        background-color: rgba(19, 127, 236, 0.3);
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    /* Disable backdrop blur on some devices for performance */
    .header {
        backdrop-filter: none;
    }
}

/* ============== PRINT STYLES ============== */
@media print {
    
    /* Hide navigation and controls */
    .sidebar,
    .header,
    .mobile-menu-toggle,
    .btn,
    button,
    .actions {
        display: none !important;
    }
    
    /* Reset margins */
    .ml-64 {
        margin-left: 0;
    }
    
    /* Full width for content */
    .container {
        max-width: 100%;
    }
    
    /* Black text on white background */
    body {
        background: white;
        color: black;
    }
    
    .card {
        border: 1px solid #ccc;
        box-shadow: none;
    }
    
    /* Page breaks */
    .card,
    .ticket-card {
        page-break-inside: avoid;
    }
}

/* ============== ACCESSIBILITY - REDUCED MOTION ============== */
@media (prefers-reduced-motion: reduce) {
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .sidebar {
        transition: none;
    }
    
    .mobile-overlay {
        transition: none;
    }
}

/* ============== HIGH CONTRAST MODE ============== */
@media (prefers-contrast: high) {
    
    button,
    .btn {
        border: 2px solid currentColor;
    }
    
    .nav-link.active {
        border-left: 4px solid var(--primary);
    }
    
    .border {
        border-width: 2px;
    }
}

/* ============== MENTIONS SYSTEM (@utente) ============== */

/* Dropdown delle mentions */
.mentions-dropdown {
    position: absolute;
    background: #0b1220;
    border: 1px solid #2a3643;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    max-height: 240px;
    overflow-y: auto;
    z-index: 10000;
    min-width: 280px;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid rgba(42, 54, 67, 0.5);
}

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

.mention-item:hover,
.mention-item.selected {
    background-color: #1a2533;
}

.mention-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #137fec, #0d5bb3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.mention-item-info {
    flex: 1;
    min-width: 0;
}

.mention-item-name {
    font-weight: 500;
    color: #f6f7f8;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-item-username {
    font-size: 12px;
    color: #93a3b4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Evidenziazione delle mentions nei commenti */
.mention-highlight {
    color: #3b82f6;
    font-weight: 500;
    background-color: rgba(59, 130, 246, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mention-highlight:hover {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* Scrollbar personalizzata per il dropdown */
.mentions-dropdown::-webkit-scrollbar {
    width: 6px;
}

.mentions-dropdown::-webkit-scrollbar-track {
    background: rgba(42, 54, 67, 0.3);
    border-radius: 3px;
}

.mentions-dropdown::-webkit-scrollbar-thumb {
    background: #2a3643;
    border-radius: 3px;
}

.mentions-dropdown::-webkit-scrollbar-thumb:hover {
    background: #3a4653;
}

/* Responsive */
@media (max-width: 640px) {
    .mentions-dropdown {
        min-width: 260px;
        max-height: 200px;
    }
    
    .mention-item {
        padding: 8px 12px;
        gap: 10px;
    }
    
    .mention-item-avatar {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
    
    .mention-item-name {
        font-size: 13px;
    }
    
    .mention-item-username {
        font-size: 11px;
    }
}

/* Sidebar: gruppi collassabili (details/summary) */
.sidebar-nav-group {
    border-radius: 0.5rem;
    border: 1px solid transparent;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.sidebar-nav-group:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.sidebar-nav-group[open] {
    border-color: rgba(99, 102, 241, 0.22);
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar-nav-group + .sidebar-nav-group {
    margin-top: 0.35rem;
}

.sidebar-nav-summary {
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.12);
    touch-action: manipulation;
    user-select: none;
    padding: 0.5rem 0.65rem 0.5rem 0.75rem;
    min-height: 2.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-radius: 0.375rem;
    transition: color 0.18s ease, background-color 0.18s ease;
    outline: none;
}

.sidebar-nav-summary:hover {
    color: #e5e7eb;
    background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-summary:focus-visible {
    color: #f9fafb;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.55);
}

.sidebar-nav-group[open] > .sidebar-nav-summary {
    color: #c7d2fe;
}

.sidebar-nav-summary::-webkit-details-marker {
    display: none;
}

.sidebar-nav-summary::marker {
    content: none;
}

.sidebar-nav-summary::after {
    content: "";
    flex-shrink: 0;
    width: 0.45rem;
    height: 0.45rem;
    margin-top: -0.05rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    opacity: 0.8;
    transform: rotate(-45deg);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
}

.sidebar-nav-group[open] > .sidebar-nav-summary::after {
    transform: rotate(45deg);
    margin-top: 0.1rem;
}

.sidebar-nav-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav-group[open] > .sidebar-nav-panel {
    grid-template-rows: 1fr;
}

.sidebar-nav-panel-inner {
    overflow: hidden;
    min-height: 0;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-nav-panel,
    .sidebar-nav-summary::after,
    .sidebar-nav-group,
    .sidebar-nav-summary {
        transition: none !important;
    }

    .sidebar-nav-group[open] > .sidebar-nav-panel {
        grid-template-rows: 1fr;
    }
}

/* ============== GENERIC COLLAPSE (details/summary) ============== */
.section-collapse {
    border-radius: 0.75rem;
    border: 1px solid rgba(31, 41, 55, 0.9);
    background: rgba(24, 35, 46, 0.92);
    overflow: hidden;
}

.section-collapse-summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    color: #e5e7eb;
}

.section-collapse-summary::-webkit-details-marker {
    display: none;
}

.section-collapse-summary::marker {
    content: none;
}

.section-collapse-summary-main {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.section-collapse-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #9ca3af;
}

.section-collapse-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(71, 85, 105, 0.35);
}

.section-collapse-chevron {
    color: #94a3b8;
    transition: transform 0.2s ease;
}

details.section-collapse[open] .section-collapse-chevron {
    transform: rotate(180deg);
}

.section-collapse-body {
    border-top: 1px solid rgba(31, 41, 55, 0.9);
}

/* ============== ADMIN LIST SEARCH (Clients/Companies panels) ============== */
.admin-list-search {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(
        165deg,
        rgba(26, 36, 48, 0.98) 0%,
        rgba(20, 28, 36, 0.99) 45%,
        var(--card-dark) 100%
    );
    border: 1px solid var(--border-dark);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 18px rgba(0, 0, 0, 0.22);
}

@media (min-width: 640px) {
    .admin-list-search {
        padding: 1.25rem;
    }
}

.admin-list-search-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7280;
}

.admin-list-search-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

@media (min-width: 640px) {
    .admin-list-search-row {
        flex-direction: row;
        align-items: center;
    }
}

.admin-list-search-form {
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
    min-height: 2.75rem;
}

.admin-list-search-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.admin-list-search-actions .reset-btn,
.admin-list-search-actions .admin-list-search-settings {
    width: 100%;
    min-height: 2.75rem;
    box-sizing: border-box;
    justify-content: center;
}

@media (min-width: 640px) {
    .admin-list-search-actions {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        width: auto;
        flex-shrink: 0;
    }

    .admin-list-search-actions .reset-btn,
    .admin-list-search-actions .admin-list-search-settings {
        width: auto;
        min-width: 9.5rem;
    }

    .admin-list-search-actions .admin-list-search-settings {
        min-width: 10.75rem;
    }
}

.admin-list-search-actions .admin-list-search-settings {
    text-decoration: none;
}

.admin-list-search .admin-list-search-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-height: 2.75rem;
    box-sizing: border-box;
    padding: 0.625rem 2.5rem 0.625rem 0.75rem;
    font-size: 1rem;
    line-height: 1.4;
    border-radius: 0.5rem;
    border: 1px solid #4b5563;
    background-color: var(--background-dark);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.admin-list-search .admin-list-search-input::placeholder {
    color: #6b7280;
}

.admin-list-search .admin-list-search-input:focus {
    outline: none;
    border-color: rgba(19, 127, 236, 0.55);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.15);
}

.admin-list-search a.btn-secondary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============== TABLE MOBILE STACK (Settings lists) ============== */
.table-mobile-stack-details {
    border-radius: 0.5rem;
    border: 1px solid var(--border-dark);
    background: rgba(0, 0, 0, 0.18);
}

.table-mobile-stack-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.12);
    touch-action: manipulation;
}

.table-mobile-stack-summary::-webkit-details-marker {
    display: none;
}

.table-mobile-stack-summary::marker {
    content: none;
}

.table-mobile-stack-summary-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
    text-align: left;
}

.table-mobile-stack-body {
    padding: 0 1rem 0.75rem;
    border-top: 1px solid var(--border-dark);
}

.table-mobile-stack-kv {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 0.35rem 0.75rem;
    padding: 0.35rem 0;
    font-size: 0.875rem;
    align-items: start;
}

.table-mobile-stack-kv dt {
    color: #9ca3af;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table-mobile-stack-kv dd {
    margin: 0;
    color: #e5e7eb;
    word-break: break-word;
}

.table-mobile-stack-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.table-mobile-stack-chevron {
    flex-shrink: 0;
    font-size: 1.35rem !important;
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.table-mobile-stack-details[open] .table-mobile-stack-chevron {
    transform: rotate(180deg);
}

@media (max-width: 767px) {
    .overflow-x-auto:has(> table.table-mobile-stack) {
        overflow-x: visible !important;
    }

    .overflow-x-auto > table.table-mobile-stack {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        table-layout: fixed !important;
    }

    .table-mobile-stack > thead.table-thead-desktop-only {
        display: none !important;
    }

    .table-mobile-stack tr.table-mobile-only {
        display: table-row !important;
    }

    .table-mobile-stack tr.table-desktop-only {
        display: none !important;
    }

    .overflow-x-auto > table.table-mobile-stack > tbody > tr > td,
    .overflow-x-auto > table.table-mobile-stack > tbody > tr > th {
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
}

@media (min-width: 768px) {
    .table-mobile-stack > thead.table-thead-desktop-only {
        display: table-header-group !important;
    }

    .table-mobile-stack tr.table-mobile-only {
        display: none !important;
    }

    .table-mobile-stack tr.table-desktop-only {
        display: table-row !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .table-mobile-stack-chevron {
        transition: none !important;
    }
}

/* ============== UTILITIES MISSING (used in templates) ============== */
.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -4px rgba(0, 0, 0, 0.28);
}

.pr-10 {
    padding-right: 2.5rem;
}

.w-11 {
    width: 2.75rem;
}

/* Color utilities used in reports/ticket pages */
.bg-blue-500\/10 { background-color: rgba(59, 130, 246, 0.10); }
.bg-green-500\/10 { background-color: rgba(34, 197, 94, 0.10); }
.bg-yellow-500\/10 { background-color: rgba(234, 179, 8, 0.10); }
.bg-purple-500\/10 { background-color: rgba(168, 85, 247, 0.10); }
.border-blue-500\/30 { border-color: rgba(59, 130, 246, 0.30); }
.border-green-500\/30 { border-color: rgba(34, 197, 94, 0.30); }
.border-yellow-500\/30 { border-color: rgba(234, 179, 8, 0.30); }
.border-purple-500\/30 { border-color: rgba(168, 85, 247, 0.30); }

.bg-gray-600 { background-color: #4b5563; }
.hover\:bg-gray-500:hover { background-color: #6b7280; }

/* Toggle switch (peer) used in email_import.php */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.relative { position: relative; }
.inline-flex { display: inline-flex; }
.cursor-pointer { cursor: pointer; }
.rounded-full { border-radius: 9999px; }

.peer:focus + div {
    outline: none;
    box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.35);
}

.peer + div {
    position: relative;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.peer + div::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.25rem;   /* h-5 */
    height: 1.25rem;  /* w-5 */
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    transition: transform 0.2s ease;
}

.peer:checked + div {
    background-color: #2563eb; /* blue-600 */
}

.peer:checked + div::after {
    transform: translateX(1.25rem);
    border-color: #ffffff;
}
