/* ==== RESET & BASE ==== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #234b9b;
    --secondary: #e0e6f6;
    --accent: #f9a826;
    --bg: #f4f5f9;
    --text: #2b2b2b;
    --radius: 10px;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    --nav-height: 70px;
}

body {
    font-family: "Inter", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--nav-height);
}


/* ==== NAVBAR ==== */
.navbar {
    background: rgba(35, 75, 155, 0.98);
    color: #fff;
    padding: 0.9rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    backdrop-filter: blur(4px);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 1100;
}

.navbar .logo {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.navbar {
    color: #fff;
    margin-left: 6px;
    transition: 0.2s;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-form {
    margin: 0;
}

.logout-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #ffb835;
    transform: translateY(-1px);
}

/* ==== SIDEBAR ==== */
.sidebar {
    width: 230px;
    background: #fff;
    border-right: 1px solid #d7d7d7;
    height: calc(100vh - 70px);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 70px;
}

.sidebar ul {
    list-style: none;
    margin-top: 1rem;
}

.sidebar li {
    margin: 0.2em 0;
}

.sidebar a {
    display: block;
    padding: 0.9em 1.2em;
    text-decoration: none;
    color: #2e2e2e;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
}

.sidebar a:hover {
    background: var(--secondary);
    border-left: 4px solid var(--primary);
    color: var(--primary);
    padding-left: 1.4em;
}

.sidebar a.active {
    background: var(--primary);
    color: #fff;
    border-left-color: var(--accent);
}

/* ==== LAYOUT ==== */
.layout {
    display: flex;
    flex: 1;
}

.content {
    flex: 1;
    padding: 1.6rem 2rem;
}

.content > h1{
    margin-bottom: 1.6rem;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.dashboard-header h2 { margin: 0; }
.dashboard-header .header-add {
    flex: 0 0 auto;
    margin-left: 0.5rem;
}

/* Dashboard two-column grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 1.2rem;
    align-items: start;
    margin-top: 0.8rem;
}

.dashboard-grid.full-grid {
    grid-template-columns: 1fr;
}

.table-card {
    background: #fff;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: auto;
}

.filters {
    position: relative;
}

.filters-card {
    position: sticky;
    top: 86px;
    background: #fff;
    padding: 0.8rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.search-box.vertical {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.filters-card .search-box input,
.filters-card .search-box select {
    padding: 0.48rem 0.6rem;
    font-size: 0.95rem;
    border-radius: 8px;
    width: 100%;
    max-width: 200px;
}

.filters-actions {
    margin-top: auto;
    display: flex;
    gap: 0.6rem;
}

.filters-actions button {
    flex: 1 1 auto;
    padding: 0.6rem 0.8rem;
}

.table-card table {
    width: 100%;
    table-layout: auto;
    font-size: 0.95rem;
}

.table-card th, .table-card td {
    padding: 0.6rem 0.8rem;
}

/* ==== CARDS (Dashboard) ==== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: 0.2s ease;
    position: relative;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.03);
}

.card:hover {
    transform: translateY(-3px);
}

.card h3 {
    font-size: 1rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.card p {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary);
}

/* ==== ACTIONS & TABLE ==== */
.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    gap: 1rem;
}

.actions input[type="text"] {
    flex: 1;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    border: 1px solid #ccc;
    outline: none;
}

.actions input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(35, 75, 155, 0.2);
}

button {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.25s;
}

button:disabled,
.btn:disabled {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
    border: 1px solid #bbb;
    box-shadow: none;
    opacity: 0.7;
    transition: background 0.2s, color 0.2s, opacity 0.2s;
}

button:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th {
    background: var(--secondary);
    color: #333;
    text-align: left;
    padding: 0.9em;
    font-weight: 600;
}

td {
    padding: 0.8em;
    border-top: 1px solid #eee;
}

tr:hover td {
    background: #fafafa;
}

/* ==== LOGIN PAGE ==== */

.login-body {
    background: linear-gradient(135deg, #1b2d5e 0%, #234b9b 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    font-family: "Inter", "Segoe UI", Roboto, sans-serif;
    color: #333;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-panel {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 2.5rem 2rem 1.5rem;
    text-align: center;
    animation: fadeIn 0.8s ease;
}

.login-header h1 {
    font-size: 2rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 1px;
}

.login-header p {
    color: #777;
    font-size: 0.9rem;
    margin-top: 0.2rem;
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form .form-group {
    position: relative;
}

.login-form input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    transition: 0.2s ease;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(35, 75, 155, 0.2);
    outline: none;
}

.login-form button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.9rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.login-form button:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

.error-msg {
    background: rgba(255, 0, 0, 0.1);
    border-left: 4px solid crimson;
    color: crimson;
    font-size: 0.9rem;
    padding: 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    animation: shake 0.3s ease-in-out;
}

.login-footer {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: #999;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-4px); }
}

/* Mobile */
@media (max-width: 500px) {
    .login-panel {
        padding: 2rem 1.2rem;
    }
}


/* ==== ERROR PAGE ==== */
.error-container {
    height: 100vh;
    background: linear-gradient(160deg, #234b9b 0%, #0e132c 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.2em;
}

.error-message {
    font-size: 1.3rem;
    max-width: 500px;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.error-container a {
    background: var(--accent);
    padding: 0.8em 1.5em;
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    transition: 0.3s;
}

.error-container a:hover {
    background: #ffb835;
}

/* ==== RESPONSIVE ==== */
@media (max-width: 800px) {
    .layout {
        flex-direction: column;
    }
    .dashboard-header { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #ccc;
    }
    .actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ==== FORM ==== */
.form-container {
    background: #fff;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-control {
    padding: 0.7rem;
    border-radius: var(--radius);
    border: 1px solid #ccc;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(35, 75, 155, 0.2);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-secondary {
    background: #ccc;
    color: #333;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    display: inline-block;
    transition: 0.25s;
}

.btn-secondary:hover {
    background: #bbb;
}

/* === Nouveau bouton "Ajouter un apprenti" === */
.btn-add {
    background: var(--primary);
    color: #fff;
    padding: 0.8rem 1.4rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    transition: all 0.25s ease;
}

.btn-add:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.15);
}

/* ==== ALERT ==== */
.empty-message {
    color: #d32f2f;
    font-weight: 600;
    margin-top: 1rem;
    background: #fdecea;
    padding: 1rem;
    border-radius: var(--radius);
    border-left: 5px solid #d32f2f;
}

.success-message {
    color: #0a872b;
    background: #eaf9ed;
    padding: 10px;
    border-radius: 6px;
}

.error-message {
    color: #a40000;
    background: #fde8e8;
    padding: 10px;
    border-radius: 6px;
}


.search-box {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-box input,
.search-box select {
    padding: 0.65rem 0.9rem;
    border-radius: 50px;
    border: 1px solid #ccc;
    outline: none;
    transition: all 0.25s ease;
    background-color: #fff;
    flex: 1 1 180px;
    min-width: 140px;
}

.search-box button {
    flex: 0 0 auto;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 75, 155, 0.15);
}

.search-box select {
    padding-right: 2.2rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23333' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 12px center/12px 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    border-radius: 50px;
}

.search-box select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 75, 155, 0.12);
}

.search-box select option {
    padding: 0.5rem 0.75rem;
}

.search-box select {
    min-width: 180px;
    max-width: 320px;
}

.table-card .search-box {
    flex-wrap: nowrap;
    align-items: center;
}

.table-card .search-box input,
.table-card .search-box select {
    flex: 0 0 150px;
    max-width: 180px;
    padding: 0.48rem 0.6rem;
    border-radius: 8px;
}

.table-card .search-box button {
    padding: 0.5rem 0.9rem;
}

@media (max-width: 900px) {
    .table-card .search-box { flex-wrap: wrap; }
    .table-card .search-box input, .table-card .search-box select { flex: 1 1 160px; max-width: none; }
}

/* === Carte de détails d'un apprenti === */
.details-card {
    background: #fff;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 600px;
    margin-top: 1rem;
}

.details-row {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem 0;
    border-bottom: 1px solid #eee;
}

.details-row:last-child {
    border-bottom: none;
}

.label {
    font-weight: 600;
    color: var(--primary);
}

.value {
    color: #333;
}

.details-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.details-card input {
    width: 60%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

.form-control[multiple] {
    height: auto;
    min-height: 120px;
}

select[multiple] {
    height: auto;
    min-height: 120px;
    padding: 0.5em;
}
.compact-multiselect {
    min-height: auto !important;
    max-height: 7.2rem;
    overflow-y: auto;
}
.hint {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
}

.years-list {
    margin-top: 1.5rem;
}

.status-current {
    color: #fff;
    background: var(--accent);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
}

.status-old {
    color: #666;
    background: #e8e8e8;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
}

.actions {
    margin-top: 2rem;
}

.success-message, .error-message {
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    font-weight: 500;
}

.success-message {
    background: #dff7df;
    color: #206620;
}

.error-message {
    background: #fbe0e0;
    color: #a00;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .6rem;
    margin-top: .3rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #f8f9fc;
    border: 1px solid #dfe3eb;
    border-radius: 8px;
    padding: .4rem .6rem;
    cursor: pointer;
    transition: all .2s ease;
}

.checkbox-item:hover {
    background: #e9edff;
    border-color: #0d6efd;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0d6efd;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .6rem;
    margin-top: .4rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #f8f9fc;
    border: 1px solid #dfe3eb;
    border-radius: 8px;
    padding: .4rem .6rem;
    cursor: pointer;
    transition: all .2s ease;
}

.checkbox-item:hover {
    background: #e9edff;
    border-color: #0d6efd;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0d6efd;
}

a {
    text-decoration: none;
    color: inherit;
}

.modal {
    position: fixed;
    z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background: rgba(0,0,0,0.45);
    display: none; align-items: center; justify-content: center;
}

.modal.show {
    display: flex;
}
.modal-content {
    background: #fff; padding: 1.6rem; border-radius: 12px;
    width: min(720px, 90%);
    max-width: 720px;
    box-shadow: 0 14px 40px rgba(15,23,42,0.25);
    text-align: left;
    transform: none;
    opacity: 1;
    transition: transform 220ms cubic-bezier(.2,.9,.3,1), opacity 220ms ease;
}
.modal-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.modal.show .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.btn-danger, .modal .btn-danger {
    background: #d9534f;
    color: #fff;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-danger:hover {
    background: #c2433e;
    transform: translateY(-2px);
}

.modal .btn-secondary {
    background: #e6e9ee;
    color: #222;
    padding: 0.55rem 0.95rem;
    border-radius: 8px;
}

.modal-content header h3 {
    font-size: 1.1rem;
    color: var(--text);
}
.modal-content section p {
    margin: 0; color: #333; line-height: 1.4;
}
.modal-content .modal-footer {
    border-top: 1px solid #eef1f6;
    padding-top: 0.9rem;
    margin-top: 0.6rem;
    background: transparent;
}

@media (max-width: 900px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e6e6e6;
    }
    .layout {
        flex-direction: column;
    }
    .content {
        padding: 1.2rem;
    }
    .search-box {
        gap: 0.5rem;
    }
    .search-box select, .search-box input, .search-box button {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 500px) {
    .search-box {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box input, .search-box select, .search-box button {
        width: 100%;
    }
}

@media (max-width: 500px) {
    .modal-content { padding: 1rem; }
    .card p { font-size: 1.6rem; }
    .btn-add { padding: 0.6rem 1rem; font-size: 0.9rem; }
}