/* ============================================================
   EUROPNET CRM — Thème global (noir #1a1a1a / blanc #ffffff)
   ============================================================ */

/* Variables */
:root {
    --color-bg: #ffffff;
    --color-surface: #f5f5f5;
    --color-surface-hover: #ececec;
    --color-border: #e0e0e0;
    --color-primary: #1a1a1a;
    --color-primary-light: #333333;
    --color-text: #1a1a1a;
    --color-text-muted: #666666;
    --color-accent: #1a1a1a;
    --color-tag: #1a1a1a;
    --color-danger: #c0392b;
    --color-success: #27ae60;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
}

/* Reset de base */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    font-family: 'Poppins', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--color-primary);
    margin-top: 0;
}

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

a:hover {
    text-decoration: underline;
}

/* ============================================================
   Radzen overrides — thème noir/blanc
   ============================================================ */

/* Bouton primary */
.rz-button.rz-primary,
.rz-button-primary {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #fff !important;
}

.rz-button.rz-primary:hover,
.rz-button-primary:hover {
    background: var(--color-primary-light) !important;
    border-color: var(--color-primary-light) !important;
}

/* Tabs */
.rz-tabview-nav .rz-tabview-selected > a {
    border-bottom-color: var(--color-primary) !important;
    color: var(--color-primary) !important;
}

/* Cards */
.rz-card {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* ============================================================
   Layout
   ============================================================ */

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

.app-sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 100;
}

.app-sidebar-logo {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
}

.sidebar-logo-img {
    height: 36px;
    width: auto;
    object-fit: contain;
    display: block;
}

.app-nav {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    gap: 2px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    text-decoration: none;
}

.app-nav-link:hover,
.app-nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}

.app-nav-link .nav-icon {
    font-size: 1rem;
    opacity: 0.8;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--color-bg);
    overflow-x: hidden;
}

.app-topbar {
    height: 56px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-topbar-title {
    font-size: 1rem;
    font-weight: 600;
}

.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================================
   Badge tag "épinglé"
   ============================================================ */

.badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-tag);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ============================================================
   Badge ID agence
   ============================================================ */

.badge-id {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1px 6px;
    margin-right: 0.4rem;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Agence Card (liste)
   ============================================================ */

.agence-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.agence-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #bbb;
}

.agence-card.pinned {
    border-left: 3px solid var(--color-primary);
}

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

.agence-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.agence-card-meta {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.agence-card-statut {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    background: var(--color-surface);
}

/* ============================================================
   Grid agences
   ============================================================ */

.agences-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

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

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

/* ============================================================
   Barre de recherche
   ============================================================ */

.search-bar {
    margin-bottom: 1.25rem;
}

/* ============================================================
   Page Login
   ============================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    padding: 1rem;
}

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

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
    background: black;
    border-radius: var(--radius);
    padding: 1rem;
}

.login-logo-img {
    height: 48px;
    width: auto;
    object-fit: contain;
    display: inline-block;
}

.login-error {
    background: #fdf2f2;
    border: 1px solid #f5c6cb;
    color: var(--color-danger);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ============================================================
   Détail agence
   ============================================================ */

.agence-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.agence-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem 1.5rem;
}

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

.info-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.info-item span {
    font-size: 0.9rem;
    color: var(--color-text);
}

.info-empty {
    color: var(--color-text-muted);
    font-style: italic;
}

/* ============================================================
   Contact card
   ============================================================ */

.contact-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    cursor: pointer;
    transition: box-shadow 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: #bbb;
}

.contact-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.contact-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ============================================================
   Compte rendu card
   ============================================================ */

.cr-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cr-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cr-date {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cr-author {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.cr-infos {
    font-size: 0.88rem;
    color: var(--color-text);
    line-height: 1.5;
}

/* ============================================================
   Section header (avec bouton à droite)
   ============================================================ */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* ============================================================
   Map
   ============================================================ */

.map-container {
    width: 100%;
    height: 280px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
    margin-top: 1rem;
}

/* ============================================================
   Blazor error UI
   ============================================================ */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ============================================================
   Loading
   ============================================================ */

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--color-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ============================================================
   Onglets CRM — mobile-first
   ============================================================ */

/* Contenu des onglets */
.tab-content {
    padding: 1rem 0;
}

/* Barre d'onglets scrollable horizontalement sur mobile */
.crm-tabs .rz-tabview-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 2px solid var(--color-border);
    gap: 0;
    padding: 0;
    margin-bottom: 0;
}

.crm-tabs .rz-tabview-nav::-webkit-scrollbar {
    display: none;
}

/* Chaque onglet : taille fixe minimale pour ne pas se tasser */
.crm-tabs .rz-tabview-nav li {
    flex: 0 0 auto;
    min-width: 80px;
}

.crm-tabs .rz-tabview-nav li a {
    display: block;
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-text-muted);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    text-decoration: none;
}

.crm-tabs .rz-tabview-nav li a:hover {
    color: var(--color-text);
}

.crm-tabs .rz-tabview-selected a,
.crm-tabs .rz-tabview-nav li.rz-tabview-selected a {
    color: var(--color-primary) !important;
    border-bottom-color: var(--color-primary) !important;
    font-weight: 600;
}

/* Supprimer le style Radzen par défaut qui peut surcharger */
.crm-tabs .rz-tabview-panels {
    padding: 0;
    border: none;
}

/* ============================================================
   Info section (bloc avec titre dans détail agence)
   ============================================================ */

.info-section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.info-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin: 0 0 0.85rem 0;
}

/* ============================================================
   Texte RTF dépouillé
   ============================================================ */

.rtf-text {
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
}

/* ============================================================
   Formulaire inline (ajout contact / CR)
   ============================================================ */

.inline-form-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* ============================================================
   Bottom nav (mobile only)
   ============================================================ */

.bottom-nav {
    display: none;
}

@media (max-width: 767px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--color-primary);
        border-top: 1px solid rgba(255,255,255,0.1);
        z-index: 200;
        align-items: stretch;
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: rgba(255,255,255,0.65);
        font-size: 0.72rem;
        font-weight: 500;
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        transition: color 0.15s, background 0.15s;
    }

    .bottom-nav-item:hover,
    .bottom-nav-item.active {
        color: #fff;
        background: rgba(255,255,255,0.08);
        text-decoration: none;
    }

    .bottom-nav-icon {
        font-size: 1rem;
        line-height: 1;
    }

    .bottom-nav-label {
        font-size: 0.68rem;
        letter-spacing: 0.02em;
    }

    .bottom-nav-logout {
        color: rgba(255,255,255,0.55);
    }
}

/* ============================================================
   Responsive : sidebar mobile
   ============================================================ */

@media (max-width: 767px) {
    .app-sidebar {
        display: none;
    }

    .app-content {
        padding: 1rem;
        padding-bottom: calc(1rem + 60px); /* space for bottom nav */
    }

    .agence-title {
        font-size: 1.1rem;
    }

    .crm-tabs .rz-tabview-nav li a {
        padding: 0.6rem 0.75rem;
        font-size: 0.82rem;
    }
}
