/* ============================================
   FACE RECOGNITION SYSTEM - Corporate Style
   Based on DayNight Admin Template
   Snow Edition (Light) / Carbon Edition (Dark)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== CSS Variables - Snow Edition (Default) ===== */
:root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8FAFC;
    --bg-surface: #F1F5F9;
    --border-color: #E2E8F0;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --accent: rgb(56, 189, 248);
    --accent-hover: #0EA5E9;
    --accent-light: rgba(56, 189, 248, 0.1);
    --success: #22C55E;
    --success-light: rgba(34, 197, 94, 0.1);
    --warning: #F59E0B;
    --warning-light: rgba(245, 158, 11, 0.1);
    --danger: #EF4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ===== Carbon Edition (Dark Mode) ===== */
html.carbon,
body.carbon {
    --bg-primary: #0F0F0F;
    --bg-secondary: #171717;
    --bg-surface: #1F1F1F;
    --border-color: #2E2E2E;
    --text-primary: #F5F5F5;
    --text-secondary: #A3A3A3;
    --text-muted: #737373;
    --accent: #38BDF8;
    --accent-hover: #7DD3FC;
    --accent-light: rgba(56, 189, 248, 0.15);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

html {
    background: var(--bg-secondary);
    scroll-behavior: smooth;
}

/* ===== Base Styles ===== */
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

a:hover {
    color: var(--accent);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: 0.9375rem;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

p {
    color: var(--text-secondary);
}

/* ===== Layout ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.container-wide {
    max-width: 1400px;
}

/* ===== Header ===== */

.logo {
    position: absolute;
    top: 50px;
    left: 60px;
    height: 80px;
}


.header {
    text-align: center;
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.header .subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Back Link */
.back-link {
    position: absolute;
    top: 2rem;
    left: 2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header .icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: var(--radius-md);
    color: var(--accent);
}

.card-header .icon svg {
    width: 20px;
    height: 20px;
}

/* ===== Homepage Cards ===== */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card-enrollment,
.card-verification {
    cursor: pointer;
    text-align: center;
    padding: 2rem;
    transition: var(--transition);
}

.card-enrollment:hover,
.card-verification:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.card-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: 50%;
    color: var(--accent);
}

.card-icon svg {
    width: 32px;
    height: 32px;
}

.card-enrollment h2,
.card-verification h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.card-enrollment > p,
.card-verification > p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
}

/* Card Features */
.card-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.card-features span {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* ===== Step Container ===== */
.step-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.step-container.hidden {
    display: none;
}

.step-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.step-number {
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.step-number.completed {
    background: var(--success);
}

.step-header > div h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.step-header > div p,
.step-header p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--accent);
    background: var(--accent-light);
}

.btn-large {
    padding: 1rem 1.5rem;
    font-size: 1rem;
    width: 100%;
}

.btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn-grid .btn {
    flex: 1;
    min-width: 120px;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group .required {
    color: var(--danger);
    margin-left: 2px;
}

.input-field,
.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-field:hover,
.form-input:hover {
    border-color: var(--text-secondary);
}

.input-field:focus,
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-field::placeholder,
.form-input::placeholder {
    color: var(--text-muted);
}

.input-field:disabled,
.input-field[readonly] {
    background: var(--bg-surface);
    cursor: not-allowed;
    opacity: 0.7;
}

.hint-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ===== User Found Card ===== */
.user-found-card {
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1.25rem;
    display: none;
}

.user-found-card.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

.user-found-card .user-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 0.25rem;
}

.user-found-card .user-badge {
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.user-found-card .user-faces {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ===== DB Status ===== */
.db-status {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 180px;
    border-left: 3px solid var(--text-muted);
    transition: var(--transition);
}

.db-status.connected {
    border-left-color: var(--success);
}

.db-status.error {
    border-left-color: var(--danger);
}

.db-status .title {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.db-status .info {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.db-status .info small {
    opacity: 0.8;
}

/* ===== Video Container ===== */
.video-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    
    /* NUOVO: Flex per espandere il contenuto */
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.video-card .card-header {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.video-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #1E293B;
    box-shadow: var(--shadow-md);
    
    /* NUOVO: Espande per riempire lo spazio */
    flex: 1;
    min-height: 400px;
}

.video-container video {
    /* NUOVO: Posizionamento assoluto per coprire tutto */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cambia in 'contain' per mantenere proporzioni */
    display: block;
}

.video-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ===== Main Content Layout ===== */
.main-content {
    display: flex;
    gap: 1.5rem;
    /* NUOVO: Altezza che riempie lo schermo */
    height: calc(100vh - 200px);
    min-height: 500px;
}

/* ===== Side Panel ===== */
.side-panel {
    width: 350px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 100%;
    overflow: hidden;
}

.side-panel .card:last-child {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.log-entries {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ===== Video Wrapper (per altre pagine) ===== */
.video-wrapper {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #1E293B;
    box-shadow: var(--shadow-lg);
}

.video-wrapper video {
    width: 100%;
    display: block;
}

.video-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.capture-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
        height: auto;
    }
    
    .video-container {
        height: 50vh;
        min-height: 300px;
    }
    
    .side-panel {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .video-container {
        height: 40vh;
        min-height: 250px;
    }
    
    .main-content {
        gap: 1rem;
    }
}

/* ===== Status Panel ===== */
.status-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--bg-primary);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    border-left: 3px solid var(--text-muted);
}

.status-panel.active {
    border-left-color: var(--success);
}

.status-panel.scanning {
    border-left-color: var(--warning);
}

.status-panel.error {
    border-left-color: var(--danger);
}

/* ===== Recognition Overlay ===== */
.recognition-overlay {
    position: absolute;
    bottom: 1.25rem;
    left: 1.25rem;
    right: 1.25rem;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: none;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.recognition-overlay.visible {
    display: block;
    animation: slideUp 0.3s ease;
}

.recognition-overlay.recognized {
    border-color: var(--success);
    border-width: 2px;
}

.recognition-overlay.unknown {
    border-color: var(--danger);
    border-width: 2px;
}

.recognition-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.recognition-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.recognition-avatar svg {
    width: 28px;
    height: 28px;
}

.recognition-avatar.success {
    background: var(--success-light);
    color: var(--success);
}

.recognition-avatar.error {
    background: var(--danger-light);
    color: var(--danger);
}

.recognition-details {
    flex: 1;
}

.recognition-details h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.recognition-details .badge-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

/* ===== Confidence Bar ===== */
.confidence-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.confidence-fill.medium {
    background: var(--warning);
}

.confidence-fill.low {
    background: var(--danger);
}

.confidence-text {
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--success);
    min-width: 48px;
    text-align: right;
}

.confidence-text.medium {
    color: var(--warning);
}

.confidence-text.low {
    color: var(--danger);
}

/* ===== Progress Bar ===== */
.progress-container {
    margin: 1.5rem 0;
}

.progress-bar {
    height: 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 0.75rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

/* ===== Size Display ===== */
.size-display {
    background: var(--bg-surface);
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

.size-display strong {
    color: var(--accent);
}

/* ===== Photo Grid ===== */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.photo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.625rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    min-width: 80px;
    border: 2px solid var(--border-color);
    transition: var(--transition);
}

.photo-item.pending {
    border-color: var(--warning);
}

.photo-item.success {
    border-color: var(--success);
}

.photo-item.error {
    border-color: var(--danger);
}

.photo-item img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.photo-item .placeholder {
    width: 56px;
    height: 56px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
}

.photo-item .size {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.photo-item .status {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-weight: 600;
    color: var(--text-muted);
}

.photo-item.success .status {
    color: var(--success);
}

.photo-item.pending .status {
    color: var(--warning);
}

.photo-item.error .status {
    color: var(--danger);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-item,
.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: var(--transition);
}

.stat-item:hover,
.stat-card:hover {
    border-color: var(--accent);
}

.stat-item .value,
.stat-item .stat-value,
.stat-card .value,
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
    display: block;
    margin-bottom: 0.25rem;
}

.stat-item .label,
.stat-item .stat-label,
.stat-card .label,
.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

/* ===== Stats Section - Homepage ===== */
.stats-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.stats-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

/* ===== People List - Homepage ===== */
.people-list {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.people-list h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.875rem;
}

/* Person Card */
.person-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.person-card:hover {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
}

.person-avatar {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: 50%;
    color: var(--accent);
    margin-bottom: 0.625rem;
}

.person-avatar svg {
    width: 22px;
    height: 22px;
}

.person-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.25rem;
}

.person-photos {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Empty Message */
.empty-message {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
    grid-column: 1 / -1;
}

/* ===== Threshold Slider ===== */
.threshold-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.threshold-section label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.threshold-section .value {
    color: var(--accent);
    font-weight: 700;
}

.threshold-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-surface);
    outline: none;
    appearance: none;
    cursor: pointer;
}

.threshold-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.15s ease;
}

.threshold-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.threshold-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* ===== Log Entries ===== */
.log-entries {
    max-height: 320px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    margin-bottom: 0.625rem;
    border-left: 3px solid var(--success);
    transition: var(--transition);
}

.log-entry:hover {
    transform: translateX(3px);
}

.log-entry.failed {
    border-left-color: var(--danger);
}

.log-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--success-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--success);
}

.log-avatar svg {
    width: 16px;
    height: 16px;
}

.log-avatar.unknown {
    background: var(--danger-light);
    color: var(--danger);
}

.log-details {
    flex: 1;
    min-width: 0;
}

.log-details .name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-details .time {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.log-confidence {
    font-weight: 700;
    font-size: 0.8125rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    background: var(--success-light);
    color: var(--success);
}

.log-confidence.medium {
    background: var(--warning-light);
    color: var(--warning);
}

.log-confidence.low {
    background: var(--danger-light);
    color: var(--danger);
}

.log-placeholder {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* ===== Verification Panel ===== */
.verification-panel {
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.verification-panel.error {
    background: var(--danger-light);
    border-color: var(--danger);
}

.verification-panel h4 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--success);
}

.verification-item {
    display: flex;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.9375rem;
}

.verification-item:last-child {
    border-bottom: none;
}

.verification-item .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.verification-item .value {
    font-weight: 700;
    color: var(--text-primary);
}

.verification-item .value.success {
    color: var(--success);
}

.verification-item .value.error {
    color: var(--danger);
}

.verification-item .value.warning {
    color: var(--warning);
}

/* ===== Success Content ===== */
.success-content {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    background: var(--success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
}

.success-icon svg {
    width: 36px;
    height: 36px;
}

.success-name {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.success-badge {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== Controls ===== */
.controls {
    display: flex;
    justify-content: center;
    gap: 0.875rem;
    margin-top: 1.5rem;
}

/* ===== Side Panel - Verification ===== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Main Content Layout - Verification */
.main-content {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border-color);
}

.footer a {
    color: var(--accent);
}

/* ===== Toast Notifications ===== */
.toast {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 0.9375rem;
    z-index: 10000;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--accent);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.log-entries::-webkit-scrollbar {
    width: 5px;
}

.log-entries::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: 3px;
}

.log-entries::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ===== Animations ===== */
@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1000px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .back-link {
        position: relative;
        top: auto;
        left: auto;
        display: inline-flex;
        margin-bottom: 1rem;
    }
    
    .step-container {
        padding: 1.25rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-grid {
        flex-direction: column;
    }
    
    .btn-grid .btn {
        width: 100%;
    }
    
    .db-status {
        position: relative;
        top: auto;
        right: auto;
        margin-bottom: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .photo-grid {
        justify-content: center;
    }
    
    .cards-container {
        grid-template-columns: 1fr;
    }
    
    .people-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls .btn {
        width: 100%;
    }
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success) !important;
}

.text-error {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ===== Homepage Cards - Versione Grande ===== */
.cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin: 3rem 0;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.card-enrollment,
.card-verification {
    padding: 3rem 2.5rem;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-enrollment h2,
.card-verification h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.card-enrollment > p,
.card-verification > p {
    font-size: 1rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.card-features {
    margin-bottom: 2rem;
}

.card-features span {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.card-enrollment .btn,
.card-verification .btn {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Responsive - Una colonna su mobile */
@media (max-width: 768px) {
    .cards-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin: 2rem 0;
    }
    
    .card-enrollment,
    .card-verification {
        padding: 2rem 1.5rem;
        min-height: auto;
    }
}
/* ===== Stats Row ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}

.stat-box .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-box .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ===== Tabs ===== */
.tabs-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* ===== Table ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.empty-state {
    text-align: center;
    padding: 2.5rem !important;
    color: var(--text-secondary);
}

/* ===== Tags & Badges ===== */
.badge-tag {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.level-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.level-tag.level-1 { background: #dc2626; }
.level-tag.level-2 { background: #ea580c; }
.level-tag.level-3 { background: #d97706; }
.level-tag.level-4 { background: #ca8a04; }
.level-tag.level-5 { background: #65a30d; }
.level-tag.level-6 { background: #16a34a; }
.level-tag.level-7 { background: #0d9488; }

.status-tag {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-tag.active {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-tag.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ===== Actions ===== */
.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-icon.danger:hover {
    background: #ef4444;
    border-color: #ef4444;
}

/* ===== Matrix ===== */
.matrix-wrapper {
    overflow-x: auto;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.matrix-table th,
.matrix-table td {
    padding: 0.75rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.matrix-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.matrix-cell {
    padding: 0.5rem !important;
}

.access-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.access-indicator:hover {
    transform: scale(1.15);
}

.access-indicator.granted {
    background: #22c55e;
}

.access-indicator.denied {
    background: #ef4444;
}

/* ===== Legend ===== */
.legend-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.access-dot {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
}

.access-dot.granted {
    background: #22c55e;
}

.access-dot.denied {
    background: #ef4444;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.modal-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ===== Form ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.text-muted {
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tabs-container {
        flex-wrap: wrap;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .legend-box {
        flex-direction: column;
        align-items: flex-start;
    }
}
/* ============================================
   ADMIN LOGIN PAGE
   ============================================ */

/* Login Container */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    max-width: 460px;
    margin: 0 auto;
}

/* Login Card */
.login-card {
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.4s ease;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-align: center;
}

.login-card > p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
}

/* Login Error Message */
.login-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 1.25rem;
    animation: shake 0.4s ease;
}

/* Login Hint */
.login-hint {
    text-align: center;
    margin-top: 1.5rem;
    margin-bottom: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Logo positioning for login page */
body:has(.login-container) .logo {
    position: absolute;
    top: 30px;
    left: 30px;
    height: 70px;
    animation: fadeIn 0.6s ease;
}

/* Button Loading State */
.btn-primary.loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

/* Focus enhancement for login */
.login-card .input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Dark Mode Adjustments */
html.carbon .login-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body:has(.login-container) .logo {
        top: 20px;
        left: 20px;
        height: 50px;
    }

    .login-container {
        padding: 1rem;
    }

    .login-card h2 {
        font-size: 1.25rem;
    }

    .login-card > p {
        font-size: 0.875rem;
    }
}