/* ============================================================
   CRM Studio — style.css
   Personalizzazioni Bootstrap 5
   ============================================================ */

/* Variabili colori brand */
:root {
    --brand-primary:     #2c3e6b;
    --brand-primary-dk:  #1a2540;
    --brand-accent:      #4a90d9;
    --brand-accent-hover:#357abd;
    --brand-light:       #f0f4f8;
    --brand-sidebar-w:   260px;
    --brand-header-h:    56px;
}

/* ============================================================
   LAYOUT GENERALE
   ============================================================ */
body {
    background: var(--brand-light);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .9rem;
}

/* ============================================================
   NAVBAR HEADER
   ============================================================ */
.crm-navbar {
    background: var(--brand-primary);
    height: var(--brand-header-h);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.crm-navbar .brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .4px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}

.crm-navbar .brand i {
    color: var(--brand-accent);
    font-size: 1.2rem;
}

.crm-navbar .nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.crm-navbar .btn-icon {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.75);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    cursor: pointer;
}

.crm-navbar .btn-icon:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.crm-navbar .avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--brand-accent);
}

.crm-navbar .user-name {
    color: #fff;
    font-size: .85rem;
    font-weight: 500;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.crm-sidebar {
    background: var(--brand-primary);
    width: var(--brand-sidebar-w);
    position: fixed;
    top: var(--brand-header-h);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
    transition: transform .25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

.crm-sidebar::-webkit-scrollbar { width: 4px; }
.crm-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* Pannello utente sidebar */
.sidebar-user {
    padding: 1rem 1rem .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--brand-accent);
    flex-shrink: 0;
}

.sidebar-user .avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-user .user-info .name {
    color: #fff;
    font-weight: 600;
    font-size: .85rem;
    line-height: 1.2;
}

.sidebar-user .user-info .role {
    color: rgba(255,255,255,.5);
    font-size: .72rem;
}

/* Navigazione sidebar */
.sidebar-nav {
    padding: .5rem 0;
}

.sidebar-label {
    color: rgba(255,255,255,.35);
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: .75rem 1rem .25rem;
}

.sidebar-nav .nav-item { margin: 1px .5rem; }

.sidebar-nav .nav-link {
    color: rgba(255,255,255,.75);
    border-radius: 8px;
    padding: .55rem .75rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .875rem;
    transition: background .15s, color .15s;
    text-decoration: none;
}

.sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    font-size: .9rem;
    flex-shrink: 0;
}

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

.sidebar-nav .nav-link.active {
    background: var(--brand-accent);
    color: #fff;
    font-weight: 500;
}

/* Submenu */
.sidebar-submenu {
    list-style: none;
    padding: .25rem 0 .25rem 2.5rem;
    margin: 0;
}

.sidebar-submenu .nav-link {
    font-size: .82rem;
    padding: .35rem .75rem;
    color: rgba(255,255,255,.6);
}

.sidebar-submenu .nav-link::before {
    content: '›';
    margin-right: .4rem;
    font-size: 1rem;
    line-height: 1;
}

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

/* Toggle freccia submenu */
.nav-link .arrow {
    margin-left: auto;
    font-size: .7rem;
    transition: transform .2s;
}

.nav-link[aria-expanded="true"] .arrow {
    transform: rotate(-90deg);
}

/* ============================================================
   CONTENUTO PRINCIPALE
   ============================================================ */
.crm-main {
    margin-left: var(--brand-sidebar-w);
    margin-top: var(--brand-header-h);
    min-height: calc(100vh - var(--brand-header-h));
    display: flex;
    flex-direction: column;
}

.page-header {
    background: #fff;
    border-bottom: 1px solid #e5e9f0;
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-header h1 i { color: var(--brand-accent); }

.page-content {
    padding: 1.25rem 1.5rem;
    flex: 1;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.card-header-brand {
    background: var(--brand-primary);
    color: #fff;
    border-radius: 10px 10px 0 0 !important;
    padding: .75rem 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header-brand .card-title {
    margin: 0;
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ============================================================
   BOTTONI
   ============================================================ */
.btn { border-radius: 7px; font-size: .85rem; }
.btn-brand {
    background: var(--brand-accent);
    color: #fff;
    border: none;
}
.btn-brand:hover { background: var(--brand-accent-hover); color: #fff; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: .8rem;
}
.breadcrumb-item + .breadcrumb-item::before { color: #adb5bd; }

/* ============================================================
   TABELLE
   ============================================================ */
.table thead th {
    background: var(--brand-light);
    color: var(--brand-primary);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid #dde3ed;
    white-space: nowrap;
}

.table tbody tr:hover { background: #f5f8ff; }

/* ============================================================
   BADGE RUOLI
   ============================================================ */
.badge-admin        { background: #e74c3c; color: #fff; }
.badge-manager      { background: #f39c12; color: #fff; }
.badge-collaboratore{ background: #27ae60; color: #fff; }

/* ============================================================
   FOOTER
   ============================================================ */
.crm-footer {
    background: #fff;
    border-top: 1px solid #e5e9f0;
    padding: .6rem 1.5rem;
    font-size: .78rem;
    color: #adb5bd;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dk) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(0,0,0,.35);
    border: none;
}

.login-card .card-body { padding: 2rem; }

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #fff;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: .5rem 0 .25rem;
}

.login-logo small {
    color: rgba(255,255,255,.5);
    font-size: .8rem;
}

/* ============================================================
   UPLOAD PREVIEW
   ============================================================ */
.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--brand-accent);
    cursor: pointer;
    transition: opacity .2s;
}
.avatar-preview:hover { opacity: .85; }

.logo-preview-wrap {
    min-height: 70px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    cursor: pointer;
    transition: border-color .2s;
}
.logo-preview-wrap:hover { border-color: var(--brand-accent); }

/* ============================================================
   SIDEBAR MOBILE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1015;
}

@media (max-width: 991.98px) {
    .crm-sidebar { transform: translateX(-100%); }
    .crm-sidebar.open { transform: translateX(0); }
    .crm-main { margin-left: 0; }
    .sidebar-overlay.show { display: block; }
    .page-header { padding: .75rem 1rem; }
    .page-content { padding: 1rem; }
}
