@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap');

:root {
    --kdBlueL: #C0DDFF;
    --kdBlue: #3E97FF;
    --kdBlueD: #002652;
    --kdGreenL: #AEFEA1;
    --kdGreen: #52b36c;
    --kdGreenD: #0B5200;
    --kdGreyL: #EDEDED;
    --kdGreyLL: #f8f9fa;
    --kdGrey: #BEBEBE;
    --kdGreyD: #2e2e2e;
    --kdRedL: #FFBBBB;
    --kdRed: #FF0000;
    --kdRedD: #580000;
    --kdOrangeL: #FFC0B2;
    --kdOrange: #FF5733;
    --kdOrangeD: #9A1C00;
    --kdBlack: #000000;
    --kdWhite: #FFFFFF;
    --kdYellow: #fabb05;
    --kdYellowL: #fef3d3;
    --kdViolet: #4338ca;
    --kdVioletL: #6366f1;

    --menu-width: 220px;
    --menu-width-closed: 60px;
    --header-height: 50px;
    --footer-height: 40px;
}

* {
    box-sizing: border-box;
    font-family: 'Lexend', sans-serif;
    margin: 0;
    padding: 0;
}

body {
    background: var(--kdGreyLL);
    overflow: hidden;
}

input:focus, textarea:focus { outline: none; box-shadow: none; }
input, textarea { border: none; outline: none; box-shadow: none; }
a { text-decoration: none; color: inherit; }
h1,h2,h3,h4,h5,h6 { font-weight: normal; }

/* ═══════════════════════════════════════════
   LAYOUT PRINCIPAL
   ═══════════════════════════════════════════ */
.app-layout {
    display: flex;
    width: 100svw;
    height: 100svh;
}

/* ═══════════════════════════════════════════
   MENU LATÉRAL
   ═══════════════════════════════════════════ */
.app-menu {
    width: var(--menu-width);
    height: 100%;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    z-index: 5;
}

.app-menu.closed {
    width: var(--menu-width-closed);
}

/* Logo / titre du menu */
.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    height: 60px;
    border-bottom: 1px solid var(--kdGreyL);
}

.menu-header .menu-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--kdBlueD);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-header .menu-toggle {
    cursor: pointer;
    font-size: 16px;
    color: var(--kdGrey);
    transition: color 0.2s;
}

.menu-header .menu-toggle:hover {
    color: var(--kdBlue);
}

.app-menu.closed .menu-title { display: none; }
.app-menu.closed .menu-toggle { margin: 0 auto; }

/* Navigation */
.menu-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 8px;
}

/* Séparateur */
.menu-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.menu-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--kdGreyL);
}

.app-menu.closed .menu-sep { justify-content: center; }
.app-menu.closed .menu-sep span { display: none; }
.app-menu.closed .menu-sep::after { display: block; margin: 0 5px; }

/* Bouton menu */
.menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 10px;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6B7280;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-btn:hover {
    background: var(--kdGreyLL);
    color: var(--kdBlueD);
}

.menu-btn.active {
    background: #e0e7ff;
    color: var(--kdBlue);
    font-weight: 500;
}

.menu-btn .menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    font-size: 16px;
    flex-shrink: 0;
}

.menu-btn .menu-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-menu.closed .menu-label { display: none; }

/* ═══════════════════════════════════════════
   ZONE PRINCIPALE (header + contenu + footer)
   ═══════════════════════════════════════════ */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
.app-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    padding: 0 20px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    z-index: 3;
}

.app-header .header-title {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
    color: var(--kdBlueD);
}

.app-header .header-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--kdGreyD);
    padding: 5px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.app-header .header-user:hover {
    background: var(--kdGreyLL);
}

.app-header .header-user i.user-icon {
    font-size: 22px;
    color: var(--kdBlue);
}

.app-header .header-user i.logout-icon {
    font-size: 18px;
    color: var(--kdGrey);
    margin-left: 8px;
    transition: color 0.2s;
}

.app-header .header-user i.logout-icon:hover {
    color: var(--kdRed);
}

/* Dropdown user */
.header-user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: white;
    border: 1px solid var(--kdGreyL);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s;
    z-index: 10;
}

.header-user-dropdown.open {
    opacity: 1;
    max-height: 300px;
}

.header-user-dropdown div {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 15px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.header-user-dropdown div:hover {
    background: var(--kdGreyLL);
}

/* ═══════════════════════════════════════════
   CONTENU
   ═══════════════════════════════════════════ */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
}

/* ═══════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════ */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--footer-height);
    padding: 0 20px;
    font-size: 12px;
    color: var(--kdGrey);
    background: white;
    border-top: 1px solid var(--kdGreyL);
}

.app-footer .footer-params {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--kdGreyD);
    transition: background 0.2s;
}

.app-footer .footer-params:hover {
    background: var(--kdGreyLL);
}

/* ═══════════════════════════════════════════
   MODALE (del_screen)
   ═══════════════════════════════════════════ */
.del-screen {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.del-screen.active {
    align-items: flex-start;
    padding-top: 20px;
    display: flex;
}

/* ═══════════════════════════════════════════
   BOUTON MENU MOBILE
   ═══════════════════════════════════════════ */
.app-menu-mobile-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 20;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    font-size: 20px;
    color: var(--kdBlue);
}

/* ═══════════════════════════════════════════
   RESPONSIVE MOBILE
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .app-menu {
        position: fixed;
        left: 0; top: 0;
        width: 0;
        z-index: 15;
    }

    .app-menu.mobile-open {
        width: 100%;
    }

    .app-menu-mobile-btn {
        display: flex;
    }

    .app-header .header-title {
        padding-left: 40px;
    }
}

/* ═══════════════════════════════════════════
   ONGLETS
   ═══════════════════════════════════════════ */
.kd-tabs {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.kd-tabs-nav {
    display: flex;
    align-items: flex-end;
    gap: 0;
    width: 100%;
    position: relative;
}

.kd-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    min-width: 120px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--kdGreyD);
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    position: relative;
    transition: all 0.25s ease;
    user-select: none;
    z-index: 1;
    margin-right: -1px;
}

.kd-tab:first-child {
    border-radius: 10px 10px 0 0;
}

.kd-tab:hover:not(.kd-tab-active) {
    background: #e8edf4;
    color: var(--kdBlueD);
}

.kd-tab-active {
    background: white;
    color: var(--kdBlue);
    font-weight: 600;
    z-index: 3;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

.kd-tab-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: white;
}

.kd-tab i {
    font-size: 15px;
}

.kd-tab-active i {
    color: var(--kdBlue);
}

/* Ligne de fermeture à droite des onglets */
.kd-tabs-end {
    flex: 1;
    border-bottom: 1px solid #e2e8f0;
    height: 100%;
    min-height: 45px;
}

/* Contenu des onglets */
.kd-tabs-content {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    width: 100%;
    flex: 1;
    overflow: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 8px 8px 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    z-index: 2;
}

/* Responsive */
@media (max-width: 768px) {
    .kd-tabs-nav {
        overflow-x: auto;
    }
    .kd-tab {
        min-width: 100px;
        padding: 10px 16px;
        font-size: 12px;
    }
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATION
   ═══════════════════════════════════════════ */
.kd-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
    animation: kdToastIn 0.35s ease, kdToastOut 0.4s ease 2.6s forwards;
    pointer-events: none;
}

.kd-toast i {
    font-size: 18px;
}

@keyframes kdToastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes kdToastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ═══════════════════════════════════════════
   LOADER OVERLAY
   ═══════════════════════════════════════════ */
.kd-loader-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(2px);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    animation: kdLoaderIn 0.2s ease;
}

.kd-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--kdBlue);
    border-radius: 50%;
    animation: kdSpin 0.8s linear infinite;
}

.kd-loader-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--kdBlueD);
}

@keyframes kdSpin {
    to { transform: rotate(360deg); }
}

@keyframes kdLoaderIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.kd-toast-error {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35);
}
