/* ============================================
   SPAZIOO.CSS - Stile unico per tutto il progetto
   Marketplace Logistico Intelligente
   Grafica: Header Blu + Card Moderne
   ============================================ */

/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #1a3a7a;
    --primary-dark: #142d5f;
    --accent: #00d4aa;
    --accent-light: #e6f9f4;
    --orange: #ff6d00;
    --purple: #7c4dff;
    --red: #ff1744;
    --green: #00c853;
    --yellow: #ffd600;

    --bg: #f5f6fa;
    --card: #ffffff;
    --text: #1a1a2e;
    --text-light: #6c757d;
    --border: #e9ecef;

    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);

    --radius: 16px;
    --radius-sm: 10px;

    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- HEADER --- */
.header {
    background: var(--primary);
    color: #fff;
    padding: 0 30px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.header-logo img,
.header-logo i {
    font-size: 32px;
    color: var(--accent);
}

.header-logo h1 {
    font-size: 24px;
    font-weight: 700;
}

.header-logo h1 span {
    color: var(--accent);
}

.header-logo small {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    font-weight: 400;
    margin-top: -2px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user-info {
    text-align: right;
}

.header-user-info strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.header-user-info small {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.btn-logout {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
}

/* --- NAV MENU --- */
.nav-menu {
    background: #fff;
    padding: 0 30px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    z-index: 999;
    height: 56px;
    align-items: center;
    overflow-x: auto;
}

.nav-item {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s;
    border: none;
    background: none;
    cursor: pointer;
}

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

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

.nav-item i {
    font-size: 16px;
}

/* --- MAIN CONTENT --- */
.main-content {
    margin-top: 146px;
    padding: 30px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* --- PAGE HEADER --- */
.page-header {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.page-header p {
    color: var(--text-light);
    margin-top: 6px;
    font-size: 15px;
}

/* --- STATS CARDS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #e3f2fd; color: #1976d2; }
.stat-icon.green { background: #e8f5e9; color: #388e3c; }
.stat-icon.orange { background: #fff3e0; color: #f57c00; }
.stat-icon.purple { background: #f3e5f5; color: #7b1fa2; }
.stat-icon.red { background: #ffebee; color: #d32f2f; }
.stat-icon.teal { background: #e0f2f1; color: #00695c; }

/* Varianti Icone WMS Partner */
.stat-icon.stat-warning { background: #fff3e0; color: #ff9800; }
.stat-icon.stat-info { background: #e3f2fd; color: #2196f3; }
.stat-icon.stat-purple { background: #f3e5f5; color: #9c27b0; }
.stat-icon.stat-success { background: #e8f5e9; color: #4caf50; }
.stat-icon.stat-teal { background: #e0f2f1; color: #009688; }
.stat-icon.stat-danger { background: #ffebee; color: #f44336; }

.stat-content h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-content p {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 6px;
}

/* --- CARDS --- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 i {
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

/* Scheda AI e Metriche */
.card-ai-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    margin-top: 24px;
}
.card-ai-title { font-size: 18px; margin-bottom: 12px; }
.card-ai-text { opacity: 0.9; font-size: 14px; margin-bottom: 16px; }

.ai-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.ai-metric-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 16px;
    border-radius: 12px;
}
.ai-metric-box h4 { font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.ai-metric-box p { font-size: 24px; font-weight: 700; margin: 0; }

/* --- TABLES --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: #f8f9fa;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 16px;
    border-bottom: 1px solid #f1f3f5;
    font-size: 14px;
    vertical-align: middle;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* --- BADGES --- */
.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-blue { background: #e3f2fd; color: #1976d2; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-orange { background: #fff3e0; color: #f57c00; }
.badge-purple { background: #f3e5f5; color: #7b1fa2; }
.badge-red { background: #ffebee; color: #c62828; }
.badge-gray { background: #f5f5f5; color: #757575; }

/* Badge AI Pill */
.badge-ai-pill {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

/* --- BUTTONS --- */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-accent:hover {
    background: #00b894;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* --- FORMS --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 58, 122, 0.1);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* --- ALERTS --- */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.alert-warning {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffe0b2;
}

.alert-info {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
    color: var(--primary);
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 8px;
}

/* --- AI BADGE --- */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.ai-badge::before {
    content: '✨';
}

/* --- PROGRESS BAR --- */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .header {
        padding: 0 16px;
    }

    .nav-menu {
        padding: 0 16px;
    }

    .main-content {
        padding: 20px 16px;
        margin-top: 126px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        gap: 16px;
    }
}