/* Palette inspirée de CSI_Dsi : coral/primary, violet/secondary, bleu/accent */
:root {
    --background: 0 0% 96%;
    --foreground: 0 0% 18%;
    --card: 0 0% 100%;
    --card-foreground: 0 0% 18%;
    --primary: 0 48% 63%;
    --primary-foreground: 0 0% 100%;
    --secondary: 270 100% 44%;
    --secondary-foreground: 0 0% 100%;
    --muted: 0 0% 92%;
    --muted-foreground: 0 0% 45%;
    --accent: 200 95% 46%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 100%;
    --border: 0 0% 85%;
    --input: 0 0% 85%;
    --radius-lg: 0.75rem;
    --radius-md: 0.5rem;
    --radius-sm: 0.25rem;
    --sidebar-width: 220px;
}

html.dark {
    --background: 0 0% 11%;
    --foreground: 0 0% 92%;
    --card: 0 0% 15%;
    --card-foreground: 0 0% 92%;
    --primary: 0 55% 66%;
    --primary-foreground: 0 0% 10%;
    --secondary: 270 85% 68%;
    --secondary-foreground: 0 0% 10%;
    --muted: 0 0% 20%;
    --muted-foreground: 0 0% 65%;
    --accent: 200 60% 30%;
    --accent-foreground: 0 0% 95%;
    --destructive: 0 62% 48%;
    --destructive-foreground: 0 0% 100%;
    --border: 0 0% 26%;
    --input: 0 0% 26%;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: inherit; }

/* --- Pages non connectées (accueil, login) --- */

.public-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
}

.public-header .brand,
.sidebar-logo .brand,
.mobile-brand {
    font-weight: 700;
    text-decoration: none;
    color: hsl(var(--primary));
    font-size: 1.1rem;
}

.public-header .brand { font-size: 1rem; }

.logo-img { display: block; height: auto; }
.logo-img-public { width: 220px; max-width: 100%; }
.logo-img-sidebar { width: 100%; }
.logo-img-mobile { height: 2.25rem; width: auto; }

.brand-accent { color: hsl(var(--secondary)); }

.public-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-main {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.site-footer {
    text-align: center;
    color: hsl(var(--muted-foreground));
    font-size: 0.85rem;
    padding: 2rem 1rem;
}

.site-footer a { color: hsl(var(--primary)); }

.legal {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: 2rem;
    line-height: 1.6;
}

.legal h2 {
    margin-top: 2rem;
    font-size: 1.25rem;
    color: hsl(var(--primary));
}

.legal h3 {
    margin-top: 1.5rem;
    font-size: 1.05rem;
}

.legal ul { padding-left: 1.5rem; }
.legal li { margin-bottom: 0.5rem; }

.legal code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: hsl(var(--muted));
    border-radius: var(--radius-sm);
    padding: 0.1rem 0.3rem;
}

.legal .table { font-size: 0.9rem; margin-top: 1rem; }
.legal .table th, .legal .table td { vertical-align: top; }

.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero-link {
    text-decoration: none;
    color: hsl(var(--primary));
    font-size: 2rem;
    font-weight: 700;
}

.hero-link:hover { text-decoration: underline; }

/* --- Portfolio (page d'accueil) --- */

.pf-hero {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 3rem 0 2rem;
}

.pf-portrait {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid hsl(var(--primary));
    flex-shrink: 0;
}

.pf-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.64rem;
    font-weight: 700;
    color: hsl(var(--secondary));
    margin: 0 0 0.4rem;
}

.pf-hero h1 {
    margin: 0;
    font-size: 1.76rem;
}

.pf-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: hsl(var(--primary));
    margin: 0.2rem 0 1rem;
}

.pf-pitch {
    max-width: 60ch;
    color: hsl(var(--foreground));
    line-height: 1.6;
    font-size: 0.8rem;
}

.pf-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

.pf-section {
    padding: 2.5rem 0;
    border-top: 1px solid hsl(var(--border));
}

.pf-section h2 {
    font-size: 1.12rem;
    margin-bottom: 0.5rem;
}

.pf-section-intro {
    color: hsl(var(--muted-foreground));
    max-width: 70ch;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
}

.pf-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .pf-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .pf-grid { grid-template-columns: 1fr; }
}

.pf-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.pf-card h3 {
    margin: 0 0 0.5rem;
    font-size: 0.96rem;
    color: hsl(var(--primary));
}

.pf-card p { margin: 0; color: hsl(var(--foreground)); font-size: 0.84rem; line-height: 1.5; }

.pf-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pf-timeline-item {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1rem;
    padding-left: 1rem;
    border-left: 2px solid hsl(var(--primary));
}

.pf-timeline-date {
    font-weight: 700;
    color: hsl(var(--secondary));
    font-size: 0.72rem;
}

.pf-timeline-item h3 { margin: 0 0 0.15rem; font-size: 0.84rem; }

.pf-timeline-org {
    color: hsl(var(--muted-foreground));
    font-size: 0.7rem;
    margin: 0 0 0.4rem;
}

.pf-timeline-item p:last-child { margin: 0; font-size: 0.74rem; line-height: 1.5; }

.pf-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pf-tag {
    background: hsl(var(--accent) / 0.12);
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

.pf-section .pf-tag { font-size: 0.68rem; }

.pf-clients {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.pf-client {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    min-width: 280px;
    height: 250px;
    text-decoration: none;
}

a.pf-client:hover { border-color: hsl(var(--primary)); }

.pf-client-link-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-radius: 50%;
    font-size: 0.68rem;
    line-height: 1;
}

.pf-client-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pf-client-sigle {
    font-weight: 700;
    color: hsl(var(--primary));
    font-size: 0.88rem;
}

.pf-contact { text-align: center; }
.pf-contact-intro { font-size: 0.8rem; }

.pf-contact-details {
    font-size: 0.88rem;
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.pf-contact-details a { color: hsl(var(--primary)); text-decoration: none; }
.pf-contact-details a:hover { text-decoration: underline; }

@media (max-width: 640px) {
    .pf-hero { flex-direction: column; text-align: center; }
    .pf-cta { justify-content: center; }
    .pf-timeline-item { grid-template-columns: 1fr; }
}

/* --- Boutons --- */

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover { filter: brightness(0.92); }

.btn-secondary {
    background: transparent;
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

/* --- Cartes / formulaires / listes --- */

.form-page, .list-page {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid hsl(var(--border));
}

.form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 420px; }
.form label { font-weight: 600; margin-top: 0.5rem; }
.form input, .form textarea, .form select {
    padding: 0.5rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
}
.form button, .form .btn { margin-top: 1rem; align-self: flex-start; }

.form h2 {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid hsl(var(--border));
    font-size: 1.1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-top: 0.5rem;
}
.checkbox-label input { width: auto; }

.client-logo-thumb {
    height: 2rem;
    width: auto;
    max-width: 4rem;
    object-fit: contain;
}

.client-logo-preview {
    height: 4rem;
    width: auto;
    max-width: 10rem;
    object-fit: contain;
    display: block;
    margin: 0.25rem 0;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left;
    padding: 0.6rem;
    border-bottom: 1px solid hsl(var(--border));
}

.actions { display: flex; gap: 0.75rem; align-items: center; }
.actions form { display: inline; }
.theme-swatch {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    border: 1px solid hsl(var(--border));
    margin-right: 0.25rem;
    vertical-align: middle;
}

.histo-fail {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    margin: 0;
    font-size: 0.85rem;
}

.histo-ua {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-action {
    background: none;
    border: none;
    color: hsl(var(--primary));
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}

.link-danger {
    background: none;
    border: none;
    color: hsl(var(--destructive));
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; }
.alert-error { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); }
.alert-success { background: hsl(var(--accent) / 0.15); color: hsl(var(--foreground)); }

.muted { color: hsl(var(--muted-foreground)); font-size: 0.9rem; }

.steps { padding-left: 1.25rem; color: hsl(var(--foreground)); }
.steps li { margin-bottom: 0.4rem; }

.secret-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* --- Sidebar (pages connectées) --- */

body.has-sidebar { background: hsl(var(--background)); }

.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: hsl(var(--card));
    border-right: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.2s ease;
}

.sidebar-logo {
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
}

.sidebar-logo .brand {
    line-height: 1.3;
    font-size: 0.95rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.15rem;
}

.nav-link:hover { background: hsl(var(--accent) / 0.12); color: hsl(var(--foreground)); }

.nav-link.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.nav-icon { width: 1.2rem; text-align: center; flex-shrink: 0; }

.nav-sublink {
    margin-left: 1rem;
    font-size: 0.85rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.nav-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid hsl(var(--border));
}

.nav-section-title {
    display: block;
    padding: 0 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.4rem;
}

.sidebar-footer {
    border-top: 1px solid hsl(var(--border));
    padding: 1rem 0.75rem;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.5rem;
    padding: 0 0.25rem;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    border: none;
    background: none;
    color: hsl(var(--muted-foreground));
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
}

.theme-toggle:hover { background: hsl(var(--accent) / 0.12); color: hsl(var(--foreground)); }

.logout-link { margin-top: 0.25rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
}

.sidebar-overlay.visible { display: block; }

.site-main-with-sidebar {
    margin-left: var(--sidebar-width);
    max-width: none;
    padding: 2rem;
}

.site-footer-with-sidebar { margin-left: var(--sidebar-width); }

@media (max-width: 900px) {
    .mobile-header { display: flex; }
    .sidebar { transform: translateX(-100%); top: 0; }
    .sidebar.open { transform: translateX(0); }
    .site-main-with-sidebar { margin-left: 0; padding: 1.25rem; padding-top: 4.5rem; }
    .site-footer-with-sidebar { margin-left: 0; }
}

@media (max-width: 600px) {
    .site-main { padding: 0 1rem; }
    .list-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .table, .table thead, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table thead { display: none; }
    .table tr { margin-bottom: 1rem; border: 1px solid hsl(var(--border)); border-radius: var(--radius-md); padding: 0.5rem; }
}
