/* ============================================================
   HACCP Trace — Stile modulo
   Compatibile con qms-global.css e qms-layout.css
   ============================================================ */

:root {
    --ht-primary: #2e7d32;
    --ht-primary-light: #4caf50;
    --ht-primary-dark: #1b5e20;
    --ht-secondary: #37474f;
    --ht-accent: #ff8f00;
    --ht-sidebar-bg: #1b2a1c;
    --ht-sidebar-width: 240px;
    --ht-topbar-height: 60px;
    --ht-text-light: #eceff1;
    --ht-border: #e0e0e0;
    --ht-bg: #f5f7f5;
}

/* ---- Layout ---- */
body.qms-body {
    display: flex;
    min-height: 100vh;
    background: var(--ht-bg);
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.haccp-sidebar {
    width: var(--ht-sidebar-width);
    height: 100vh;
    background: var(--ht-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.haccp-sidebar-header {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.haccp-logo-icon {
    font-size: 1.6rem;
    color: var(--ht-primary-light);
}

.haccp-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ht-text-light);
    letter-spacing: 0.5px;
}

.haccp-nav {
    flex: 1;
    padding: 8px 0;
}

.haccp-nav-section {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 14px 16px 4px;
}

.haccp-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.haccp-nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.haccp-nav-item.active {
    background: rgba(76,175,80,0.15);
    color: var(--ht-primary-light);
    border-left-color: var(--ht-primary-light);
    font-weight: 600;
}

.haccp-sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ---- Main area ---- */
.haccp-main {
    margin-left: var(--ht-sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.haccp-topbar {
    height: var(--ht-topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--ht-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.haccp-page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ht-secondary);
    margin: 0;
}

.haccp-content {
    padding: 24px;
    flex: 1;
}

/* ---- Card ---- */
.ht-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--ht-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

.ht-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--ht-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
    border-radius: 10px 10px 0 0;
}

.ht-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ht-secondary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ht-card-body {
    padding: 20px;
}

/* ---- Stat cards (dashboard) ---- */
.ht-stat-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--ht-border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s;
}

.ht-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ht-stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.ht-stat-icon.green  { background: #e8f5e9; color: var(--ht-primary); }
.ht-stat-icon.blue   { background: #e3f2fd; color: #1565c0; }
.ht-stat-icon.orange { background: #fff3e0; color: #e65100; }
.ht-stat-icon.purple { background: #f3e5f5; color: #6a1b9a; }
.ht-stat-icon.teal   { background: #e0f2f1; color: #00695c; }

.ht-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ht-secondary);
    line-height: 1;
}

.ht-stat-label {
    font-size: 0.8rem;
    color: #78909c;
    margin-top: 2px;
}

/* ---- Tabelle ---- */
.ht-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.ht-table th {
    background: #f5f7f5;
    color: var(--ht-secondary);
    font-weight: 600;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--ht-border);
    white-space: nowrap;
}

.ht-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.ht-table tr:hover td {
    background: #f9fdf9;
}

.ht-table .actions {
    white-space: nowrap;
    text-align: right;
}

/* ---- Badge ---- */
.ht-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ht-badge.alimento    { background: #e8f5e9; color: var(--ht-primary-dark); }
.ht-badge.semilavorato { background: #fff3e0; color: #bf360c; }
.ht-badge.conforme    { background: #e8f5e9; color: var(--ht-primary-dark); }
.ht-badge.nonconforme { background: #ffebee; color: #b71c1c; }

/* ---- Form ---- */
.ht-form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ht-secondary);
    margin-bottom: 4px;
}

.ht-form-control {
    border: 1px solid #cfd8dc;
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 0.88rem;
    width: 100%;
    transition: border-color 0.15s;
}

.ht-form-control:focus {
    outline: none;
    border-color: var(--ht-primary-light);
    box-shadow: 0 0 0 3px rgba(76,175,80,0.15);
}

/* ---- Bottoni ---- */
.ht-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, box-shadow 0.15s;
}

.ht-btn:hover { opacity: 0.88; }

.ht-btn-primary  { background: var(--ht-primary); color: #fff; }
.ht-btn-danger   { background: #c62828; color: #fff; }
.ht-btn-warning  { background: var(--ht-accent); color: #fff; }
.ht-btn-secondary { background: #eceff1; color: var(--ht-secondary); }
.ht-btn-sm { padding: 4px 9px; font-size: 0.78rem; }

/* ---- Tracciabilità ---- */
.ht-trace-box {
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.ht-trace-box h6 {
    color: var(--ht-primary-dark);
    font-weight: 700;
    margin-bottom: 10px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .haccp-sidebar { width: 60px; }
    .haccp-logo-text, .haccp-nav-section,
    .haccp-nav-item span { display: none; }
    .haccp-main { margin-left: 60px; }
}
