/* ═══════════════════════════════════════════════════════════════
   app-ui.css — Styles UI partagés MonPortailCSE
   Requiert theme.css.php chargé AVANT pour les variables CSS
═══════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

html {
    margin: 0; padding: 0;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0; padding: 0;
    min-width: 320px;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.55;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Shell ── */
.page-shell {
    width: min(1380px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

/* ── Topbar ── */
.page-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.page-brandline {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-brandline strong {
    font-size: 1.2rem;
    font-weight: 900;
    line-height: 1.2;
    color: var(--text);
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Hero ── */
.page-hero {
    background: var(--gradient-main);
    color: #fff;
    border-radius: var(--r-xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, .7fr);
    gap: 28px;
    margin-bottom: 24px;
}

.page-hero-title {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.page-hero-title img {
    height: 56px;
    width: auto;
    border-radius: 12px;
    background: #fff;
    padding: 4px;
    flex-shrink: 0;
}

.page-hero h1 {
    margin: 0 0 8px;
    font-size: 1.9rem;
    line-height: 1.08;
    font-weight: 900;
    color: #fff;
}

.page-hero p {
    margin: 0;
    line-height: 1.65;
    opacity: .92;
    font-size: .97rem;
    color: #fff;
}

.page-hero-meta {
    display: grid;
    gap: 10px;
    align-content: start;
}

.hero-meta-box {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.22);
    border-radius: var(--r-md);
    padding: 11px 14px;
    font-weight: 700;
    font-size: .93rem;
    color: #fff;
}

/* ── Section card ── */
.section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 26px 28px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.section-title {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: -.02em;
    line-height: 1.1;
}

.section-lead {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: .97rem;
    line-height: 1.65;
}

/* ── Grids ── */
.content-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.content-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.content-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }

/* ── Quick links ── */
.quick-links {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 16px;
}

.quick-link {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--tr);
    min-height: 110px;
}

.quick-link:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--secondary) 30%, var(--border));
    box-shadow: var(--shadow-md);
}

.quick-link strong {
    display: block;
    margin-bottom: 7px;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.3;
}

.quick-link span {
    color: var(--muted);
    font-size: .93rem;
    line-height: 1.5;
}

/* ── Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    color: var(--muted);
    font-size: .87rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1.1;
}

/* ── Module cards ── */
.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 18px;
}

.module-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: var(--tr);
    overflow: hidden;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

/* Barre colorée en haut de chaque card */
.module-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--gradient-main);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--primary) 20%, var(--border));
}

/* Card verrouillée (plan insuffisant) */
.module-card.locked {
    opacity: .72;
    background: #f8fafc;
}
.module-card.locked::before {
    background: #cbd5e1;
}

.module-icon {
    font-size: 1.9rem;
    line-height: 1;
    margin-bottom: 10px;
}

.module-card h3 {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 900;
    line-height: 1.2;
}

.module-card p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: .92rem;
    line-height: 1.6;
    flex: 1;
}

.module-count {
    font-size: 1.9rem;
    font-weight: 900;
    color: var(--secondary);
    margin: 0 0 14px;
    line-height: 1.1;
}

.module-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: auto;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.badge-active {
    background: color-mix(in srgb, var(--primary) 12%, white);
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 20%, white);
}

.badge-locked {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-option {
    background: color-mix(in srgb, var(--accent) 15%, white);
    color: color-mix(in srgb, var(--accent) 80%, #000);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, white);
}

.badge-info {
    background: color-mix(in srgb, var(--secondary) 12%, white);
    color: var(--secondary);
    border: 1px solid color-mix(in srgb, var(--secondary) 20%, white);
}

/* ── Boutons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 9px 16px;
    border-radius: var(--r-md);
    font-weight: 800;
    font-size: .93rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--tr);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    color: #fff;
    background: var(--gradient-main);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 22%, transparent);
}

.btn-secondary {
    color: var(--secondary);
    background: var(--card);
    border-color: color-mix(in srgb, var(--secondary) 28%, var(--border));
}

.btn-light {
    color: var(--text);
    background: var(--card);
    border-color: var(--border);
}

.btn-danger {
    color: #be123c;
    background: #fff1f2;
    border-color: #fecdd3;
}

.btn-sm {
    min-height: 34px;
    padding: 6px 12px;
    font-size: .85rem;
    border-radius: var(--r-sm);
}

/* ── Alerts ── */
.alert {
    padding: 13px 16px;
    border-radius: var(--r-md);
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: 18px;
    line-height: 1.5;
}

.alert-success { background: #ecfdf3; border: 1px solid #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Formulaires ── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }

label {
    font-weight: 800;
    font-size: .93rem;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    font: inherit;
    font-size: .97rem;
    color: var(--text);
    background: #fff;
    transition: border-color var(--tr), box-shadow var(--tr);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

textarea { min-height: 110px; resize: vertical; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; min-width: 700px; }

th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    font-size: .93rem;
}

th {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: #f8fafc;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: color-mix(in srgb, var(--primary) 3%, white); }

/* ── Cards utilitaires ── */
.modal-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 26px;
    box-shadow: var(--shadow-lg);
}

.panel-card {
    background: linear-gradient(180deg, #fff, #fcfdff);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

/* ── Utilitaires ── */
.small   { color: var(--muted); font-size: .9rem; }
.muted   { color: var(--muted); }
.fw-900  { font-weight: 900; }
.mt-0    { margin-top: 0; }
.mb-0    { margin-bottom: 0; }
.text-primary   { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-danger    { color: var(--danger); }
.text-success   { color: var(--success); }

/* ── Responsive ── */
@media (max-width: 1100px) {
    .page-hero      { grid-template-columns: 1fr; }
    .stats-grid     { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .quick-links    { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .module-grid    { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 720px) {
    .page-shell     { width: calc(100vw - 24px); padding: 16px 0 28px; }
    .page-hero      { padding: 20px; }
    .page-hero h1   { font-size: 1.5rem; }
    .section-card   { padding: 18px; }
    .section-title  { font-size: 1.3rem; }
    .module-card    { min-height: auto; }
    .content-grid-2,
    .content-grid-3,
    .content-grid-4,
    .stats-grid,
    .quick-links,
    .module-grid,
    .form-grid      { grid-template-columns: 1fr; }
}
.front-header{
    position:sticky;
    top:0;
    z-index:100;
    background:rgba(255,255,255,.96);
    backdrop-filter:blur(12px);
    border-bottom:1px solid var(--border);
}

.front-header-inner{
    max-width:1280px;
    margin:0 auto;
    min-height:76px;
    padding:0 20px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:20px;
}

.front-brand{
    display:flex;
    align-items:center;
    gap:12px;
    font-weight:950;
    color:var(--text);
    text-decoration:none;
}

.front-brand img{
    height:38px;
    width:auto;
    display:block;
}

.front-nav{
    display:flex;
    align-items:center;
    gap:22px;
    flex-wrap:wrap;
}

.front-nav a{
    color:#334155;
    font-weight:800;
    text-decoration:none;
}

.front-nav a:hover,
.front-nav a.active{
    color:var(--primary);
}

.front-pill,
.front-lang{
    padding:12px 16px;
    border:1px solid var(--border);
    border-radius:14px;
    background:#fff;
}

@media(max-width:860px){
    .front-header-inner{
        align-items:flex-start;
        padding:14px 20px;
        flex-direction:column;
    }

    .front-nav{
        width:100%;
        display:grid;
        grid-template-columns:1fr 1fr;
        gap:10px;
    }
}