/* StudioWorkflow — Componenti UI */

/* ========================================================================
   BUTTONS
   ======================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-text);
    border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-success {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-alt); }

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-alt); color: var(--color-text); }

.btn-link {
    background: transparent;
    color: var(--color-primary);
    border: 0;
    padding: 0;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
}
.btn-link:hover:not(:disabled) { text-decoration: underline; }

.btn-lg { padding: var(--space-4) var(--space-6); font-size: var(--fs-base); }
.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--fs-xs); }

/* ========================================================================
   FORM
   ======================================================================== */
.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.form-row label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text);
}
.form-row input,
.form-row select,
.form-row textarea {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    background: var(--color-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-row textarea { min-height: 100px; resize: vertical; }

.form-error {
    color: var(--color-danger);
    font-size: var(--fs-xs);
}

.form-grid {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: 1fr;
    max-width: 600px;
}
.form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    align-items: center;
    margin-top: var(--space-4);
}
.form-actions-stretch .btn { flex: 1; }

.form-alert {
    padding: var(--space-3) var(--space-4);
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
}

/* ========================================================================
   PAGE HEADER
   ======================================================================== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.page-header h1 {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    margin-bottom: var(--space-1);
}
.page-subtitle {
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}
.page-actions {
    display: flex;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* ========================================================================
   FLASH MESSAGES
   ======================================================================== */
.flash {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    margin: 0 var(--space-6) var(--space-4);
    font-size: var(--fs-sm);
}
.flash-success { background: var(--color-success-bg); color: var(--color-success); }
.flash-error   { background: var(--color-danger-bg);  color: var(--color-danger); }
.flash-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.flash-info    { background: var(--color-info-bg);    color: var(--color-info); }

/* ========================================================================
   DATA TABLE
   ======================================================================== */
.data-table {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table th,
.data-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--color-border);
}
.data-table th {
    background: var(--color-surface-alt);
    font-weight: var(--fw-semi);
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: 0.05em;
}
.data-table tbody tr:hover { background: var(--color-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: 0; }

/* ========================================================================
   STAT GRID
   ======================================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}
.stat-value {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    color: var(--color-text);
}
.stat-value-accent  { color: var(--color-primary); }
.stat-value-warning { color: var(--color-warning); }
.stat-link {
    display: inline-block;
    margin-top: var(--space-3);
    font-size: var(--fs-sm);
    color: var(--color-primary);
    font-weight: var(--fw-medium);
}

/* ========================================================================
   DASHBOARD COLUMNS
   ======================================================================== */
.dashboard-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}
@media (max-width: 900px) {
    .dashboard-columns { grid-template-columns: 1fr; }
}

.dashboard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}
.dashboard-card-header h2 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semi);
}

.deadline-list,
.task-list {
    padding: var(--space-2);
}
.deadline-item,
.task-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
}
.deadline-item:hover,
.task-item:hover { background: var(--color-surface-alt); }

.deadline-date {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    min-width: 70px;
    text-align: center;
    text-transform: uppercase;
}
.deadline-body strong,
.task-body a {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text);
}
.deadline-body small,
.task-body small {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

.task-priority {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-weight: var(--fw-bold);
    font-size: var(--fs-xs);
}
.task-priority-urgente { background: var(--color-prio-urgente); }
.task-priority-alta    { background: var(--color-prio-alta); }
.task-priority-media   { background: var(--color-prio-media); }
.task-priority-bassa   { background: var(--color-prio-bassa); }

.empty-state {
    padding: var(--space-8);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}

/* ========================================================================
   NOTIFICATION BELL
   ======================================================================== */
.notif-bell {
    position: relative;
}
.notif-bell-trigger {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    transition: background var(--transition-fast);
}
.notif-bell-trigger:hover { background: var(--color-surface-alt); }
.notif-bell-icon { font-size: var(--fs-lg); }
.notif-bell-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: var(--color-danger);
    color: white;
    font-size: 10px;
    font-weight: var(--fw-bold);
    min-width: 18px; height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-bell-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.notif-bell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.notif-bell-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}
.notif-bell-list .notif-item {
    padding: var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    border-left: 3px solid transparent;
}
.notif-bell-list .notif-item:hover { background: var(--color-surface-alt); }
.notif-bell-list .notif-item.is-unread {
    border-left-color: var(--color-primary);
    background: var(--color-primary-light);
}
.notif-bell-list .notif-item strong { display: block; font-size: var(--fs-sm); }
.notif-bell-list .notif-item small { color: var(--color-text-muted); font-size: var(--fs-xs); }
.notif-bell-empty {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}
.notif-bell-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--color-border);
    text-align: center;
}

/* ========================================================================
   TOAST
   ======================================================================== */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.toast {
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: slideIn var(--transition);
}
.toast-success { border-left-color: var(--color-success); }
.toast-error   { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-title   { font-weight: var(--fw-semi); font-size: var(--fs-sm); }
.toast-body    { font-size: var(--fs-sm); color: var(--color-text-muted); margin-top: var(--space-1); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ========================================================================
   ERROR PAGES
   ======================================================================== */
.error-page {
    text-align: center;
    padding: var(--space-12);
}
.error-code {
    font-size: 6rem;
    font-weight: var(--fw-bold);
    color: var(--color-text-light);
    line-height: 1;
}
.error-page h1 {
    font-size: var(--fs-2xl);
    margin: var(--space-4) 0;
}
.error-page p {
    color: var(--color-text-muted);
    margin-bottom: var(--space-6);
}
.error-ref { font-size: var(--fs-xs); }

/* ========================================================================
   STATUS BADGES
   ======================================================================== */
.status-badge {
    display: inline-flex;
    padding: var(--space-1) var(--space-3);
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-attiva, .status-active { background: var(--color-success-bg); color: var(--color-success); }
.status-sospesa, .status-sospeso, .status-suspended { background: var(--color-warning-bg); color: var(--color-warning); }
.status-chiusa, .status-archiviata { background: var(--color-surface-alt); color: var(--color-text-muted); }
