/* === RESET E BASE === */
:root {
  --primary-color: #4f46e5;
  --primary-color-dark: #4338ca;
  --secondary-color: #6b7280;
  --secondary-color-dark: #4b5563;
  --background-light: #f3f4f6;
  --background-white: #ffffff;
  --text-dark: #1f2937;
  --text-light: #6b7280;
  --border-color: #d1d5db;
  --danger-color: #ef4444;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 88px; /* <-- NUOVA VARIABILE */
  --header-height: 60px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  font-family: 'Inter', sans-serif;
  background-color: var(--background-light);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[v-cloak] { display: none; }

/* === LAYOUT PRINCIPALE === */
.app-layout { display: flex; }
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background-color: var(--background-white);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease-in-out; /* <-- TRANSIZIONE AGGIUNTA */
  flex-shrink: 0;
}
.main-content {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  width: calc(100% - var(--sidebar-width));
  min-width: 0;
  transition: width 0.3s ease-in-out, margin-left 0.3s ease-in-out; /* <-- TRANSIZIONE AGGIUNTA */
}
.header-mobile {
  display: none;
  height: var(--header-height);
  background-color: var(--background-white);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.hamburger-btn, .logout-btn-mobile {
  background: none; border: none; cursor: pointer; padding: 0.5rem; border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
}
.hamburger-btn:hover, .logout-btn-mobile:hover { background-color: var(--background-light); }


/* === NUOVA LOGICA PER SIDEBAR COLLASSABILE === */
.sidebar.is-collapsed {
    width: var(--sidebar-collapsed-width);
}
.sidebar.is-collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}
.sidebar.is-collapsed .sidebar-header-text,
.sidebar.is-collapsed .sidebar-link-text,
.sidebar.is-collapsed .user-profile .name,
.sidebar.is-collapsed .user-profile .email {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar.is-collapsed .sidebar-menu a {
    justify-content: center;
}
.sidebar.is-collapsed .collapse-btn {
    transform: rotate(180deg);
}


/* === RESPONSIVITÀ === */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; z-index: 1000; }
  .sidebar.is-open { transform: translateX(0); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
  .main-content { margin-left: 0 !important; width: 100% !important; padding: 1rem; }
  .header-mobile { display: flex; }
  .sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); z-index: 999;
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease;
  }
  .sidebar-overlay.is-open { opacity: 1; visibility: visible; }
  .collapse-btn { display: none; } /* Nascondi il bottone desktop in visualizzazione mobile */
}

/* === COMPONENTI SIDEBAR === */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
}
.sidebar-header-text, .sidebar-link-text {
    transition: opacity 0.2s ease, width 0.2s ease;
}
.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 99px;
    color: var(--text-light);
    transition: transform 0.3s ease-in-out, color 0.2s ease;
}
.collapse-btn:hover {
    background-color: var(--background-light);
    color: var(--text-dark);
}
.sidebar-menu { padding: 1rem; list-style: none; }
.sidebar-menu a {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
  border-radius: 0.5rem; text-decoration: none; color: var(--text-light);
  font-weight: 500; transition: background-color 0.2s ease, color 0.2s ease;
}
.sidebar-menu a:hover { background-color: var(--background-light); color: var(--text-dark); }
.sidebar-menu a.active { background-color: var(--primary-color); color: white; }
.sidebar-footer { margin-top: auto; padding: 1rem; border-top: 1px solid var(--border-color); }
.user-profile { padding: 0.5rem; transition: opacity 0.2s ease; }
.user-profile .name { font-weight: 600; }
.user-profile .email { font-size: 0.875rem; color: var(--text-light); }

/* === STILI PER TABELLE, FORM, ACCORDION ECC... (INVARIATI) === */
h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.5rem; }
p { color: var(--text-light); }
.view-header {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: center; gap: 1.5rem; margin-bottom: 1.5rem;
}
.card {
  background-color: var(--background-white); border-radius: 0.75rem; padding: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
  margin-bottom: 2rem;
}
.form-grid { display: grid; gap: 1.5rem; }
@media(min-width: 768px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
.form-control { display: flex; flex-direction: column; }
.form-control label { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-dark); }
.form-control .input, .form-control .select {
  width: 100%; height: 2.5rem; padding: 0 0.75rem;
  border: 1px solid var(--border-color); border-radius: 0.5rem;
  background-color: var(--background-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control .input:focus, .form-control .select:focus {
  outline: none; border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 2.5rem; padding: 0 1.5rem; border: 1px solid transparent; border-radius: 0.5rem;
  font-weight: 600; cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-color-dark); }
.btn-secondary {
    background-color: var(--background-white);
    color: var(--text-light);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--background-light);
    border-color: #9ca3af;
    color: var(--text-dark);
}
.btn:disabled { background-color: #d1d5db; border-color: #d1d5db; color: #9ca3af; cursor: not-allowed; }
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  background-color: var(--background-white);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
th {
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 0.75rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background-color: #f9fafb; }
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-wrapper .input { padding-right: 2.5rem; }
.password-toggle {
  position: absolute; right: 0.1rem; top: 0.1rem; bottom: 0.1rem; width: 2.3rem;
  background: none; border: none; cursor: pointer; color: var(--text-light);
  display: flex; align-items: center; justify-content: center;
}
.table-actions a {
  cursor: pointer; margin-right: 1rem; color: var(--text-light);
  display: inline-flex; align-items: center; gap: 0.25rem;
  transition: color 0.2s ease;
}
.table-actions a:hover { color: var(--primary-color); }
.table-actions a.delete:hover { color: var(--danger-color); }
.agent-associations { display: flex; flex-direction: column; gap: 0.75rem; }
.add-agent-control { display: flex; gap: 0.5rem; align-items: flex-end; }
.add-agent-control .select { flex-grow: 1; }
.btn-icon { width: 2.5rem; padding: 0; }
.associated-agents-list { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.5rem; }
.agent-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background-color: var(--background-light); border: 1px solid var(--border-color);
  padding: 0.25rem 0.75rem; border-radius: 99px; font-size: 0.875rem;
}
.agent-pill-remove {
  background: none; border: none; cursor: pointer; color: var(--text-light);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.agent-pill-remove:hover { color: var(--danger-color); }
.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}
.accordion-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.accordion-item {
  background-color: var(--background-white);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  overflow: hidden;
}
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
}
.accordion-header:hover {
  background-color: #f9fafb;
}
.accordion-header .icon {
  transition: transform 0.3s ease;
}
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease-out;
  border-top: 1px solid var(--border-color);
  padding: 0 1.5rem;
}
.accordion-item.open .accordion-content {
  max-height: 5000px;
  padding-bottom: 0.5rem;
}
.accordion-item.open .accordion-header .icon {
  transform: rotate(180deg);
}
.month-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--background-light);
}
.month-list-item:last-child {
  border-bottom: none;
}
.loading-spinner {
    width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor;
    border-top-color: transparent; animation: spin 1s linear infinite;
}
.btn .loading-spinner { border-color: white; border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-actions a.has-note { color: var(--primary-color); }
.note-summary {
    display: grid; grid-template-columns: 1fr auto; gap: 1rem;
    width: 100%; align-items: center;
}
.note-details {
    display: flex; flex-direction: column; min-width: 0;
}
.note-actions { display: flex; gap: 0.75rem; }
.note-client-name { font-weight: 600; }
.note-meta { font-size: 0.8rem; color: var(--text-light); }
.note-preview {
    font-size: 0.9rem; margin-top: 0.5rem; color: #4b5563;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.highlighted-note {
    border: 2px solid var(--primary-color) !important;
    box-shadow: 0 0 12px rgba(79, 70, 229, 0.25);
    transform: scale(1.01);
}
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem; margin-bottom: 2rem; padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.detail-item {
    display: flex; flex-direction: column;
}
.detail-item label {
    font-size: 0.8rem; color: var(--text-light);
    margin-bottom: 0.25rem; text-transform: uppercase;
}
.note-text-display {
    white-space: pre-wrap; word-wrap: break-word; line-height: 1.6;
}
.page-actions { display: flex; gap: 1rem; }
