/* public/assets/css/app.css */
/* Thème GreenTech / Énergie – minimal, responsive, homemade */

/* Variables */
:root {
    --primary:      #2e7d32;     /* vert forêt énergie */
    --primary-dark: #1b5e20;
    --accent:       #ff9800;     /* orange solaire / bouton Pro */
    --light-bg:     #f8fafc;
    --card-bg:      #ffffff;
    --text:         #1f2937;
    --text-light:   #6b7280;
    --border:       #e5e7eb;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.1);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
    --radius:       10px;
}

/* Reset & base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light-bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Dashboard global */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--primary);
    color: white;
    padding: 24px 20px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar .user-info {
    text-align: center;
    margin-bottom: 36px;
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    margin: 8px 0;
}

.sidebar a {
    display: block;
    padding: 12px 16px;
    color: white;
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(255,255,255,0.15);
}

/* Main content */
main {
    flex: 1;
    padding: 32px;
    background: var(--light-bg);
}

h1 {
    color: var(--primary);
    margin-bottom: 32px;
    font-size: 2.2rem;
}

header {
    background: var(--primary);
    color: white;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Footer sticky */
footer {
    background: var(--primary-dark);
    color: white;
    text-align: center;
    padding: 16px;
    position: sticky;
    bottom: 0;
    z-index: 900;
    margin-top: auto;
    height: auto;
}

/* Container principal avec marges */
.container, 
main {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Widgets grid */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
}

.widget {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

.widget:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.widget h3 {
    margin: 0 0 16px;
    color: var(--primary);
    font-size: 1.35rem;
}

/* Teaser Pro */
.freemium-teaser {
    background: linear-gradient(135deg, #fffbeb, #fefce8);
    border: 1px solid #fde68a;
    text-align: center;
}

.freemium-teaser h3 {
    color: #c2410c;
}

.freemium-teaser ul {
    text-align: left;
    margin: 20px auto;
    max-width: 420px;
}

.freemium-teaser li {
    margin: 12px 0;
    font-size: 1.05em;
}

.freemium-teaser a.btn-pro {
    display: inline-block;
    padding: 14px 36px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(245,158,11,0.3);
    transition: all 0.25s;
}

.freemium-teaser a.btn-pro:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(245,158,11,0.4);
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        padding: 20px;
        position: relative;
        height: auto;
    }
}

@media (max-width: 640px) {
    main {
        padding: 20px;
    }
    h1 {
        font-size: 1.8rem;
    }
    .widgets-grid {
        grid-template-columns: 1fr;
    }
}

/* Pages auth (login/register/credentials) */


.auth-card {
    background: white;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 480px;
}

.auth-card h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 32px;
}

.auth-card form p {
    margin-bottom: 24px;
}

.auth-card input,
.auth-card button {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 1rem;
}

.auth-card button {
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-card button:hover {
    background: var(--primary-dark);
}

body.auth-page {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
}

body.auth-page .main-wrapper {
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.error {
    border: 2px solid #dc3545 !important;
}

.error-message {
    color: #dc3545;
    font-size: 0.9em;
    margin-top: 4px;
    display: block;
}

input:focus.error {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

/* Flash messages - position fixed haut-droite par défaut */
.flash-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: white;
    font-weight: 500;
    animation: slideIn 0.4s ease-out;
    min-width: 320px;
    max-width: 500px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

.flash-success { background: #10b981; }
.flash-error   { background: #ef4444; }
.flash-warning { background: #f59e0b; }
.flash-info    { background: #3b82f6; }

.flash-text {
    flex: 1;
}

.flash-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    margin-left: 16px;
    opacity: 0.8;
}

.flash-close:hover {
    opacity: 1;
}

/* Animation d'apparition */
@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* Paramétrage par rôle (exemple pour super admin) */
/* À activer via JS ou classe body si besoin */
body.super-admin .flash-container {
    right: auto;
    left: 20px;
    /* ou bottom: 20px; top: auto; pour bottom-left par exemple */
}

/* Variantes pour super_admin */
body.super-admin .flash-container.top-left    { top: 20px; right: auto; left: 20px; }
body.super-admin .flash-container.bottom-right{ top: auto; bottom: 20px; right: 20px; left: auto; }
body.super-admin .flash-container.bottom-left { top: auto; bottom: 20px; right: auto; left: 20px; }

/* Impersonate banner */
.impersonate-banner {
    background: #f59e0b;
    color: white;
    padding: 10px 24px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 999;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Gestion de l'image de profil + modale */
.sidebar .user-info img,
.sidebar .user-info .avatar-placeholder {
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.3);
    object-fit: cover;
}

.avatar-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.avatar-wrapper.has-photo {
    animation: avatarPop 0.35s ease;
}

.avatar-wrapper.big {
    width: 140px;
    height: 140px;
}

.avatar-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.avatar-wrapper.has-photo img {
    display: block;
}

.avatar-letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.avatar-wrapper.has-photo .avatar-letter {
    display: none;
}

.avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    transition: opacity 0.25s ease;
    cursor: pointer;
    margin-top: -8px;
}

.avatar-wrapper:hover .avatar-overlay {
    opacity: 1;
}

@keyframes avatarPop {
    0%   { transform: scale(0.85); opacity: 0.5; }
    60%  { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); }
}

.avatar-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.avatar-actions button {
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.avatar-actions .danger {
    background: #ef4444;
    color: white;
}

#choose-file-btn {
    background: var(--primary);
    color: white;
}

#upload-status {
    text-align: center;
    color: #666;
    min-height: 20px;
}
