/* ============================================================
   Workspace Piro89 — Tema editoriale, mobile-first
   Mobile = base styles; desktop = @media (min-width: 880px)
   ============================================================ */

:root {
    --p-bg:        #FAF7F2;
    --p-surface:   #FFFFFF;
    --p-border:    #E7E2D9;
    --p-border-2:  #D6CFC2;
    --p-ink:       #15233B;
    --p-ink-soft:  #4A5468;
    --p-muted:     #8A8576;

    --p-primary:        #15233B;
    --p-primary-hover:  #0B1729;
    --p-accent:         #B85A2C;
    --p-accent-hover:   #9C4A22;

    --p-success:  #3B7D5C;
    --p-warning:  #C8973A;
    --p-danger:   #B8443D;

    --p-font-display: 'Fraunces', 'Times New Roman', serif;
    --p-font-body:    'Outfit', system-ui, sans-serif;

    --p-sidebar-w:  260px;
    --p-radius:     10px;
    --p-radius-sm:  6px;
    --p-shadow:     0 1px 2px rgba(21,35,59,0.04), 0 4px 16px rgba(21,35,59,0.05);
    --p-shadow-lg:  0 8px 28px rgba(21,35,59,0.18);

    --p-topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--p-bg);
    color: var(--p-ink);
    font-family: var(--p-font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: none;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--p-font-display);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--p-ink);
    margin: 0 0 0.5em;
}

h1 { font-size: 1.7rem; line-height: 1.15; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--p-accent); text-decoration: none; }
a:hover { color: var(--p-accent-hover); }

/* ============================================================
   LAYOUT (mobile-first)
   ============================================================ */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Topbar mobile */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--p-topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--p-primary);
    color: #fff;
    padding: 0 14px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
.app-topbar .brand {
    font-family: var(--p-font-display);
    font-size: 1.15rem;
    font-weight: 500;
    color: #fff;
}
.app-topbar .brand small {
    font-family: var(--p-font-body);
    font-size: 0.7rem;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-left: 8px;
}
.hamburger {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--p-radius-sm);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, border-color 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,0.08); }
.hamburger:focus-visible {
    outline: 2px solid #E9C9A8;
    outline-offset: 2px;
}
.hamburger svg { width: 22px; height: 22px; }
.topbar-spacer { width: 44px; }

/* Sidebar (chiusa su mobile) */
.app-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: min(86vw, var(--p-sidebar-w));
    height: 100vh;
    height: 100dvh;
    background: var(--p-primary);
    color: #E9E4D8;
    padding: 24px 18px 28px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: var(--p-shadow-lg);
    overflow-y: auto;
}
.app-sidebar.is-open { left: 0; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11,23,41,0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 18px;
}
.sidebar-header .brand {
    font-family: var(--p-font-display);
    font-size: 1.4rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.1;
}
.sidebar-header .brand small {
    display: block;
    font-family: var(--p-font-body);
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-top: 4px;
}
.sidebar-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--p-radius-sm);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidebar-close svg { width: 18px; height: 18px; }

.app-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: rgba(255,255,255,0.78);
    border-radius: var(--p-radius-sm);
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.app-sidebar nav a:hover,
.app-sidebar nav a:focus-visible {
    background: rgba(255,255,255,0.06);
    color: #fff;
    outline: none;
}
.app-sidebar nav a.is-active {
    background: rgba(255,255,255,0.10);
    color: #fff;
    font-weight: 500;
}
.app-sidebar nav a svg {
    width: 20px;
    height: 20px;
    opacity: 0.85;
    flex-shrink: 0;
}

.user-card {
    margin-top: auto;
    padding: 14px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: var(--p-radius-sm);
}
.user-card .name {
    color: #fff;
    font-size: 0.92rem;
    font-weight: 500;
}
.user-card .email {
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
    margin-top: 2px;
    word-break: break-all;
}
.user-card a {
    display: inline-block;
    margin-top: 10px;
    color: #E9C9A8;
    font-size: 0.85rem;
}

.app-main { display: block; }

.app-content {
    padding: 20px 16px 60px;
    max-width: 100%;
}

.page-header {
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--p-border);
}
.page-header .eyebrow {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: var(--p-muted);
    margin-bottom: 6px;
}
.page-header h1 { margin: 0; }
.page-header .text-muted-p { margin-top: 6px; }
.page-header .actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Card */
.card-p {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 18px;
    box-shadow: var(--p-shadow);
    margin-bottom: 16px;
}
.card-p > h3:first-child,
.card-p > h2:first-child { margin-top: 0; }

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-label {
    display: block;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--p-ink-soft);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control,
.form-select {
    width: 100%;
    padding: 11px 12px;
    background: var(--p-surface);
    border: 1px solid var(--p-border-2);
    border-radius: var(--p-radius-sm);
    font-family: var(--p-font-body);
    font-size: 16px;
    color: var(--p-ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
.form-select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2315233B' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
select[multiple].form-select {
    min-height: 160px;
    background-image: none;
    padding-right: 12px;
}
.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--p-accent);
    box-shadow: 0 0 0 3px rgba(184,90,44,0.15);
}
textarea.form-control { min-height: 110px; resize: vertical; }

/* Buttons */
.btn-p {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--p-radius-sm);
    border: 1px solid transparent;
    font-family: var(--p-font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1;
    min-height: 42px;
    -webkit-tap-highlight-color: transparent;
}
.btn-p svg { width: 16px; height: 16px; }
.btn-primary-p { background: var(--p-primary); color: #fff; }
.btn-primary-p:hover { background: var(--p-primary-hover); color: #fff; }
.btn-accent-p { background: var(--p-accent); color: #fff; }
.btn-accent-p:hover { background: var(--p-accent-hover); color: #fff; }
.btn-ghost-p { background: transparent; color: var(--p-ink); border-color: var(--p-border-2); }
.btn-ghost-p:hover { background: var(--p-bg); }
.btn-danger-p { background: var(--p-danger); color: #fff; }
.btn-danger-p:hover { background: #95342E; color: #fff; }
.btn-sm-p { padding: 7px 12px; font-size: 0.82rem; min-height: 32px; }
.btn-block-p { width: 100%; }

/* Badge */
.badge-p {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    white-space: nowrap;
}
.badge-confermato    { background: rgba(59,125,92,0.13);  color: var(--p-success); }
.badge-da-confermare { background: rgba(200,151,58,0.18); color: #8A6219; }
.badge-annullato     { background: rgba(184,68,61,0.13);  color: var(--p-danger); }

/* Tables */
.table-p {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    overflow: hidden;
    font-size: 0.92rem;
}
.table-p th, .table-p td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--p-border);
}
.table-p th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--p-muted);
    background: var(--p-bg);
    font-weight: 500;
}
.table-p tr:last-child td { border-bottom: none; }

/* Alerts */
.alert-p {
    border-left: 3px solid var(--p-border-2);
    background: var(--p-surface);
    padding: 12px 14px;
    border-radius: var(--p-radius-sm);
    margin-bottom: 14px;
    font-size: 0.93rem;
}
.alert-danger-p  { border-left-color: var(--p-danger);  background: #FBF2F1; }
.alert-success-p { border-left-color: var(--p-success); background: #F1F7F3; }
.alert-warning-p { border-left-color: var(--p-warning); background: #FBF6EA; }

/* Image grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}
.image-grid .image-tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--p-radius-sm);
    overflow: hidden;
    background: var(--p-border);
    border: 1px solid var(--p-border);
}
.image-grid .image-tile img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.image-grid .image-tile .overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    display: flex;
    justify-content: flex-end;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.week-greeting { margin-bottom: 18px; }
.week-greeting .week-range {
    color: var(--p-muted);
    font-size: 0.92rem;
    margin-top: 4px;
}

.week-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 14px;
    box-shadow: var(--p-shadow);
}
.stat-card .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--p-muted);
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-family: var(--p-font-display);
    font-size: 1.7rem;
    line-height: 1;
    color: var(--p-ink);
}
.stat-card.stat-warn .stat-value { color: var(--p-warning); }
.stat-card.stat-ok .stat-value   { color: var(--p-success); }

.todo-section { margin-bottom: 26px; }
.todo-section .section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.todo-section .section-title svg {
    width: 18px; height: 18px;
    color: var(--p-warning);
    flex-shrink: 0;
}
.todo-section h2 { margin: 0; }

.day-block { margin-bottom: 22px; }
.day-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--p-border);
}
.day-header.is-today { border-bottom-color: var(--p-accent); }
.day-header .day-name {
    font-family: var(--p-font-display);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--p-ink);
}
.day-header.is-today .day-name { color: var(--p-accent); }
.day-header .day-date { font-size: 0.85rem; color: var(--p-muted); }
.day-header .today-pill {
    background: var(--p-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 8px;
}

.event-card {
    display: block;
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-left: 3px solid var(--p-warning);
    border-radius: var(--p-radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--p-shadow);
    color: inherit;
    text-decoration: none;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.event-card:hover,
.event-card:focus-visible {
    color: inherit;
    box-shadow: var(--p-shadow-lg);
    outline: none;
}
.event-card:active { transform: scale(0.99); }
.event-card.event-confermato    { border-left-color: var(--p-success); }
.event-card.event-da-confermare { border-left-color: var(--p-warning); }
.event-card.event-annullato     { border-left-color: var(--p-danger); opacity: 0.7; }

.event-card .event-row1 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}
.event-card .event-time {
    font-family: var(--p-font-display);
    font-size: 0.92rem;
    color: var(--p-muted);
    flex-shrink: 0;
}
.event-card .event-title {
    font-family: var(--p-font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--p-ink);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event-card .event-meta {
    font-size: 0.85rem;
    color: var(--p-ink-soft);
    margin-top: 4px;
}
.event-card .event-meta .sep {
    color: var(--p-muted);
    margin: 0 6px;
}

.empty-day {
    color: var(--p-muted);
    font-style: italic;
    font-size: 0.9rem;
    padding: 6px 0 4px;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    background: var(--p-bg);
}
.login-shell .login-art { display: none; }
.login-shell .login-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    min-height: 100vh;
    min-height: 100dvh;
}
.login-shell .login-card {
    width: 100%;
    max-width: 380px;
}
.login-shell .login-card h2 { margin: 0 0 4px; }
.login-shell .login-card .subtitle {
    color: var(--p-muted);
    font-size: 0.9rem;
    margin: 0 0 24px;
}

/* ============================================================
   FullCalendar
   ============================================================ */
#calendar {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 12px;
    box-shadow: var(--p-shadow);
}
.fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1em !important;
}
.fc .fc-toolbar-title {
    font-family: var(--p-font-display);
    font-weight: 500;
    font-size: 1.2em !important;
}
.fc .fc-button {
    background: var(--p-surface) !important;
    border: 1px solid var(--p-border-2) !important;
    color: var(--p-ink) !important;
    text-transform: none !important;
    font-weight: 500 !important;
    box-shadow: none !important;
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
}
.fc .fc-button:hover { background: var(--p-bg) !important; }
.fc .fc-button-active,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: var(--p-primary) !important;
    color: #fff !important;
    border-color: var(--p-primary) !important;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted-p { color: var(--p-muted); }
.mb-0-p { margin-bottom: 0; }
.mt-2-p { margin-top: 8px; }
.mt-4-p { margin-top: 16px; }
.flex-row-p { display: flex; gap: 10px; flex-wrap: wrap; }
.justify-between-p { justify-content: space-between; }
.text-end-p { text-align: right; }

/* ============================================================
   DESKTOP (≥ 880px)
   ============================================================ */
@media (min-width: 880px) {
    .app-shell {
        display: grid;
        grid-template-columns: var(--p-sidebar-w) 1fr;
    }
    .app-topbar { display: none; }
    .app-sidebar {
        position: sticky;
        top: 0;
        left: 0;
        height: 100vh;
        box-shadow: none;
        transition: none;
        width: var(--p-sidebar-w);
    }
    .sidebar-backdrop { display: none !important; }
    .sidebar-close { display: none; }

    .app-content {
        padding: 36px 44px;
        max-width: 1200px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.55rem; }

    .form-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
    .week-stats { grid-template-columns: repeat(4, 1fr); gap: 14px; }
    .stat-card { padding: 18px; }
    .stat-card .stat-value { font-size: 2rem; }
    .image-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }

    .login-shell { grid-template-columns: 1fr 1fr; }
    .login-shell .login-art {
        display: flex;
        background: var(--p-primary);
        color: #fff;
        padding: 60px;
        flex-direction: column;
        justify-content: space-between;
        position: relative;
        overflow: hidden;
    }
    .login-shell .login-art::before {
        content: "";
        position: absolute;
        inset: -40% -10% auto auto;
        width: 480px; height: 480px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(184,90,44,0.35), transparent 65%);
    }
    .login-shell .login-art h1 {
        color: #fff;
        font-size: 2.6rem;
        line-height: 1.05;
        max-width: 380px;
        position: relative;
    }
    .login-shell .login-art h1 em {
        font-style: italic;
        color: #E9C9A8;
    }
    .login-shell .login-art .signature {
        font-family: var(--p-font-display);
        font-style: italic;
        color: rgba(255,255,255,0.6);
        position: relative;
    }

    #calendar { padding: 20px; }
}
