:root {
    --bg-body: #F4F4F9; --bg-card: #ffffff; --text-main: #2B2D42; --text-muted: #555555;
    --text-title: #28AD9F; --border-color: #DDDDDD; --input-bg: #ffffff; 
    --btn-role-bg: #EDF2F4; --btn-role-active-bg: #D8F3DC; --task-bg: #ffffff; 
    --shadow: rgba(0,0,0,0.12); --progress-empty: #E9ECEF; 
    --accent-red: #D0192F; --premium-gold: #FFC107; --premium-gold-hover: #E0A800;
    --btn-role-active-text: #28AD9F; 
}

body.dark-mode {
    --bg-body: #1D1E33; --bg-card: #2B2D42; --text-main: #FFFFFF; --text-muted: #BCC2CD;
    --border-color: #4A4D61; --input-bg: #1D1E33; --btn-role-bg: #1D1E33;
    --btn-role-active-bg: #28AD9F; --task-bg: #1D1E33;
    --btn-role-active-text: #FFFFFF; 
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Carlito', sans-serif; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg-body); color: var(--text-main); line-height: 1.6; display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 10px; }

.global-nav { width: 100%; max-width: 500px; display: flex; justify-content: space-between; padding: 10px 0; margin-bottom: 10px; }
.nav-col { display: flex; align-items: center; gap: 8px; }
.nav-stack { flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.nav-widget { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-main); padding: 6px 10px; border-radius: 8px; font-weight: bold; cursor: pointer; }
.nav-badge { font-size: 11px; font-weight: bold; color: var(--text-muted); }
.logout-nav-btn { background: var(--bg-body); color: var(--text-title); border: 2px solid var(--text-title); padding: 8px 16px; font-size: 14px; }

.container { width: 100%; max-width: 500px; margin: 0 auto; }
.card { background: var(--bg-card); border-radius: 20px; padding: 25px 20px; box-shadow: 0 8px 20px var(--shadow); width: 100%; transition: background 0.3s; }

.title { text-align: center; color: var(--text-title); font-size: 32px; margin-bottom: 5px; }
.subtitle { text-align: center; color: var(--text-muted); font-size: 16px; margin-bottom: 30px; }

.role-selector { display: flex; gap: 10px; margin-bottom: 25px; }
.role-btn { flex: 1; padding: 15px; border: 2px solid transparent; background: var(--btn-role-bg); color: var(--text-main); border-radius: 12px; font-weight: bold; font-size: 16px; transition: all 0.2s; cursor: pointer; }
.role-btn.active { background: var(--btn-role-active-bg); border-color: var(--text-title); color: var(--btn-role-active-text); }

.input-group { margin-bottom: 20px; }
label { display: block; font-weight: bold; margin-bottom: 8px; color: var(--text-main); }
input[type="text"], input[type="number"], .styled-select { width: 100%; padding: 14px; border: 2px solid var(--border-color); border-radius: 12px; font-size: 16px; background: var(--input-bg); color: var(--text-main); outline: none; transition: border 0.3s; }
input[type="text"]:focus, input[type="number"]:focus, .styled-select:focus { border-color: var(--text-title); }
.input-hint { font-size: 13px; color: var(--text-muted); margin-top: 5px; }

.checkbox-row { margin-bottom: 15px; }
.checkbox-container { display: flex; align-items: center; position: relative; padding-left: 35px; cursor: pointer; font-size: 15px; user-select: none; }
.checkbox-container input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark { position: absolute; top: 0; left: 0; height: 24px; width: 24px; background-color: var(--input-bg); border: 2px solid var(--border-color); border-radius: 6px; transition: all 0.2s; }
.checkbox-container:hover input ~ .checkmark { border-color: var(--text-title); }
.checkbox-container input:checked ~ .checkmark { background-color: var(--text-title); border-color: var(--text-title); }
.checkmark:after { content: ""; position: absolute; display: none; left: 8px; top: 4px; width: 5px; height: 10px; border: solid white; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.checkbox-container input:checked ~ .checkmark:after { display: block; }
.checkbox-label { line-height: 1.4; }

.legal-link { color: #17665D; text-decoration: underline; font-weight: 700; font-size: 16px; }
body.dark-mode .legal-link { color: #4DEEEA; }

.primary-btn, .primary-action-btn, .secondary-btn { width: 100%; padding: 16px; border: none; border-radius: 12px; font-size: 18px; font-weight: bold; cursor: pointer; transition: transform 0.1s, background 0.2s; }
.primary-btn { background: var(--text-title); color: #ffffff; margin-top: 10px; }
.primary-action-btn { background: var(--text-title); color: #ffffff; margin-top: 15px; }
.primary-btn:hover, .primary-action-btn:hover { background: #208b7f; }

.dashboard-top-row { display: flex; gap: 10px; margin-bottom: 20px; }
.info-box { flex: 1; background: var(--btn-role-bg); padding: 12px; border-radius: 12px; border: 1px solid var(--border-color); }
.flex-box { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; }
.info-text-compact { font-size: 14px; margin-bottom: 8px; line-height: 1.3; }

.share-btn { background: #E0E0E0; color: #333; border: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: bold; cursor: pointer; align-self: flex-start; }
.dark-mode .share-btn { background: #333; color: #FFF; }

.badge-base { background: #6c757d; color: white; padding: 3px 8px; border-radius: 6px; font-size: 13px; margin-left: 5px; }
.badge-premium { background: var(--premium-gold); color: #000; padding: 3px 8px; border-radius: 6px; font-size: 13px; margin-left: 5px; }

.premium-btn { background: var(--premium-gold); color: #000; font-size: 14px; padding: 8px; border-radius: 8px; border: none; font-weight: bold; cursor: pointer; width: 100%; margin-top: 5px; }
.premium-btn:hover { background: var(--premium-gold-hover); }
.premium-coffee-text { display: block; font-size: 11px; text-align: center; color: var(--text-muted); margin-top: 4px; }

.admin-section { background: var(--btn-role-bg); padding: 15px; border-radius: 12px; margin-bottom: 15px; }
.admin-section h2 { font-size: 16px; margin-bottom: 10px; }
.setup-row { display: flex; gap: 10px; margin-top: 8px; margin-bottom: 10px; }
.options-row { margin-bottom: 10px; }

.thin-line { border: 0; height: 1px; background: var(--border-color); margin: 20px 0; }
.separator { border: 0; height: 2px; background: var(--border-color); margin: 25px 0; }

.secondary-btn { background: #e0e0e0; color: #333; margin-top: 10px; font-size: 16px; padding: 12px; }
.dark-mode .secondary-btn { background: #4A4D61; color: #FFF; }

/* Gestione Reset buttons */
.reset-buttons-row { width: 100%; }
.reset-btn-large { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; background: #FFE5E5; color: var(--accent-red); font-size: 14px; width: 100%; }
.dark-mode .reset-btn-large { background: rgba(208, 25, 47, 0.2); }

.requests-list { list-style: none; margin-top: 10px; }
.request-item { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.request-actions { display: flex; gap: 8px; }
.btn-accept { background: var(--btn-role-active-bg); color: var(--btn-role-active-text); border: none; padding: 6px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; transition: transform 0.1s; }
.btn-reject { background: #FFE5E5; color: var(--accent-red); border: none; padding: 6px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; transition: transform 0.1s; }
.dark-mode .btn-reject { background: rgba(208, 25, 47, 0.2); }
.btn-accept:active, .btn-reject:active { transform: scale(0.9); }

/* Stile per Bacheche Dinamiche Premi */
.reward-board { background: var(--btn-role-bg); padding: 15px; border-radius: 12px; margin-bottom: 20px; border: 2px solid var(--border-color); }
.reward-info { font-size: 18px; width: 100%; margin-bottom: 10px; }
.reward-highlight { color: var(--text-title); font-weight: bold; font-size: 20px; }
.delete-reward-btn { background: #FFE5E5; color: var(--accent-red); border: none; border-radius: 6px; padding: 6px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.dark-mode .delete-reward-btn { background: rgba(208, 25, 47, 0.2); }

.progress-bar-segmented { display: flex; gap: 3px; width: 100%; height: 24px; background: transparent; }
.progress-segment { flex: 1; background: var(--progress-empty); height: 100%; border-radius: 4px; transition: background 0.3s ease; }
.progress-segment.filled { background: var(--text-title); }
.progress-segment:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.progress-segment:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

.task-item { background: var(--task-bg); padding: 15px; border-radius: 12px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: bold; width: 100%; margin-bottom: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.task-item.completed { opacity: 0.6; text-decoration: line-through; background: var(--btn-role-active-bg); border-color: var(--text-title); }
.task-text { flex: 1; word-break: break-word; margin-right: 10px; color: var(--text-main); }
.task-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.btn-task { border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: bold; transition: transform 0.1s; display: inline-block; }
.btn-task:active { transform: scale(0.9); }
.btn-complete { background: var(--btn-role-active-bg); color: var(--btn-role-active-text); }
.btn-delete { background: #FFE5E5; color: var(--accent-red); }

.history-item { background: var(--bg-card); padding: 10px 15px; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 8px; font-size: 14px; color: var(--text-main); font-weight: bold; }

/* --- REGOLE RTL (Right-to-Left) PER LA LINGUA ARABA --- */
html[dir="rtl"] .progress-segment:first-child { border-radius: 0 12px 12px 0; }
html[dir="rtl"] .progress-segment:last-child { border-radius: 12px 0 0 12px; }
html[dir="rtl"] .task-text { margin-right: 0; margin-left: 10px; }
html[dir="rtl"] .nav-col.left { flex-direction: row-reverse; }
html[dir="rtl"] .nav-col.right { flex-direction: row-reverse; }
html[dir="rtl"] .checkbox-container { padding-left: 0; padding-right: 35px; }
html[dir="rtl"] .checkmark { left: auto; right: 0; }
html[dir="rtl"] .checkmark:after { left: auto; right: 8px; }