/* style.css (Versione Completa e Corretta) */

/* --- Variabili e Reset Globale --- */
:root {
    --primary-color: #8E44AD;
    --secondary-color: #3498DB;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --background-color: #f4f6f9;
    --font-family: 'Poppins', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background-color: var(--background-color); color: var(--dark-color); line-height: 1.6; display: flex; flex-direction: column; min-height: 100vh; }

/* --- Contenitori Principali --- */
.container { max-width: 500px; margin: 2rem auto; padding: 2rem; background: #fff; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); text-align: center; }

/* --- Moduli (Login/Registrazione/Dashboard) --- */
.form-container h1 { margin-bottom: 1.5rem; color: var(--primary-color); font-size: 2rem; }
.form-group { margin-bottom: 1.5rem; text-align: left; position: relative; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; color: #555; }
.form-group .input-icon {
    position: absolute;
    left: 15px;
    top: calc(50% + 12px);
    transform: translateY(-50%);
    color: #aaa;
}
.form-control { width: 100%; padding: 12px 12px 12px 40px; border: 1px solid #ccc; border-radius: 5px; font-size: 1rem; transition: all 0.3s ease; }
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 5px rgba(142, 68, 173, 0.5); }
.btn { display: inline-block; width: 100%; padding: 15px; border: none; border-radius: 5px; background: linear-gradient(45deg, var(--primary-color), var(--secondary-color)); color: #fff; font-size: 1.1rem; font-weight: 600; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; text-transform: uppercase; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.form-link { margin-top: 1.5rem; font-size: 0.9rem; }
.form-link a { color: var(--primary-color); text-decoration: none; font-weight: 600; }

/* --- Messaggi di Notifica --- */
.alert { padding: 1rem; margin-bottom: 1rem; border-radius: 5px; color: #fff; text-align: center; }
.alert-success { background-color: var(--success-color); }
.alert-danger { background-color: var(--error-color); }

/* --- Dashboard --- */
.dashboard-header { background: #fff; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.dashboard-header .logo { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); text-decoration: none; }
.dashboard-header .user-menu a { color: var(--dark-color); text-decoration: none; margin-left: 1.5rem; font-weight: 600; transition: color 0.2s ease; }
.dashboard-header .user-menu a:hover { color: var(--primary-color); }
.dashboard-header .user-menu .logout-btn { color: var(--error-color); }
.dashboard-container { max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
.add-link-section, .links-list-section, .profile-section, .stats-section { background: #fff; padding: 2rem; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); margin-bottom: 2rem; }
.add-link-section h2, .links-list-section h2, .stats-section h2, .profile-section h2 { text-align: center; margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.link-item { background: #fff; display: flex; align-items: center; padding: 1rem 1.5rem; border-radius: 8px; margin-bottom: 1rem; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.link-item:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.link-item .link-icon { font-size: 1.5rem; color: var(--primary-color); margin-right: 1.5rem; width: 24px; text-align: center; }
.link-item .link-details { flex-grow: 1; }
.link-item .link-title { font-weight: 600; font-size: 1.1rem; margin: 0; }
.link-item .link-url { font-size: 0.9rem; color: #777; word-break: break-all; }
.link-item .link-actions { display: flex; align-items: center; }
.link-item .link-actions a { color: var(--dark-color); text-decoration: none; font-size: 1.2rem; margin-left: 1rem; transition: color 0.2s ease; }
.link-item .link-actions a.edit-btn:hover { color: var(--secondary-color); }
.link-item .link-actions a.delete-btn:hover { color: var(--error-color); }
.link-item.inactive { opacity: 0.6; background: #f8f9fa; }
.link-item.inactive .link-title, .link-item.inactive .link-url { text-decoration: line-through; }
.click-badge { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: #555; font-weight: 600; margin-right: 1.5rem; }
.sortable-ghost { opacity: 0.4; background: #c8ebfb; }

/* --- Pagina Profilo Pubblica --- */
body.public-profile { background-color: #eaeaea; background-size: cover; background-position: center center; color: #fff; padding: 3rem 1rem; transition: background-image 0.5s ease-in-out; }
.profile-container { max-width: 680px; margin: 0 auto; text-align: center; }
.profile-header { margin-bottom: 2rem; }
.profile-image { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.2); margin-bottom: 1rem; }
.profile-username { font-size: 1.8rem; font-weight: 700; margin: 0; color: #fff; text-shadow: 1px 1px 3px rgba(0,0,0,0.4); }
.public-links-list a { display: block; background: rgba(255, 255, 255, 0.9); color: var(--dark-color); padding: 18px 20px 18px 50px; margin-bottom: 1rem; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 1.1rem; box-shadow: 0 4px 10px rgba(0,0,0,0.1); transition: all 0.2s ease-in-out; display: flex; align-items: center; gap: 12px; position: relative; }
.public-links-list a:hover { transform: scale(1.03); box-shadow: 0 6px 15px rgba(0,0,0,0.15); background: white; }
.public-links-list a i { position: absolute; left: 20px; font-size: 1.5rem; width: 20px; text-align: center; }
.site-footer { padding: 2rem 0; text-align: center; }
.site-footer a { font-weight: 700; color: #fff; text-decoration: none; background: rgba(0,0,0,0.3); padding: 5px 10px; border-radius: 5px; transition: background 0.2s; }
.site-footer a:hover { background: var(--primary-color); }

/* --- Pagina Profilo (Admin) --- */
.profile-section h2 { text-align: left; border-bottom: 2px solid #f0f0f0; padding-bottom: 1rem; }
.current-images { display: flex; gap: 2rem; margin-bottom: 2rem; align-items: center; }
.current-images div { text-align: center; }
.current-images img { height: 100px; width: 100px; object-fit: cover; border-radius: 50%; border: 3px solid #eee; }
.current-images .current-bg { width: 150px; height: 100px; border-radius: 8px; }
.file-input-wrapper { position: relative; overflow: hidden; display: inline-block; padding: 10px 15px; border: 1px dashed #ccc; border-radius: 5px; cursor: pointer; }
.file-input-wrapper:hover { border-color: var(--primary-color); }
.file-input-wrapper input[type=file] { font-size: 100px; position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; }
.file-input-wrapper .file-input-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* --- Pagina Statistiche --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: #fff; padding: 1.5rem; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); display: flex; align-items: center; gap: 1.5rem; }
.stat-card .icon { font-size: 2.2rem; color: #fff; width: 65px; height: 65px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card .icon.primary { background: var(--primary-color); }
.stat-card .icon.secondary { background: var(--secondary-color); }
.stat-card .icon.success { background: var(--success-color); }
.stat-card .info .value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-card .info .label { font-size: 0.9rem; color: #777; }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.stats-table th { background-color: #f8f9fa; font-weight: 600; }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover { background-color: #f8f9fa; }
.stats-table .clicks-col { font-weight: bold; text-align: right; width: 100px; }

/* --- Pagina Modifica Link e Toggle Switch --- */
.edit-link-container { max-width: 600px; margin: 2rem auto; padding: 2rem; background: #fff; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.edit-link-container h1 { text-align: center; margin-bottom: 2rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.switch-field { display: flex; align-items: center; gap: 15px; margin-bottom: 1.5rem; }
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success-color); }
input:checked + .slider:before { transform: translateX(26px); }
.premium-feature { background: linear-gradient(45deg, var(--primary-color), var(--secondary-color)); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; font-weight: bold; text-transform: uppercase; vertical-align: middle; margin-left: 8px; }

/* --- Responsive --- */
@media (max-width: 600px) {
    .dashboard-header { flex-direction: column; gap: 10px; }
    .link-item { flex-direction: column; align-items: flex-start; gap: 10px; }
    .link-item .link-actions { width: 100%; text-align: right; margin-top: 10px; }
}