/* ============================================================================
   Portail Piscop — Styles partagés
   Même palette que le module cantonniers
   ============================================================================ */

:root {
    --c-bg:          #f4f6fa;
    --c-surface:     #ffffff;
    --c-surface-alt: #eef1f7;
    --c-text:        #1a1f2c;
    --c-text-muted:  #6b7280;
    --c-border:      #dde2ec;
    --c-primary:     #16a34a;
    --c-primary-light: #bbf7d0;
    --c-danger:      #dc2626;
    --c-warning:     #f59e0b;
    --c-info:        #0ea5e9;
    --radius:        8px;
    --radius-lg:     12px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
    --shadow-md:     0 4px 12px rgba(0,0,0,.1);
    --shadow-lg:     0 8px 30px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Login page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.login-logo {
    text-align: center;
    margin-bottom: 24px;
}
.login-logo svg {
    width: 64px;
    height: 64px;
    color: var(--c-primary);
}
.login-logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 12px 0 0;
}
.login-logo p {
    font-size: .85rem;
    color: var(--c-text-muted);
    margin: 4px 0 0;
}
.form-field {
    margin-bottom: 16px;
}
.form-field label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--c-text-muted);
    margin-bottom: 4px;
}
.form-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    background: var(--c-bg);
    color: var(--c-text);
    transition: border-color .15s;
}
.form-field input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}
.form-error {
    font-size: .8rem;
    color: var(--c-danger);
    margin-top: 4px;
}
.form-alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .85rem;
    margin-bottom: 16px;
}
.form-alert.error { background: #fef2f2; color: var(--c-danger); border: 1px solid #fecaca; }
.form-alert.info  { background: #eff6ff; color: var(--c-info); border: 1px solid #bfdbfe; }
.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--c-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.btn-login:hover { background: #15803d; }
.btn-login:active { transform: scale(.98); }

/* --- Portail index --- */
.portail-shell {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 20px;
}
.portail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 12px;
}
.portail-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.portail-header h1 svg { width: 28px; height: 28px; color: var(--c-primary); }
.portail-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .9rem;
}
.portail-user .badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.module-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .2s, transform .15s;
    cursor: pointer;
}
.module-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.module-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.module-icon i { font-size: 1.5rem; color: #fff; }
.module-info h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 4px;
}
.module-info p {
    font-size: .82rem;
    color: var(--c-text-muted);
    margin: 0;
    line-height: 1.4;
}

.section-title {
    font-size: .85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--c-text-muted);
    margin-bottom: 12px;
}

/* --- Users page --- */
.users-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.users-table th,
.users-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
    font-size: .88rem;
}
.users-table th {
    background: var(--c-surface-alt);
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--c-text-muted);
}
.users-table tr:hover td {
    background: var(--c-surface-alt);
}

/* --- Common buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-danger  { background: var(--c-danger); color: #fff; }
.btn-ghost   { background: transparent; color: var(--c-text-muted); border: 1px solid var(--c-border); }
.btn-sm      { min-height: 32px; padding: 4px 12px; font-size: .8rem; }

/* --- Modal --- */
.cant-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.cant-modal {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%; max-width: 520px; max-height: 85vh;
    overflow-y: auto; padding: 24px;
}
.cant-modal h2 { margin: 0 0 16px; font-size: 1.1rem; }
.cant-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* --- Toast --- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    padding: 12px 24px; border-radius: var(--radius);
    color: #fff; font-weight: 600; font-size: .9rem; z-index: 9999;
    box-shadow: var(--shadow-md);
    animation: toast-in .25s ease-out;
}
.toast.success { background: var(--c-primary); }
.toast.error   { background: var(--c-danger); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Theme toggle --- */
.theme-toggle {
    background: none; border: 1px solid var(--c-border); border-radius: 50%;
    width: 36px; height: 36px; display: inline-flex; align-items: center;
    justify-content: center; cursor: pointer; font-size: 1.1rem;
    color: var(--c-text-muted); padding: 0;
}

/* --- Dark mode --- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --c-bg: #0f1117; --c-surface: #1a1d27; --c-surface-alt: #22252f;
        --c-text: #e4e7ed; --c-text-muted: #9ca3af; --c-border: #2d3140;
    }
}
:root[data-theme="dark"] {
    --c-bg: #0f1117; --c-surface: #1a1d27; --c-surface-alt: #22252f;
    --c-text: #e4e7ed; --c-text-muted: #9ca3af; --c-border: #2d3140;
}
:root[data-theme="dark"] .form-field input {
    background: var(--c-surface); color: var(--c-text); border-color: var(--c-border);
}
:root[data-theme="dark"] .form-alert.error {
    background: #1c1113; border-color: #991b1b;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .login-card { padding: 24px; }
    .modules-grid { grid-template-columns: 1fr; }
}
