/* ============================
   BASE
============================ */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* ============================
   LAYOUT
============================ */
.dashboard {
    display: flex;
    height: 100vh;
}

/* ============================
   SIDEBAR
============================ */
.sidebar {
    background: #1f1f1f;
    color: white;
    padding: 20px;
    width: 230px;
}

.sidebar h2 {
    margin-top: 0;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
}

.sidebar li i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar li:hover {
    background: #333;
}

.sidebar li.active {
    background: #0077ff;
    color: white;
}

/* ============================
   CONTENUTO
============================ */
.content {
    flex: 1;
    padding: 0 30px;
    background: white;
}

/* ============================
   TOPBAR
============================ */
.topbar {
    position: sticky;
    top: 0;
    background: white;
    padding: 15px 0;
    z-index: 10;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.theme-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

/* ============================
   CARD
============================ */
.card {
    background: #ffffff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid #e5e5e5;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.card h3 {
    margin-bottom: 10px;
    font-size: 18px;
    color: #333;
}

/* TEXTAREA */
.card textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

.card textarea:focus {
    border-color: #0077ff;
}

/* ============================
   BUTTON SALVA
============================ */
.card button {
    margin-top: 10px;
    padding: 10px 18px;
    background: #0077ff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s ease;
}

.card button:hover {
    background: #005fcc;
}

/* ============================
   BUTTON SALVA TUTTO
============================ */
.save-all-btn {
    padding: 10px 18px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s ease;
}

.save-all-btn:hover {
    background: #1f8a36;
}

/* ============================
   LOADER
============================ */
.loader {
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top-color: #0077ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

.hidden {
    display: none;
}

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

/* MINI LOADER NEI PULSANTI */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    width: 14px;
    height: 14px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    transform: translateY(-50%);
}

/* STATO SALVATO */
.btn-saved {
    background: #28a745 !important;
    color: white !important;
}

/* INDICATORE MODIFICHE */
.modified-indicator {
    color: #d9534f;
    font-size: 14px;
    margin-left: 10px;
    font-weight: bold;
}

/* FLASH SALVATAGGIO */
.card.flash-save {
    animation: flashGreen 0.5s ease;
}

@keyframes flashGreen {
    0% { background-color: #d4f8d4; }
    100% { background-color: #ffffff; }
}

/* ============================
   TOAST
============================ */
#toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #0077ff;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform: translateY(-20px);
    z-index: 9999;
}

#toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ============================
   LOGIN SCREEN
============================ */
.login-screen {
    position: fixed;
    inset: 0;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 300px;
    text-align: center;
}

.login-box input {
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

.login-box button {
    margin-top: 15px;
    width: 100%;
    padding: 10px;
    background: #0077ff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.login-box button:hover {
    background: #005fcc;
}

.error {
    color: red;
    margin-top: 10px;
}

/* ============================
   TEMA SCURO
============================ */
body.dark {
    background: #121212;
    color: #eaeaea;
}

body.dark .sidebar {
    background: #181818;
}

body.dark .card {
    background: #1f1f1f;
    border-color: #333;
}

body.dark textarea {
    background: #2a2a2a;
    color: white;
    border-color: #444;
}

body.dark .save-all-btn {
    background: #1f8a36;
}
