@import 'Variables.css';

* {
    box-sizing: border-box;
}

:root {
    --color-background: #0f172a;
    --color-surface: rgba(15, 23, 42, 0.88);
    --color-surface-soft: rgba(30, 41, 59, 0.92);
    --color-primary: #14b8a6;
    --color-primary-dark: #0f766e;
    --color-accent: #22c55e;
    --color-success: #16a34a;
    --color-error: #ef4444;
    --color-white: #ffffff;
    --color-text: #cbd5e1;
    --color-text-light: #e2e8f0;
    --color-muted: #94a3b8;
    --color-gray-100: #1e293b;
    --color-gray-200: #334155;
    --color-gray-300: #475569;
    --panel-2: rgba(15, 23, 42, 0.72);
    --card-border: rgba(148, 163, 184, 0.14);
    --shadow-md: 0 18px 50px rgba(2, 6, 23, 0.35);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 28px;
    --spacing-1: 0.5rem;
    --spacing-2: 1rem;
    --spacing-3: 1.5rem;
    --accent: var(--color-primary);
}

html, body {
    min-height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background:
        radial-gradient(circle at top, rgba(20, 184, 166, 0.10), transparent 36%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: var(--color-text-light);
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    overscroll-behavior-y: none;
}

#app {
    min-height: 100dvh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-white);
    margin-top: 0;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-background);
    color: var(--color-text-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #1e293b;
    border-bottom-color: var(--color-primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    z-index: 100;
}

.login-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #020617 100%);
}

.gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(20, 184, 166, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
}

.login-container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    min-height: 100vh;
    padding: 2rem;
    z-index: 1;
}

.login-hero-logo {
    width: min(92vw, 820px);
    display: flex;
    justify-content: center;
}

.login-hero-image {
    width: 100%;
    max-width: 360px;
    height: auto;
    display: block;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}

.login-card {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    color: #ffffff;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.4rem 0;
    background: linear-gradient(135deg, #14b8a6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #94a3b8;
    font-size: 0.95rem;
    margin: 0;
}

.login-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

.form-input::placeholder {
    color: #64748b;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.error-icon {
    font-size: 1.2rem;
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(20, 184, 166, 0.3);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.login-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    padding-top: 1.5rem;
}

.hint {
    color: #94a3b8;
    font-size: 0.75rem;
    text-align: center;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.test-users {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.test-user-btn {
    flex: 1;
    min-width: 120px;
    padding: 0.625rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.test-user-btn:hover {
    background: rgba(20, 184, 166, 0.1);
    border-color: rgba(20, 184, 166, 0.3);
    color: #14b8a6;
}

.test-user-icon {
    width: 16px;
    height: 16px;
    fill: #cbd5e1;
    margin-right: 0.5rem;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(18px);
    background: rgba(15, 23, 42, 0.76);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.app-main {
    flex: 1;
    padding: 1rem 1rem 6.6rem;
}

.content-panel {
    max-width: 720px;
    margin: 0 auto;
}

.nav-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-white);
}

.nav-links {
    display: flex;
    gap: 0.75rem;
    font-weight: 600;
}

.nav-links a.active {
    color: var(--color-primary);
}

.auth-screen {
    min-height: calc(100vh - 80px);
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card,
.hero-panel,
.action-panel {
    width: 100%;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.80) 100%);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 1.25rem;
}

.auth-card {
    max-width: 420px;
}

.brand-mark {
    width: 3.5rem;
    height: 3.5rem;
    display: grid;
    place-items: center;
    border-radius: 1.2rem;
    background: linear-gradient(135deg, var(--color-primary), #0ea5a1);
    color: #062c2a;
    font-weight: 900;
    font-size: 1.7rem;
    margin-bottom: 1rem;
}

.auth-card h1 {
    margin-bottom: 0.4rem;
}

.auth-card p,
.hero-copy p,
.eyebrow,
.action-panel h2,
.field-group label,
.session-box span {
    color: var(--color-muted);
}

.field-group {
    margin-top: 1rem;
}

.btn,
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary,
.btn-hero {
    color: var(--color-white);
    background: linear-gradient(135deg, var(--color-primary) 0%, #0ea5a1 100%);
    border: none;
}

.btn-primary:hover,
.btn-hero:hover {
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, #0d9488 100%);
}

.btn-hero {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    font-weight: 700;
    color: #ffffff;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(20, 184, 166, 0.22);
}

.form-control {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-sm);
    background-color: rgba(15, 23, 42, 0.92);
    color: var(--color-text-light);
}

.form-control::placeholder {
    color: var(--color-muted);
}

.home-shell {
    display: grid;
    gap: 1rem;
}

.empty-page-shell {
    min-height: calc(100vh - 170px);
    display: grid;
    place-items: center;
}

.empty-page-card {
    width: 100%;
    max-width: 620px;
    border: 1px dashed rgba(148, 163, 184, 0.35);
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.5);
    padding: 2rem;
    text-align: center;
}

.empty-page-card h1 {
    margin-bottom: 0.6rem;
}

.empty-page-card p {
    color: var(--color-muted);
    margin-bottom: 1.4rem;
}

.detail-page-shell {
    min-height: calc(100vh - 130px);
    width: 100%;
    display: block;
    padding: 0.25rem 0 0;
}

.detail-card {
    width: 100%;
    max-width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
}

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.detail-kicker {
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.detail-header p {
    color: var(--color-muted);
    margin: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.info-tile {
    border-radius: 18px;
    background: rgba(30, 41, 59, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.10);
    padding: 0.95rem;
    display: grid;
    gap: 0.25rem;
}

.info-tile span,
.detail-meta-line span,
.commessa-row-subtitle {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.tile-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.tile-icon {
    font-size: 0.95rem;
}

.shipped-icon {
    color: #22c55e;
}

.pending-icon {
    color: #facc15;
}

.info-tile strong,
.detail-meta-line strong,
.commessa-row-title {
    color: var(--color-white);
}

.detail-meta-panel {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.48);
    border: 1px solid rgba(148, 163, 184, 0.10);
    margin-bottom: 1rem;
}

.detail-meta-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.detail-field-group {
    margin-top: 0;
}

.detail-input {
    width: 100%;
    padding: 0.95rem 1rem;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    color: var(--color-white);
}

.detail-input:focus {
    outline: none;
    border-color: rgba(20, 184, 166, 0.8);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.detail-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    position: relative;
    z-index: 90;
}

.scan-helper {
    color: var(--color-muted);
    margin: 0 0 0.9rem;
}

.qr-reader {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.72);
}

.qr-reader video {
    border-radius: 12px;
}

.scan-manual-panel {
    margin-top: 1rem;
    padding: 0.95rem;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.45);
}

.scan-manual-title {
    color: var(--color-muted);
    margin-bottom: 0.65rem;
    font-size: 0.9rem;
}

.scan-manual-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    align-items: center;
}


.detail-state {
    padding: 0.95rem 1rem;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--color-text-light);
}

.detail-state-error {
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(127, 29, 29, 0.28);
    color: #fecaca;
    margin-top: 0.75rem;
}

.detail-state-ok {
    border-color: rgba(34, 197, 94, 0.28);
    background: rgba(20, 83, 45, 0.24);
    color: #bbf7d0;
    margin-top: 0.75rem;
}

.flash-message {
    position: fixed;
    top: 0.9rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 140;
    width: min(92vw, 560px);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(20, 184, 166, 0.35);
    background: rgba(20, 83, 45, 0.22);
    color: #ccfbf1;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.45);
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.commessa-list {
    display: grid;
    gap: 0.75rem;
}

.commessa-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(30, 41, 59, 0.76);
    border: 1px solid rgba(148, 163, 184, 0.10);
}

.commessa-row-main {
    display: grid;
    gap: 0.15rem;
}

.commessa-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.commessa-ubicazione-row {
    margin-top: 0.4rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.55rem;
    align-items: stretch;
}

.commessa-ubicazione-label {
    align-self: center;
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.ubicazione-readonly-input {
    height: 42px;
    padding: 0.65rem 0.85rem;
    color: var(--color-text-light);
    border-color: rgba(148, 163, 184, 0.24);
}

.ubicazione-readonly-input[readonly] {
    opacity: 0.95;
}

.row-edit-btn {
    height: 42px;
    width: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 12px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal-card {
    width: min(560px, 100%);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.55);
    padding: 1rem;
    display: grid;
    gap: 0.9rem;
}

.modal-card h2 {
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.status-badge {
    flex-shrink: 0;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-shipped {
    background: rgba(20, 184, 166, 0.14);
    color: #6ee7d8;
    border: 1px solid rgba(20, 184, 166, 0.24);
}

.status-pending {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.22);
}

.ghost-btn {
    border: 1px solid rgba(20, 184, 166, 0.45);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    background: rgba(20, 184, 166, 0.08);
    color: #9be7dd;
    font-weight: 600;
}

.ghost-btn:hover {
    background: rgba(20, 184, 166, 0.15);
}

.hero-panel {
    padding: 1.5rem;
}

.hero-copy h1 {
    margin: 0.25rem 0 0.75rem;
    font-size: clamp(2rem, 8vw, 3rem);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.summary-grid article,
.session-box,
.action-card {
    border-radius: 20px;
    background: rgba(30, 41, 59, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.10);
}

.summary-grid article {
    padding: 0.9rem;
    display: grid;
    gap: 0.15rem;
}

.summary-grid strong {
    font-size: 1.15rem;
    color: var(--color-white);
}

.action-panel h2 {
    margin-top: 0;
}

.action-list {
    display: grid;
    gap: 0.75rem;
}

.action-card {
    border: 0;
    color: var(--color-text-light);
    padding: 1rem;
    text-align: left;
}

.session-box {
    margin-top: 1rem;
    padding: 1rem;
    display: grid;
    gap: 1rem;
}

.session-box strong {
    display: block;
    margin-top: 0.25rem;
    word-break: break-all;
    color: var(--color-white);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid var(--color-error);
}

.validation-message {
    color: #fca5a5;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.92);
    color: var(--color-text-light);
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
    font-size: 0.9rem;
    align-items: center;
    gap: 0.5rem;
}

#blazor-error-ui a.reload {
    color: var(--color-primary);
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    margin-left: 0.6rem;
    cursor: pointer;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin-small 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin-small {
    to {
        transform: rotate(360deg);
    }
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
    border-radius: 8px;
    border: 2px solid rgba(11, 17, 28, 0.6);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #0d9488 0%, #0ea5a1 100%);
}

* {
    scrollbar-width: thin;
    scrollbar-color: #14b8a6 rgba(15, 23, 42, 0.2);
}

@media (max-width: 640px) {
    .nav-wrap {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .auth-card,
    .hero-panel,
    .action-panel {
        border-radius: 22px;
    }

    .detail-header,
    .commessa-row {
        flex-direction: column;
        align-items: stretch;
    }

    .commessa-row-top,
    .modal-actions {
        justify-content: stretch;
    }

    .commessa-ubicazione-row {
        grid-template-columns: auto 1fr auto;
    }

    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .detail-actions {
        justify-content: stretch;
    }

    .detail-save-btn {
        width: 100%;
        min-width: 190px;
        color: #ffffff;
    }
}