:root {
    --primary-color: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #e0f2fe;
    --secondary-color: #38bdf8;
    --accent-color: #f59e0b;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --status-new: #94a3b8;
    --status-contact: #fbbf24;
    --status-won: #10b981;
    --status-quote: #8b5cf6;
    
    --font-main: 'Outfit', sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body { font-family: var(--font-main); background-color: var(--bg-main); color: var(--text-main); font-size: 15px; }

/* Layout */
.app-container { display: flex; min-height: 100vh; }

.sidebar { width: 260px; background: var(--bg-card); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; z-index: 10; transition: transform 0.3s ease; }
.sidebar-header { padding: 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color); }
.logo { display: flex; align-items: center; gap: 12px; }
.sidebar-nav { padding: 24px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-md); color: var(--text-muted); text-decoration: none; font-weight: 500; transition: var(--transition); }
.nav-item i { font-size: 20px; }
.nav-item:hover, .nav-item.active { background: var(--primary-light); color: var(--primary-color); }
.sidebar-footer { padding: 24px 16px; border-top: 1px solid var(--border-color); }
.user-profile { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.user-avatar { width: 40px; height: 40px; background: var(--primary-color); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--text-muted); }

.main-content { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.top-header { height: 80px; background: var(--bg-card); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; }
.header-left { display: flex; align-items: center; gap: 16px; }
#mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; color: var(--text-main); cursor: pointer; }
#page-title { font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.header-right { display: flex; align-items: center; gap: 24px; }
.search-bar { display: flex; align-items: center; background: var(--bg-main); padding: 8px 16px; border-radius: 20px; width: 300px; }
.search-bar i { color: var(--text-muted); margin-right: 8px; }
.search-bar input { border: none; background: transparent; outline: none; width: 100%; font-family: var(--font-main); }
.header-actions { display: flex; align-items: center; gap: 16px; }

.view-container { padding: 32px; flex: 1; overflow-y: auto; }

/* Buttons */
.primary-btn, .btn-save { background: var(--primary-color); color: white; border: none; padding: 10px 20px; border-radius: var(--radius-md); font-family: var(--font-main); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition); }
.primary-btn:hover, .btn-save:hover { background: var(--primary-dark); transform: translateY(-1px); }

.secondary-btn, .btn-cancel { background: transparent; color: var(--text-muted); border: 1px solid var(--border-color); padding: 10px 20px; border-radius: var(--radius-md); font-family: var(--font-main); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition); }
.secondary-btn:hover, .btn-cancel:hover { background: #f1f5f9; color: var(--text-main); }

.icon-btn { background: var(--bg-main); border: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; color: var(--text-main); position: relative; transition: var(--transition); }
.icon-btn:hover { background: #e2e8f0; }
.badge { position: absolute; top: -2px; right: -2px; background: #ef4444; color: white; font-size: 10px; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; }

/* Utility Responsive Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    display: none;
    z-index: 999;
}
.modal-backdrop.active { display: block; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -45%); background: var(--bg-card); width: 100%; max-width: 600px; border-radius: var(--radius-lg); z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: var(--shadow-md); display: flex; flex-direction: column; max-height: 90vh; }
.modal.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%); }
.modal-header { padding: 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 20px; color: var(--primary-dark); }
.close-modal { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.close-modal:hover { color: var(--text-main); }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { padding: 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; }

form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    transition: all 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease-out forwards;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Utility */
.fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: calc(100vh - 200px);
}

.kanban-board::-webkit-scrollbar {
    height: 8px;
}
.kanban-board::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.kanban-col {
    min-width: 220px;
    flex: 1;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.kanban-col-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kanban-col-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.kanban-col-header .count {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

.kanban-items {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.kanban-items::-webkit-scrollbar {
    width: 6px;
}
.kanban-items::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.lead-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(0,0,0,0.05);
}
.lead-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}


/* Print Media */
@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0; }
    .sidebar, .top-header, .print-hidden { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; width: 100% !important; background: white !important; }
    body { background: white !important; }
    .quote-document { box-shadow: none !important; margin: 0 !important; padding: 0 !important; }
    @page { margin: 1cm; }
}

@media (max-width: 1024px) {
    .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.3s ease; z-index: 1000; }
    .sidebar.open { transform: translateX(0); }
    #mobile-menu-btn { display: block !important; }
    .search-bar { display: none; }
    .main-content { margin-left: 0; }
    form { grid-template-columns: 1fr !important; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr) !important; }
    .modal-body { grid-template-columns: 1fr !important; }
    .modal-body > div { border-right: none !important; padding-right: 0 !important; }
}

@media (max-width: 640px) {
    .dashboard-stats { grid-template-columns: 1fr !important; }
    #header-add-btn span { display: none; }
    .data-table th, .data-table td { padding: 12px 8px; font-size: 13px; }
    .modal-content { width: 100% !important; height: 100% !important; max-height: 100vh; border-radius: 0; }
    .modal { transform: translate(0, 0) !important; top: 0 !important; left: 0 !important; }
    .form-group[style*="grid-column: span 2"] { grid-column: 1 / -1 !important; }
    /* Nascondi colonne meno importanti su mobile se necessario */
    .data-table .hide-mobile { display: none; }
}
