:root {
    --bg: #0f1419;
    --bg-card: #1a2332;
    --bg-sidebar: #121a24;
    --border: #2a3544;
    --text: #e8edf4;
    --text-muted: #8b9cb3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

/* Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand a {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 2rem;
    flex: 1;
}

.sidebar-nav a {
    color: var(--text-muted);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-card);
    color: var(--text);
}

.sidebar-user {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-name {
    font-weight: 600;
}

.admin-main {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-x: auto;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(145deg, #0f1419 0%, #1a2744 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.login-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
}

.login-subtitle {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
    font-size: 0.9rem;
}

/* Typography */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
}

.flex-between {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.text-muted {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    background: transparent;
    font-family: inherit;
}

.btn:hover {
    text-decoration: none;
    filter: brightness(1.08);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
}

.btn-secondary {
    background: #334155;
    color: #fff;
}

.btn-outline {
    border-color: var(--border);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Forms */
.form label {
    display: block;
    margin-bottom: 1rem;
}

.form label span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form input,
.form select,
.form textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

.form-card {
    max-width: 560px;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.inline-form {
    display: inline;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status-inactive {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

.status-maintenance {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.priority-basse {
    background: #334155;
    color: #cbd5e1;
}

.priority-normale {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

.priority-haute {
    background: rgba(245, 158, 11, 0.25);
    color: #fcd34d;
}

.priority-urgente {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.badge-role {
    background: var(--border);
    color: var(--text-muted);
    width: fit-content;
}

/* Project grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.project-card h2 {
    margin: 0;
    font-size: 1.1rem;
}

.project-domain {
    color: var(--primary);
    font-size: 0.9rem;
    margin: 0.35rem 0;
}

.project-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.project-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.stat-pill {
    font-size: 0.8rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.stat-muted {
    color: var(--text-muted);
}

.project-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 600;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Kanban */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.filters-bar label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.filters-bar select {
    min-width: 180px;
    padding: 0.45rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(240px, 1fr));
    gap: 1rem;
    align-items: start;
}

.kanban-column {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 200px;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.kanban-column-header h2 {
    margin: 0;
    font-size: 0.95rem;
}

.kanban-count {
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
}

.kanban-cards {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.kanban-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
}

.kanban-card h3 {
    margin: 0.35rem 0;
    font-size: 0.95rem;
}

.kanban-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.kanban-project {
    color: var(--text-muted);
}

.kanban-desc,
.kanban-due,
.kanban-assigned {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.25rem 0;
}

.kanban-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
    align-items: center;
}

.status-select {
    font-size: 0.75rem;
    padding: 0.25rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* AI */
.ai-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.ai-result-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.ai-result-panel h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

.ai-result-text {
    width: 100%;
    min-height: 280px;
    padding: 0.75rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}

.recent-generations {
    margin-top: 2rem;
}

.draft-list {
    list-style: none;
    padding: 0;
}

.draft-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Responsive */
@media (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
    .ai-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        margin-top: 0;
        margin-left: 1rem;
    }
    .sidebar-user {
        margin-top: 0;
        border: none;
        flex-direction: row;
        align-items: center;
    }
    .kanban-board {
        grid-template-columns: 1fr;
    }
}
