/* =====================
   GLOBAL VARIABLES
   ===================== */
:root {
    --bg-main: #f5f6f7;
    --bg-dark: #1f2933;
    --bg-card: #ffffff;

    --primary: #1f2933;
    --primary-hover: #1f2933;

    --text-main: #212529;
    --text-muted: #6b7280;

    --shadow-soft: 0 10px 30px rgba(0,0,0,0.08);
    --shadow-strong: 0 20px 50px rgba(0,0,0,0.25);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}


/* =====================
   BASE
   ===================== */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
}

/* =====================
   LOADING OVERLAY
   ===================== */
.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.app-loading-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.app-loading-overlay__panel {
    min-width: 210px;
    max-width: 92vw;
    border-radius: var(--radius-md);
    background: rgba(31, 41, 51, 0.95);
    color: #f8fafc;
    box-shadow: var(--shadow-strong);
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
}

.app-loading-overlay__spinner {
    width: 1.2rem;
    height: 1.2rem;
    border-width: 0.18em;
}


/* =====================
   CARD
   ===================== */
.card-base {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 25px;
    box-shadow: var(--shadow-soft);
}


/* =====================
   PAGE HEADER
   ===================== */
.page-header {
    margin: 40px 0 30px 0;
}

.page-header h1 {
    font-weight: 700;
}

.page-header p {
    color: var(--text-muted);
}

.page-header-with-search {
    margin: 40px 0 30px 0;
}

.page-header-with-search .page-header {
    margin: 0;
}

.page-header-with-search .search-panel-compact {
    margin: 0;
}

@media (min-width: 992px) {
    .page-header-with-search {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 1rem;
    }

    .page-header-with-search .page-header {
        flex: 1 1 auto;
        min-width: 0;
    }

    .page-header-with-search .search-panel-compact {
        flex: 0 0 min(460px, 42%);
        width: min(460px, 42%);
    }
}

@media (max-width: 991.98px) {
    .page-header-with-search .search-panel-compact {
        margin-top: 1rem;
    }
}



/* =====================
   LOGIN
   ===================== */
.login-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-strong);
}

.login-footer {
    font-size: 0.85rem;
    color: #9ca3af;
    text-align: center;
    margin-top: 20px;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.login-page {
    background-color: var(--bg-dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}



/* =====================
   KPI
   ===================== */
.kpi-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 25px;
    box-shadow: var(--shadow-soft);
    height: 100%;
}

.kpi-card-link {
    display: block;
    height: 100%;
    text-decoration: none !important;
    color: inherit;
}

.kpi-card-link:hover,
.kpi-card-link:visited,
.kpi-card-link:focus,
.kpi-card-link:active {
    text-decoration: none !important;
    color: inherit;
}

.kpi-card-link * {
    text-decoration: none !important;
}

.kpi-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    margin-top: 10px;
}



/* =====================
   TABLE
   ===================== */
.table-container {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 25px;
    box-shadow: var(--shadow-soft);
}

.table th {
    font-weight: 600;
    color: #374151;
}

.home-nav-card {
    display: block;
    height: 100%;
    text-decoration: none !important;
    color: inherit;
    padding: 20px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.home-nav-card:hover,
.home-nav-card:focus {
    text-decoration: none !important;
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
}

.home-nav-card-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.home-nav-card-desc {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 8px;
}



/* =====================
   STATUS BADGES
   ===================== */
.badge-status {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 20px;
    font-weight: 600;
}

.status-stoccato {
    background-color: #e2e8f0;
    color: #334155;
}

.status-lavorazione {
    background-color: #fed7aa;
    color: #9a3412;
}


.status-ready {
    background-color: #34d399;
    color: #064e3b;
}

.status-consegnato {
    background-color: #bae6fd;
    color: #0c4a6e;
}

.quick-status-trigger {
    border: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quick-status-trigger:hover,
.quick-status-trigger:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.quick-status-form {
    max-width: 430px;
}

.quick-status-form .form-select {
    min-width: 190px;
}

.quick-status-save {
    height: 31px;
    padding: 0 12px;
}

.status-select-preview {
    display: flex;
    align-items: center;
}

.search-panel-compact {
    padding: 14px 16px;
}

.search-panel-compact .form-label {
    margin-bottom: 0.35rem !important;
    font-size: 0.9rem;
}

.search-panel-compact .form-control {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.search-panel-compact .alert {
    margin-top: 0.7rem !important;
    padding: 0.5rem 0.75rem;
}

.clickable-fields-hint {
    font-size: 0.92rem;
}

.form-click-guides .form-control,
.form-click-guides .form-select {
    border: 2px solid #cbd5e1;
    background-color: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.form-click-guides .form-control:hover,
.form-click-guides .form-select:hover {
    border-color: #94a3b8;
}

.form-click-guides .form-control:focus,
.form-click-guides .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(31, 41, 51, 0.18);
    background-color: #f8fbff;
}

.file-input-wrap {
    position: relative;
}

.file-input-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-input-visual {
    min-height: 44px;
    border: 2px solid #cbd5e1;
    border-radius: 0.5rem;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.file-input-visual-label {
    justify-content: center;
    padding: 0 12px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    text-align: center;
}

.file-input-icon {
    font-size: 1.05rem;
    color: #64748b;
    line-height: 1;
}

.file-input-wrap:hover .file-input-visual {
    border-color: #94a3b8;
}

.file-input-native:focus + .file-input-visual {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(31, 41, 51, 0.18);
    background-color: #f8fbff;
}

.field-icon-wrap {
    position: relative;
}

.field-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: #64748b;
    pointer-events: none;
    z-index: 2;
}

.field-icon-textarea {
    top: 12px;
    transform: none;
}

.form-click-guides .has-field-icon {
    padding-left: 2.1rem;
}

.form-click-guides textarea.has-field-icon {
    padding-top: 0.55rem;
}

.form-click-guides .btn-engine {
    box-shadow: 0 0 0 2px rgba(31, 41, 51, 0.2);
}

.form-click-guides .btn-engine:hover,
.form-click-guides .btn-engine:focus {
    box-shadow: 0 0 0 3px rgba(31, 41, 51, 0.25);
}

.status-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(15, 23, 42, 0.16);
}

.status-dot-waiting {
    background-color: #e2e8f0;
}

.status-dot-work {
    background-color: #fed7aa;
}

.status-dot-ready {
    background-color: #34d399;
}

.status-dot-delivered {
    background-color: #bae6fd;
}


/* =====================
   NAVBAR
   ===================== */
.navbar .nav-link {
    font-weight: 500;
    margin-right: 12px;
}

.navbar .nav-link.active,
.navbar.navbar-dark .navbar-nav .nav-link.active,
.navbar .nav-link.active:hover,
.navbar .nav-link.active:focus {
    color: #ffffff !important;
    font-weight: 600;
}
.navbar {
    position: relative;
    z-index: 3000 !important;
}

.navbar-action-btn {
    width: 2.5rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.navbar-brand {
    margin-right: 1rem;
}

.navbar .nav-group-start {
    margin-left: 0.75rem;
}

@media (max-width: 991.98px) {
    .navbar-action-btn {
        width: 2.4rem;
        height: 2.2rem;
    }

    .navbar .navbar-collapse {
        text-align: center;
        margin-top: 0.65rem;
        padding: 0.65rem 0.25rem;
        border: 1px solid rgba(255, 255, 255, 0.18);
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.04);
    }

    .navbar .navbar-nav {
        width: 100%;
        align-items: center;
    }

    .navbar .navbar-nav .nav-item {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .navbar .nav-group-start {
        margin-left: 0;
        margin-top: 0.2rem;
        padding-top: 0.2rem;
    }

    .navbar .nav-link {
        margin-right: 0;
        display: inline-flex;
        justify-content: center;
    }

    .navbar .navbar-nav.ms-auto {
        margin-left: 0 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        margin-top: 0.45rem;
        padding-top: 0.45rem;
    }
}


/* =====================
   ENGINE GALLERY
   ===================== */
.engine-gallery-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: transform 0.15s ease;
    height: 100%;
}

.engine-gallery-card:hover {
    transform: translateY(-4px);
}

.engine-card-link {
    display: block;
    height: 100%;
    text-decoration: none !important;
    color: inherit;
}

.engine-card-link:hover,
.engine-card-link:focus,
.engine-card-link:active {
    color: inherit;
    text-decoration: none !important;
}

.engine-card-link * {
    text-decoration: none !important;
}

.engine-image {
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-color: #e5e7eb;
    background-position: center;
}

.engine-image-empty {
    background-image: none !important;
    background: repeating-linear-gradient(
            135deg,
            #e5e7eb,
            #e5e7eb 10px,
            #f1f5f9 10px,
            #f1f5f9 20px
    );
    border: 1px solid #d1d5db;
}

.engine-image-empty-label {
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    text-align: center;
    padding: 0 6px;
}

.engine-images-edit-list {
    max-height: 52vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.engine-image-edit-card {
    position: relative;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px;
    background-color: #fff;
}

.engine-image-edit-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    background-color: #f3f4f6;
}

.engine-image-delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 1.7rem;
    height: 1.7rem;
    border: none;
    border-radius: 999px;
    background-color: #dc2626;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.engine-image-delete-btn:hover,
.engine-image-delete-btn:focus {
    background-color: #b91c1c;
}

.selected-video-preview-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background-color: #0f172a;
}

.selected-video-preview {
    width: 100%;
    max-height: 240px;
    display: block;
    background-color: #0f172a;
}

.dashboard-engine-thumb {
    width: 84px;
    height: 64px;
    border-radius: 10px;
    background-color: #1f2933;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    flex-shrink: 0;
}

.engine-body {
    padding: 20px;
}

.engine-code {
    font-weight: 700;
    font-size: 1.1rem;
}

.engine-client {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.engine-detail-section {
    margin-bottom: 30px;
}

.engine-footer {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hydraulic-video-wrap {
    aspect-ratio: 16 / 9;
    background-color: #0f172a;
}

.hydraulic-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hydraulic-notes {
    font-size: 0.9rem;
    color: var(--text-muted);
}



/* =====================
   CUSTOMER LIST
   ===================== */

.customer-list {
    max-width: 1100px;
    margin: 0 auto;
}

.customer-card {
    padding: 22px 24px;
    margin-bottom: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.customer-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.customer-card-link:hover .customer-card,
.customer-card-link:focus .customer-card {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.customer-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(170px, 1fr));
    align-items: start;
    gap: 14px 24px;
    text-align: left;
}

.customer-field {
    min-width: 0;
}

.customer-main {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.25;
}

.customer-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.customer-field > div:last-child {
    word-break: break-word;
}

.customer-notes {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 0.9rem;
}

@media (max-width: 992px) {
    .customer-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px 18px;
    }

    .customer-field--name {
        grid-column: 1 / -1;
    }
}

@media (max-width: 576px) {
    .customer-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}



/* =====================
   BUTTONS
   ===================== */
.btn-engine {
    background-color: var(--primary);
    border: none;
    height: 48px;
    padding: 0 20px;

    font-weight: 600;
    color: #fff;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    border-radius: var(--radius-sm);

    transition: background-color 0.2s ease;
}

.btn-engine:hover,
.btn-engine:focus {
    background-color: var(--primary-hover);
    color: #fff;
    box-shadow: none;
}

.btn-engine:active {
    transform: scale(0.98);
}

.btn-detail-edit,
.btn-detail-delete {
    min-width: 120px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-detail-edit {
    color: #fff;
    background-color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-detail-edit:hover,
.btn-detail-edit:focus {
    color: #fff;
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-detail-delete {
    color: #b91c1c;
    background-color: #fff;
    border: 1px solid #ef4444;
}

.btn-detail-delete:hover,
.btn-detail-delete:focus {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #dc2626;
}

.btn-detail-delete:disabled {
    color: #9ca3af;
    background-color: #f3f4f6;
    border-color: #d1d5db;
    cursor: not-allowed;
}

.detail-actions .btn {
    min-width: 140px;
}

@media (max-width: 576px) {
    .detail-actions {
        gap: 0.6rem !important;
    }

    .detail-actions .btn {
        flex: 1 1 calc(50% - 0.6rem);
        min-width: 130px;
        text-align: center;
    }
}

.pswp__button--custom-share,
.pswp__button--close {
    width: 56px !important;
    height: 56px !important;
    margin-top: 20px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: rgba(31, 41, 51, 0.85) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

.pswp__button--close {
    opacity: 1 !important;
    visibility: visible !important;
}

.pswp__button--close .pswp__icn {
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.pswp__button--custom-share:hover,
.pswp__button--close:hover {
    background: rgba(31, 41, 51, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    transform: scale(1.08);
}

.pswp__button--custom-share:active,
.pswp__button--close:active {
    transform: scale(0.95);
}

.pswp__button--close:hover {
    transform: scale(1.08) rotate(90deg);
}

.pswp__button--custom-share svg {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pswp__button--zoom {
    display: none !important;
}

.pswp__button--arrow {
    width: 56px !important;
    height: 56px !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    top: 50% !important;
    transform: translateY(-50%);
    box-shadow: none !important;
    opacity: 1 !important;
}

.pswp__button--arrow:hover {
    background: transparent !important;
    border: none !important;
}

.pswp__button--arrow--prev {
    left: 8px !important;
}

.pswp__button--arrow--next {
    right: 8px !important;
}

@media (max-width: 768px) {
    .pswp__button--arrow--prev {
        left: 2px !important;
    }

    .pswp__button--arrow--next {
        right: 2px !important;
    }
}

body.modal-open {
    overflow: hidden !important;
}

.navbar-hidden {
    visibility: hidden;
}

.fab-hidden {
    display: none !important;
}















/* =====================
   RESPONSIVE SYSTEM
   ===================== */
@media (max-width: 992px) {
    .page-header {
        margin: 30px 0 20px 0;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 0.95rem;
    }

    .engine-code {
        font-size: 1rem;
    }

    .page-header h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 576px) {
    .card-base,
    .kpi-card,
    .table-container {
        border-radius: 10px;
    }
}
