/* ============================================================
   Planning Maintenance CVC — feuille de style
   ============================================================ */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-success: #16a34a;
    --color-success-bg: #dcfce7;
    --color-error: #dc2626;
    --color-error-bg: #fee2e2;
    --color-warning: #ea580c;
    --color-warning-bg: #ffedd5;
    --color-info: #0ea5e9;
    --color-info-bg: #e0f2fe;
    --sidebar-width: 250px;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout général -------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.4rem 1.2rem;
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-icon { font-size: 1.3rem; }

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 0.6rem;
    gap: 0.15rem;
    overflow-y: auto;
}
.sidebar-nav a {
    color: #cbd5e1;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.92rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar-nav a.active { background: var(--color-primary); color: #fff; font-weight: 600; }

.sidebar-user {
    padding: 1rem 1.2rem 1.4rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.85rem;
}
.sidebar-user-name { font-weight: 600; color: #fff; }
.sidebar-user-role { color: #94a3b8; margin-bottom: 0.5rem; }
.sidebar-logout { color: #f87171; font-size: 0.85rem; }

.content { flex: 1; min-width: 0; }
.content-header {
    background: var(--color-surface);
    padding: 1.4rem 2rem;
    border-bottom: 1px solid var(--color-border);
}
.content-header h1 { margin: 0; font-size: 1.4rem; }
.content-body { padding: 1.6rem 2rem 3rem; }
.content-body.full-width { padding: 0; }

/* --- Cartes -------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.4rem 1.6rem;
    margin-bottom: 1.5rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.card h3 { font-size: 0.98rem; margin: 1.2rem 0 0.6rem; }

.grid-2col {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) {
    .grid-2col { grid-template-columns: 1fr; }
}
.card-wide { grid-column: auto; }

.hint { color: var(--color-text-muted); font-size: 0.88rem; margin-top: -0.4rem; }

/* --- Formulaires -------------------------------------------------- */
.form-stack { display: flex; flex-direction: column; gap: 0.9rem; }
.form-stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; font-weight: 600; color: var(--color-text-muted); }

.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; }
.form-inline label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.92rem;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.form-actions { display: flex; gap: 0.7rem; margin-top: 0.3rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--color-text); }
.btn-ghost { background: transparent; color: var(--color-text-muted); border-color: var(--color-border); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-block { width: 100%; }

.link { font-size: 0.88rem; }
.link-muted { color: var(--color-text-muted); background: none; border: none; padding: 0; cursor: pointer; font-size: 0.88rem; text-decoration: underline; }
.link-danger { color: var(--color-error); background: none; border: none; padding: 0; cursor: pointer; font-size: 0.88rem; text-decoration: underline; }
.actions-cell { display: flex; gap: 0.8rem; align-items: center; white-space: nowrap; }

/* --- Tableaux -------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--color-border); }
.data-table th { color: var(--color-text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
.data-table tbody tr:hover { background: #f8fafc; }
.row-inactive { opacity: 0.55; }
.row-alert { background: var(--color-error-bg); }
.empty-cell { text-align: center; color: var(--color-text-muted); padding: 1.5rem; }

/* --- Badges -------------------------------------------------- */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.badge-lg { font-size: 0.85rem; padding: 0.35rem 0.9rem; }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-green { background: var(--color-success-bg); color: var(--color-success); }
.badge-red { background: var(--color-error-bg); color: var(--color-error); }

/* --- Alertes / flash messages -------------------------------------------------- */
.alert { padding: 0.8rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: var(--color-success-bg); color: #166534; }
.alert-error { background: var(--color-error-bg); color: #991b1b; }
.alert-info { background: var(--color-info-bg); color: #075985; }
.alert-list { list-style: none; padding: 0; margin: 0 0 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.9rem; }

/* --- Stat tiles -------------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.2rem; }
.stat-tile-alert { border-color: var(--color-error); background: var(--color-error-bg); }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 0.2rem; }

/* --- Mission detail -------------------------------------------------- */
.mission-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.mission-meta { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 1rem 0 1.4rem; font-size: 0.9rem; color: var(--color-text-muted); }
.mission-meta strong { color: var(--color-text); }

/* --- Connexion -------------------------------------------------- */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a, #1e3a8a); padding: 1.5rem; }
.login-box { background: #fff; border-radius: 12px; padding: 2.2rem 2.4rem; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.login-brand { text-align: center; margin-bottom: 1.6rem; }
.login-brand .brand-icon { font-size: 2rem; }
.login-brand h1 { font-size: 1.3rem; margin: 0.4rem 0 0.2rem; }
.login-brand p { color: var(--color-text-muted); font-size: 0.85rem; margin: 0; }
.login-demo { margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--color-border); font-size: 0.82rem; color: var(--color-text-muted); }
.login-demo ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.login-demo code { background: #f1f5f9; padding: 0.1rem 0.35rem; border-radius: 4px; }

/* --- Responsive -------------------------------------------------- */
@media (max-width: 720px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .content-body { padding: 1.2rem; }
    .content-header { padding: 1rem 1.2rem; }
}
