/* ==========================================================================
   CLR Admin — Styles
   Couleurs : fond #F5F5F5, texte #1A1A1A, accent #E10600
   Police : Inter
   ========================================================================== */

/* --- Base --- */

body {
    background-color: #F5F5F5;
    color: #1A1A1A;
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    margin: 0;
}

/* --- Layout sidebar --- */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid #E5E7EB;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-bottom: 1px solid #E5E7EB;
}

.sidebar-logo img {
    width: 100%;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.sidebar-section {
    padding: .75rem 1rem .25rem;
    font-size: .7rem;
    font-weight: 700;
    color: #E10600;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .7;
}

.sidebar-section::before {
    content: '';
    display: block;
    height: 1px;
    margin: 0 2rem .75rem;
    background: radial-gradient(ellipse at center, #E10600 0%, transparent 70%);
    opacity: .4;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    text-decoration: none;
    color: #4B5563;
    font-size: .875rem;
    transition: background .15s, color .15s;
}

.sidebar-icon {
    width: 16px;
    height: 16px;
    opacity: .5;
    flex-shrink: 0;
}

.sidebar-link:hover .sidebar-icon,
.sidebar-link.active .sidebar-icon {
    opacity: .8;
    filter: brightness(0) saturate(100%) invert(8%) sepia(95%) saturate(6000%) hue-rotate(358deg) brightness(95%) contrast(112%);
}

.section-icon {
    width: 1.25rem;
    height: 1.25rem;
    vertical-align: -3px;
    filter: brightness(0) saturate(100%) invert(8%) sepia(95%) saturate(6000%) hue-rotate(358deg) brightness(95%) contrast(112%);
    opacity: .7;
}

.sidebar-link:hover {
    background: #F9FAFB;
    color: #E10600;
}

.sidebar-link.active {
    background: #FEF2F2;
    color: #E10600;
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid #E5E7EB;
    padding: .75rem 1rem;
}

.sidebar-user {
    font-size: .8rem;
    color: #6B7280;
    margin-bottom: .375rem;
}

.sidebar-logout {
    font-size: .8rem;
    color: #E10600;
    text-decoration: none;
}

.sidebar-logout:hover {
    text-decoration: underline;
}

.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 2rem 2rem;
    max-width: calc(100% - 220px);
}

/* --- Page header --- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-title-icon {
    width: 28px;
    height: 28px;
    filter: brightness(0) saturate(100%) invert(8%) sepia(95%) saturate(6000%) hue-rotate(358deg) brightness(95%) contrast(112%);
    opacity: .7;
}

/* --- Cartes --- */

.card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    padding: 0;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

.card-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #FEF2F2;
    border-right: 2px solid #E10600;
}

.card-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    filter: brightness(0) saturate(100%) invert(8%) sepia(95%) saturate(6000%) hue-rotate(358deg) brightness(95%) contrast(112%);
}

.card-body {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.5rem;
}

.card:hover {
    border-color: #E10600;
}

.franchise-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: .25rem;
}

.card-actions {
    display: flex;
    gap: .75rem;
    margin-top: .5rem;
    font-size: .8rem;
}

.card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #E10600;
}

.card-label {
    color: #6B7280;
    margin-top: .25rem;
}

.card-code {
    font-family: ui-monospace, monospace;
    font-size: .875rem;
    color: #E10600;
}

.card-name {
    font-weight: 600;
    margin-top: .25rem;
}

.card-meta {
    color: #6B7280;
    font-size: .875rem;
    margin-top: .5rem;
}

/* --- Tableaux --- */

.table-wrap {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    overflow: hidden;
}

.table-wrap table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}

.table-wrap thead {
    border-bottom: 1px solid #E5E7EB;
    background: #F9FAFB;
}

.table-wrap th {
    padding: .75rem 1rem;
    color: #6B7280;
    font-size: .875rem;
    font-weight: 500;
}

.table-wrap td {
    padding: .75rem 1rem;
}

.table-wrap tbody tr {
    border-bottom: 1px solid #F3F4F6;
}

.table-wrap tbody tr:hover {
    background: #F9FAFB;
}

/* --- Boutons --- */

.btn {
    display: inline-block;
    font-weight: 600;
    padding: .5rem 1rem;
    border-radius: .375rem;
    text-decoration: none;
    transition: background-color .15s;
    cursor: pointer;
    border: none;
    font-size: .875rem;
}

.btn-primary {
    background: #E10600;
    color: #fff;
}

.btn-primary:hover {
    background: #B91C1C;
}

.btn-lg {
    padding: .5rem 1.5rem;
    font-size: 1rem;
}

.btn-filter {
    background: #fff;
    border: 1px solid #D1D5DB;
    color: #6B7280;
    padding: .375rem .75rem;
    font-size: .8125rem;
}

.btn-filter:hover {
    border-color: #E10600;
    color: #E10600;
}

.btn-filter.active {
    background: #E10600;
    border-color: #E10600;
    color: #fff;
}

/* --- Formulaires --- */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: .875rem;
    color: #6B7280;
    margin-bottom: .25rem;
}

.form-input {
    width: 100%;
    background: #fff;
    border: 1px solid #D1D5DB;
    border-radius: .375rem;
    padding: .5rem .75rem;
    color: #1A1A1A;
    font-family: inherit;
    font-size: .875rem;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: #E10600;
}

/* Wrapper formulaire : centré, card avec padding, boutons centrés */
.form-wrap {
    max-width: 42rem;
    margin: 0 auto;
}
.form-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.pwd-toggle {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6B7280;
    font-size: .75rem;
    cursor: pointer;
    font-family: inherit;
}

.pwd-toggle:hover {
    color: #E10600;
}

.pwd-strength {
    margin-top: .5rem;
}

.pwd-bar {
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: .375rem;
}

.pwd-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width .3s, background-color .3s;
}

.pwd-rules {
    font-size: .75rem;
    color: #9CA3AF;
    display: flex;
    flex-wrap: wrap;
    gap: .125rem .75rem;
}

.pwd-rules .pass {
    color: #16A34A;
}

.pwd-rules .fail {
    color: #9CA3AF;
}

textarea.form-input {
    resize: vertical;
}

.checkbox-list {
    border: 1px solid #D1D5DB;
    border-radius: .375rem;
    background: #fff;
    max-height: 12rem;
    overflow-y: auto;
    padding: .5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .375rem .5rem;
    border-radius: .25rem;
    cursor: pointer;
    font-size: .875rem;
}

.checkbox-item:hover {
    background: #F9FAFB;
}

/* --- Badges / statuts --- */

.badge {
    font-size: .875rem;
}

.badge-success {
    color: #16A34A;
}

.badge-warning {
    color: #CA8A04;
}

.badge-danger {
    color: #DC2626;
}

.badge-info {
    color: #2563EB;
}

.badge-muted {
    color: #9CA3AF;
}

.badge-xs {
    font-size: .75rem;
}

/* --- Liens d'action --- */

.action-link {
    font-size: .875rem;
    text-decoration: none;
    transition: text-decoration .15s;
}

.action-link:hover {
    text-decoration: underline;
}

.action-edit {
    color: #E10600;
}

.action-delete {
    color: #DC2626;
}

/* --- Coherence --- */

.coherence-ok {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: #16A34A;
    color: #fff;
    font-size: .75rem;
}

.coherence-warn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: #F59E0B;
    color: #fff;
    font-size: .875rem;
    cursor: help;
}

/* --- Grilles --- */

.grid-3 {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.grid-modules {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
}

@media (min-width: 768px) {
    .grid-modules {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-modules {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --- Utilitaires --- */

.text-mono {
    font-family: ui-monospace, monospace;
}
.text-upper, .text-lower {
    /* La transformation réelle est faite par JS (event input) */
}

.text-sm {
    font-size: .875rem;
}

.text-muted {
    color: #6B7280;
}

.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mb-6 { margin-bottom: 1.5rem; }
.space-x-2 > * + * { margin-left: .5rem; }

/* --- Toasts (notifications) --- */

#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 400px;
}
.toast {
    padding: .75rem 1.25rem;
    border-radius: .5rem;
    font-size: .9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: toastIn .3s ease;
    cursor: pointer;
}
.toast-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.toast-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.toast-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.toast-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

.toast-exit {
    animation: toastOut .3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* --- Alertes (inline, gardées pour compatibilité) --- */

.alert {
    padding: .75rem 1rem;
    border-radius: .375rem;
    font-size: .875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    color: #B91C1C;
}

.alert-success {
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    color: #166534;
}

.alert-warning {
    background: #FFFBEB;
    border: 1px solid #FCD34D;
    color: #92400E;
}

.alert-info {
    background: #EFF6FF;
    border: 1px solid #93C5FD;
    color: #1E40AF;
}

/* --- Login --- */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    width: 100%;
    max-width: 24rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 1rem;
}

.login-logo img {
    width: 100%;
    height: auto;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #E10600;
    text-align: center;
    margin-bottom: 2rem;
}

.login-form {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    padding: 1.5rem;
}

.login-form > * + * {
    margin-top: 1rem;
}

/* --- Navigation onglets (sections) --- */

.section-nav {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.section-nav-card {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: .5rem;
    font-weight: 600;
    font-size: .9rem;
    color: #6B7280;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    text-decoration: none;
}
.section-nav-card:hover {
    border-color: #E10600;
    color: #1A1A1A;
    text-decoration: none;
}
.section-nav-card.active {
    border-color: #E10600;
    color: #E10600;
    background: #FEF2F2;
}
.section-nav-icon {
    width: 1.25rem;
    height: 1.25rem;
}
.section-nav-card.active .section-nav-icon {
    filter: brightness(0) saturate(100%) invert(12%) sepia(97%) saturate(6083%) hue-rotate(2deg) brightness(95%) contrast(109%);
}
