/**
 * CRM Rete Vendita - Custom Styles
 * Basato su Bootstrap 5.3
 */

/* =============================================================================
   CSS VARIABLES
   ============================================================================= */
:root {
    --crm-primary: #0d6efd;
    --crm-secondary: #6c757d;
    --crm-success: #198754;
    --crm-warning: #ffc107;
    --crm-danger: #dc3545;
    --crm-info: #0dcaf0;
    
    --crm-sidebar-width: 260px;
    --crm-sidebar-collapsed-width: 70px;
    --crm-navbar-height: 60px;
    
    --crm-body-bg: #f8f9fa;
    --crm-card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --crm-transition: all 0.3s ease;
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */
body {
    background-color: var(--crm-body-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* =============================================================================
   LAYOUT - SIDEBAR
   ============================================================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--crm-sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #e9e9e9 0%, #e6e6e6 100%);
    color: #fff;
    z-index: 1030;
    transition: var(--crm-transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-logo {
    width: 36px;
    height: 36px;
    background: var(--crm-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 1.1rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav-item {
    margin: 0.125rem 0.75rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--crm-transition);
}

.sidebar-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav-link.active {
    color: #fff;
    background: var(--crm-primary);
}

.sidebar-nav-link svg,
.sidebar-nav-link i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-nav-title {
    padding: 1.5rem 1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.4);
}

/* Sidebar collapsed state */
.sidebar-collapsed .sidebar {
    width: var(--crm-sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-nav-link span,
.sidebar-collapsed .sidebar-nav-title {
    display: none;
}

.sidebar-collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 0.75rem;
}

/* =============================================================================
   LAYOUT - MAIN CONTENT
   ============================================================================= */
.main-content {
    margin-left: var(--crm-sidebar-width);
    min-height: 100vh;
    transition: var(--crm-transition);
}

.sidebar-collapsed .main-content {
    margin-left: var(--crm-sidebar-collapsed-width);
}

/* =============================================================================
   LAYOUT - NAVBAR
   ============================================================================= */
.navbar-main {
    height: var(--crm-navbar-height);
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 0 1.5rem;
}

.navbar-toggler-sidebar {
    border: none;
    background: none;
    padding: 0.5rem;
    color: var(--crm-secondary);
}

.navbar-toggler-sidebar:hover {
    color: var(--crm-primary);
}

.navbar-search {
    max-width: 400px;
}

.navbar-search .form-control {
    background: var(--crm-body-bg);
    border: none;
    padding-left: 2.5rem;
}

.navbar-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--crm-secondary);
}

.user-dropdown img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown-toggle {
    background: none;
    border: none;
    padding: 0;
}

/* =============================================================================
   CONTENT AREA
   ============================================================================= */
.content-wrapper {
    padding: 1.5rem;
}

/* =============================================================================
   CARDS
   ============================================================================= */
.card {
    border: none;
    box-shadow: var(--crm-card-shadow);
    border-radius: 0.5rem;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* =============================================================================
   TABLES
   ============================================================================= */
.table-crm {
    margin-bottom: 0;
}

.table-crm thead th {
    background: var(--crm-body-bg);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--crm-secondary);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table-crm tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

.table-crm tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

/* =============================================================================
   FORMS
   ============================================================================= */
.form-label {
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.input-group-text {
    background: var(--crm-body-bg);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
}

.btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* =============================================================================
   BADGES
   ============================================================================= */
.badge {
    font-weight: 500;
    padding: 0.375em 0.625em;
}

.badge-stage {
    font-size: 0.75rem;
    padding: 0.375em 0.75em;
    border-radius: 1rem;
}

/* =============================================================================
   PAGINATION
   ============================================================================= */
.pagination {
    margin-bottom: 0;
}

.page-link {
    color: var(--crm-primary);
    border-radius: 0.25rem;
    margin: 0 0.125rem;
}

.page-item.active .page-link {
    background-color: var(--crm-primary);
    border-color: var(--crm-primary);
}

/* =============================================================================
   DROPDOWNS
   ============================================================================= */
.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.dropdown-item {
    padding: 0.5rem 0.875rem;
    border-radius: 0.25rem;
}

.dropdown-item:hover {
    background-color: var(--crm-body-bg);
}

/* =============================================================================
   ALERTS / FLASH MESSAGES
   ============================================================================= */
.alert {
    border: none;
    border-radius: 0.5rem;
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* =============================================================================
   MODALS
   ============================================================================= */
.modal-content {
    border: none;
    border-radius: 0.75rem;
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
}

/* =============================================================================
   UTILITIES
   ============================================================================= */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1029;
        display: none;
    }
    
    .sidebar.show + .sidebar-backdrop {
        display: block;
    }
}

/* =============================================================================
   LOGIN PAGE
   ============================================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    margin: 1rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--crm-primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

/* =============================================================================
   PIPELINE / KANBAN
   ============================================================================= */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
    background: var(--crm-body-bg);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    padding: 0.875rem 1rem;
    font-weight: 600;
    border-bottom: 3px solid;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-body {
    padding: 0.75rem;
    flex-grow: 1;
    min-height: 200px;
}

.kanban-card {
    background: #fff;
    border-radius: 0.375rem;
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--crm-card-shadow);
    cursor: grab;
    transition: var(--crm-transition);
}

.kanban-card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.kanban-card.dragging {
    opacity: 0.5;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

.slide-in-up {
    animation: slideInUp 0.3s ease;
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */
@media print {
    .sidebar,
    .navbar-main,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}
