/* ==========================================================
   InfissiProduction - Theme Globale
   Design system coerente su tutte le pagine.
   Ispirato alla Dashboard Admin (hero dark-blue, glow, badge).
   ========================================================== */

:root {
    /* Palette */
    --ip-bg-dark-1: #0f172a;
    --ip-bg-dark-2: #111827;
    --ip-bg-deep: #060f1f;
    --ip-bg-card: rgba(15, 23, 42, 0.62);
    --ip-bg-card-dense: rgba(15, 23, 42, 0.85);

    --ip-accent-blue: #2563eb;
    --ip-accent-blue-hi: #3b82f6;
    --ip-accent-blue-lo: #1d4ed8;
    --ip-accent-cyan: #06b6d4;
    --ip-accent-green: #10b981;
    --ip-accent-yellow: #f59e0b;
    --ip-accent-orange: #f97316;
    --ip-accent-red: #ef4444;
    --ip-accent-purple: #8b5cf6;

    --ip-text: #e2e8f0;
    --ip-text-strong: #f8fafc;
    --ip-text-muted: rgba(226, 232, 240, 0.72);
    --ip-text-soft: rgba(226, 232, 240, 0.55);

    --ip-border: rgba(148, 163, 184, 0.16);
    --ip-border-hi: rgba(96, 165, 250, 0.38);

    --ip-shadow-card: 0 24px 60px rgba(15, 23, 42, 0.18);
    --ip-shadow-btn-primary: 0 18px 32px rgba(37, 99, 235, 0.32);
    --ip-shadow-btn-primary-hi: 0 22px 40px rgba(37, 99, 235, 0.42);

    --ip-radius-lg: 1.5rem;
    --ip-radius: 1rem;
    --ip-radius-sm: 0.75rem;
    --ip-radius-pill: 999px;
}

/* ==========================================================
   PAGE SHELL - wrapper standard per ogni pagina
   ========================================================== */
.ip-page {
    max-width: 1500px;
    margin: 0 auto;
    display: grid;
    gap: 1.5rem;
    color: var(--ip-text);
}

.ip-section,
.ip-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--ip-radius-lg);
    border: 1px solid var(--ip-border);
    box-shadow: var(--ip-shadow-card);
    background: linear-gradient(180deg, var(--ip-bg-dark-1) 0%, var(--ip-bg-dark-2) 100%);
    padding: 1.5rem;
}

.ip-hero {
    padding: 2rem;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.34), transparent 28%),
        radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.12), transparent 24%),
        linear-gradient(135deg, #0f172a 0%, #111827 55%, #172554 100%);
}

.ip-hero-row {
    display: grid;
    gap: 2rem;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
    align-items: center;
}

.ip-hero h1 {
    margin: 0.2rem 0 0.6rem;
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    line-height: 1.05;
    color: var(--ip-text-strong);
    letter-spacing: -0.02em;
}

.ip-hero p {
    color: var(--ip-text-muted);
    max-width: 60ch;
    margin: 0;
}

.ip-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.4rem;
}

/* ==========================================================
   EYEBROWS / SECTION TAG
   ========================================================== */
.ip-eyebrow,
.ip-section-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--ip-radius-pill);
    background: rgba(255, 255, 255, 0.08);
    color: #bfdbfe;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ip-section-tag.danger { color: #fecaca; background: rgba(239, 68, 68, 0.14); }
.ip-section-tag.warning { color: #fdba74; background: rgba(249, 115, 22, 0.14); }
.ip-section-tag.success { color: #86efac; background: rgba(16, 185, 129, 0.14); }

.ip-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.ip-section-heading h2 {
    margin: 0.4rem 0 0;
    font-size: 1.3rem;
    color: var(--ip-text-strong);
    letter-spacing: -0.01em;
}

.ip-section-meta {
    font-size: 0.82rem;
    color: var(--ip-text-soft);
}

/* ==========================================================
   CTA BUTTONS
   ========================================================== */
.ip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.75rem 1.15rem;
    border-radius: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    cursor: pointer;
    font-size: 0.92rem;
    font-family: inherit;
    white-space: nowrap;
}

.ip-btn:hover:not(:disabled) { transform: translateY(-2px); }

.ip-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ip-btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--ip-accent-blue) 0%, var(--ip-accent-blue-lo) 100%);
    box-shadow: var(--ip-shadow-btn-primary);
}

.ip-btn-primary:hover:not(:disabled) {
    box-shadow: var(--ip-shadow-btn-primary-hi);
}

.ip-btn-secondary {
    color: var(--ip-text);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.ip-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    border-color: var(--ip-border-hi);
}

.ip-btn-ghost {
    color: #cbd5e1;
    background: transparent;
    border-color: rgba(148, 163, 184, 0.24);
}

.ip-btn-ghost:hover:not(:disabled) {
    border-color: var(--ip-border-hi);
    color: white;
}

.ip-btn-success {
    color: white;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 14px 26px rgba(16, 185, 129, 0.24);
}

.ip-btn-success:hover:not(:disabled) {
    box-shadow: 0 18px 32px rgba(16, 185, 129, 0.34);
}

.ip-btn-warning {
    color: #451a03;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 14px 26px rgba(245, 158, 11, 0.24);
}

.ip-btn-warning:hover:not(:disabled) {
    box-shadow: 0 18px 32px rgba(245, 158, 11, 0.34);
}

.ip-btn-danger {
    color: white;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    box-shadow: 0 14px 26px rgba(239, 68, 68, 0.24);
}

.ip-btn-danger:hover:not(:disabled) {
    box-shadow: 0 18px 32px rgba(239, 68, 68, 0.34);
}

.ip-btn-info {
    color: white;
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    box-shadow: 0 14px 26px rgba(6, 182, 212, 0.24);
}

.ip-btn-info:hover:not(:disabled) {
    box-shadow: 0 18px 32px rgba(6, 182, 212, 0.34);
}

.ip-btn-icon-only {
    min-width: 44px;
    padding: 0.75rem;
    font-size: 1.1rem;
}

.ip-btn-sm {
    min-height: 36px;
    padding: 0.45rem 0.9rem;
    font-size: 0.84rem;
    border-radius: 0.7rem;
}

/* ==========================================================
   CARDS
   ========================================================== */
.ip-card {
    padding: 1rem 1.15rem;
    border-radius: var(--ip-radius);
    background: var(--ip-bg-card);
    border: 1px solid rgba(148, 163, 184, 0.12);
    transition: transform 0.2s ease, border-color 0.2s ease;
    color: inherit;
    text-decoration: none;
    display: block;
}

.ip-card.clickable:hover {
    transform: translateY(-2px);
    border-color: var(--ip-border-hi);
}

.ip-card.ferma {
    background: linear-gradient(180deg, rgba(69, 10, 10, 0.35) 0%, rgba(31, 41, 55, 0.6) 100%);
    border-color: rgba(239, 68, 68, 0.22);
}

.ip-card.archiviata {
    opacity: 0.7;
    border-style: dashed;
}

/* ==========================================================
   BADGES
   ========================================================== */
.ip-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.32rem 0.7rem;
    border-radius: var(--ip-radius-pill);
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.ip-badge-red { background: rgba(239, 68, 68, 0.14); color: #fca5a5; }
.ip-badge-orange { background: rgba(249, 115, 22, 0.14); color: #fdba74; }
.ip-badge-yellow { background: rgba(245, 158, 11, 0.14); color: #fde68a; }
.ip-badge-blue { background: rgba(59, 130, 246, 0.14); color: #93c5fd; }
.ip-badge-green { background: rgba(16, 185, 129, 0.14); color: #86efac; }
.ip-badge-slate { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }
.ip-badge-purple { background: rgba(168, 85, 247, 0.14); color: #d8b4fe; }
.ip-badge-cyan { background: rgba(6, 182, 212, 0.14); color: #67e8f9; }

/* Priority mapping */
.ip-badge.priority-urgente { background: rgba(168, 85, 247, 0.14); color: #d8b4fe; }
.ip-badge.priority-alta { background: rgba(249, 115, 22, 0.14); color: #fdba74; }
.ip-badge.priority-normale { background: rgba(59, 130, 246, 0.14); color: #93c5fd; }
.ip-badge.priority-bassa { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }

/* ==========================================================
   PROGRESS BAR
   ========================================================== */
.ip-progress {
    height: 0.55rem;
    border-radius: var(--ip-radius-pill);
    background: rgba(148, 163, 184, 0.16);
    overflow: hidden;
}

.ip-progress-fill {
    height: 100%;
    border-radius: inherit;
    transition: width 0.4s ease;
}

.ip-progress-fill.blue { background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%); }
.ip-progress-fill.yellow { background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%); }
.ip-progress-fill.green { background: linear-gradient(90deg, #10b981 0%, #34d399 100%); }
.ip-progress-fill.purple { background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 100%); }
.ip-progress-fill.cyan { background: linear-gradient(90deg, #06b6d4 0%, #67e8f9 100%); }
.ip-progress-fill.red { background: linear-gradient(90deg, #ef4444 0%, #f87171 100%); }

/* ==========================================================
   FORM CONTROLS
   ========================================================== */
.ip-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.1rem;
}

.ip-form-label {
    font-weight: 600;
    font-size: 0.84rem;
    color: var(--ip-text);
}

.ip-input,
.ip-select,
.ip-textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: rgba(15, 23, 42, 0.45);
    color: var(--ip-text-strong);
    border: 1.5px solid rgba(148, 163, 184, 0.22);
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ip-input::placeholder,
.ip-textarea::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

.ip-input:focus,
.ip-select:focus,
.ip-textarea:focus {
    outline: none;
    border-color: var(--ip-accent-blue-hi);
    background: rgba(15, 23, 42, 0.65);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.ip-textarea {
    resize: vertical;
    min-height: 80px;
}

.ip-select option {
    background: var(--ip-bg-dark-2);
    color: var(--ip-text-strong);
}

/* ==========================================================
   ALERT / STATE BOX
   ========================================================== */
.ip-alert {
    padding: 1rem 1.2rem;
    border-radius: var(--ip-radius);
    border: 1px solid var(--ip-border);
    font-size: 0.9rem;
}

.ip-alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.22);
    color: #93c5fd;
}

.ip-alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.22);
    color: #fca5a5;
}

.ip-alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.22);
    color: #fde68a;
}

.ip-alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.22);
    color: #86efac;
}

.ip-empty {
    display: grid;
    gap: 0.3rem;
    padding: 1.5rem;
    text-align: center;
    border-radius: var(--ip-radius);
    background: rgba(15, 23, 42, 0.55);
    border: 1px dashed rgba(148, 163, 184, 0.22);
    color: var(--ip-text-muted);
}

.ip-empty strong {
    color: var(--ip-text-strong);
    font-size: 1rem;
}

.ip-empty span {
    color: var(--ip-text-muted);
    font-size: 0.85rem;
}

/* ==========================================================
   LOADING / SPINNER
   ========================================================== */
.ip-loading {
    display: grid;
    place-items: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ip-text-muted);
    gap: 1rem;
}

.ip-orb {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    border: 4px solid rgba(148, 163, 184, 0.18);
    border-top-color: #60a5fa;
    animation: ip-spin 1s linear infinite;
}

.ip-orb-sm {
    width: 28px;
    height: 28px;
    border-width: 3px;
}

@keyframes ip-spin { to { transform: rotate(360deg); } }

/* ==========================================================
   MODAL
   ========================================================== */
.ip-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 10, 24, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    animation: ip-fade-in 0.15s ease;
}

@keyframes ip-fade-in { from { opacity: 0; } to { opacity: 1; } }

.ip-modal {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius-lg);
    box-shadow: 0 30px 80px rgba(2, 6, 23, 0.6);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ip-pop-in 0.18s ease;
}

.ip-modal-lg { max-width: 820px; }

@keyframes ip-pop-in {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: translateY(0); }
}

.ip-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--ip-border);
}

.ip-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--ip-text-strong);
    letter-spacing: -0.01em;
}

.ip-modal-close {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--ip-border);
    color: var(--ip-text);
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.7rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: grid;
    place-items: center;
}

.ip-modal-close:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: var(--ip-border-hi);
    color: white;
}

.ip-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.ip-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    padding: 1.1rem 1.5rem;
    border-top: 1px solid var(--ip-border);
    background: rgba(8, 15, 29, 0.5);
}

/* ==========================================================
   INFO GRID / KV PAIRS
   ========================================================== */
.ip-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.ip-info-item {
    display: grid;
    gap: 0.2rem;
}

.ip-info-item .ip-info-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--ip-text-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ip-info-item .ip-info-value {
    color: var(--ip-text-strong);
    font-weight: 500;
}

/* ==========================================================
   FORM GRID
   ========================================================== */
.ip-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.ip-form-grid .full-width { grid-column: 1 / -1; }

@media (max-width: 640px) {
    .ip-form-grid { grid-template-columns: 1fr; }
}

/* ==========================================================
   PAGE HEADER (h1 + actions)
   ========================================================== */
.ip-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.4rem 0.2rem;
}

.ip-page-header h1 {
    margin: 0 0 0.35rem;
    color: var(--ip-text-strong);
    font-size: 1.75rem;
    letter-spacing: -0.02em;
}

.ip-page-header .ip-subtitle {
    margin: 0;
    color: var(--ip-text-muted);
    font-size: 0.95rem;
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 1100px) {
    .ip-hero-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .ip-hero { padding: 1.3rem; }
    .ip-section { padding: 1.1rem; border-radius: var(--ip-radius); }
    .ip-page { gap: 1rem; }
}
