/* Densité générale — pensé pour une fenêtre d'environ 890px de large, tout en restant
   utilisable sur les autres tailles (UIkit gère déjà la réorganisation des colonnes). */

body {
    font-size: 13px;
}

.uk-container {
    padding-left: 14px;
    padding-right: 14px;
}

h1, .uk-h1 { font-size: 1.3rem; line-height: 1.3; }
h2, .uk-h2 { font-size: 1.1rem; line-height: 1.3; }
h3, .uk-h3 { font-size: 1rem; line-height: 1.3; margin-bottom: 8px; }
h4, .uk-h4 { font-size: 0.9rem; line-height: 1.3; margin-bottom: 6px; }

/* Espacements verticaux resserrés entre les blocs */
.uk-margin, .uk-margin-top { margin-top: 14px !important; }
.uk-margin-small, .uk-margin-small-top { margin-top: 6px !important; }
.uk-margin-large-top { margin-top: 20px !important; }

/* Cartes plus compactes */
.uk-card-body { padding: 14px; }
.uk-card-small > .uk-card-body,
.uk-card-small.uk-card-body { padding: 10px 12px; }

/* Tableaux plus denses */
.uk-table th, .uk-table td { padding: 6px 10px; font-size: 12.5px; }
.uk-table-small th, .uk-table-small td { padding: 4px 8px; }

/* Boutons et formulaires */
.uk-button { padding: 0 14px; font-size: 12.5px; line-height: 32px; }
.uk-button-small { padding: 0 10px; font-size: 11.5px; line-height: 26px; }
.uk-input, .uk-select, .uk-textarea { font-size: 12.5px; padding: 4px 10px; min-height: 32px; }
.uk-textarea { padding: 8px 10px; }
.uk-form-label { font-size: 12px; margin-bottom: 2px; display: inline-block; }

/* Navigation principale */
.uk-navbar-container:not(.uk-navbar-transparent) { min-height: 44px; }
.uk-navbar-nav > li > a, .uk-navbar-item, .uk-navbar-toggle { min-height: 44px; font-size: 12.5px; padding: 0 10px; }

/* Onglets et badges */
.uk-subnav { font-size: 12.5px; }
.uk-subnav > * > :first-child { padding: 4px 2px; }
.uk-label { font-size: 10px; padding: 2px 7px; }
.uk-badge { font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; }

/* Listes de contacts/commentaires/historique */
.uk-list > li { padding: 6px 0; }
.uk-list-divider > li:nth-child(n+2) { margin-top: 0; padding-top: 6px; }

/* Autocomplétion (client / fournisseur) */
.js-combobox { position: relative; }
.js-combobox-list {
    position: absolute;
    z-index: 1020;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-top: none;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}
.js-combobox-option { padding: 6px 10px; cursor: pointer; font-size: 12.5px; }
.js-combobox-option:hover, .js-combobox-option.is-active { background: #f0f5ff; }
.js-combobox-empty { padding: 6px 10px; color: #999; font-size: 12.5px; }

/* Statut "À facturer" (compte de facturation uniquement) : teinte dédiée, bien distincte des autres onglets. */
.uk-subnav-pill > .status-to-invoice-tab > a {
    color: #0ca678;
    border: 1px solid #0ca678;
    border-radius: 500px;
    font-weight: 600;
}
.uk-subnav-pill > .status-to-invoice-tab.uk-active > a { background: #0ca678; color: #fff; }
.status-to-invoice-tab .uk-badge { background: #0ca678; }
.status-to-invoice-tab.uk-active .uk-badge { background: #fff; color: #0ca678; }
.uk-table tbody tr.row-to-invoice { background: #e6fcf5; }
.js-row-status-select.is-to-invoice { border-color: #0ca678; background: #e6fcf5; color: #087f5b; font-weight: 600; }

/* Fiche tâche — bloc email repliable. Jamais de débordement horizontal (longues URL), même
   pour un texte collé sans espaces. Replier la colonne entière (display:none) libère sa largeur
   pour la colonne tâche sur ordinateur ; sous 640px (une seule colonne empilée, rien à libérer
   horizontalement) on anime plutôt le repli via max-height + opacity pour une transition douce. */
.task-email-body {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.task-email-body img { max-width: 100%; height: auto; }

#task-email-col.is-collapsed { display: none; }

/* Bouton rouge « rendez-vous par la voix » : au-dessus du bouton + (mobile, compte propriétaire) */
.fab-agenda {
    position: fixed;
    right: 16px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f0506e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 980;
}
@media (max-width: 639px) { body.has-agenda-fab { padding-bottom: calc(156px + env(safe-area-inset-bottom)); } }

/* Micro de dictée (page Agenda et fenêtre du bouton rouge) */
.ag-mic { width: 76px; height: 76px; border-radius: 50%; border: 0; background: #1e87f0; color: #fff; font-size: 30px; cursor: pointer; flex: none; }
.ag-mic.is-listening { background: #f0506e; animation: ag-pulse 1.1s infinite; }
@keyframes ag-pulse { 0% { box-shadow: 0 0 0 0 rgba(240, 80, 110, .5); } 70% { box-shadow: 0 0 0 16px rgba(240, 80, 110, 0); } 100% { box-shadow: 0 0 0 0 rgba(240, 80, 110, 0); } }

@media (max-width: 639px) {
    #task-email-col {
        overflow: hidden;
        max-height: 10000px;
        opacity: 1;
        transition: max-height 0.25s ease, opacity 0.2s ease;
    }
    #task-email-col.is-collapsed {
        display: block;
        max-height: 0;
        opacity: 0;
    }
}

/* ==========================================================================
   Version téléphone (< 640px) — l'application reste la même, installable sur l'écran d'accueil
   (manifest) ; seule la présentation change : menu burger, bouton "+" flottant, tableau de bord
   en cartes, champs en 16px (sinon iOS zoome automatiquement au focus) et zones tactiles élargies.
   ========================================================================== */
.fab-new-task {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #1e87f0;
    color: #fff;
    font-size: 32px;
    line-height: 54px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 980;
}

@media (max-width: 639px) {
    html, body { max-width: 100%; overflow-x: hidden; }
    body { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
    .uk-container { padding-left: 10px; padding-right: 10px; }
    h1, .uk-h1 { font-size: 1.15rem; }

    /* Zones tactiles et champs */
    .uk-input, .uk-select, .uk-textarea { font-size: 16px; min-height: 44px; }
    .uk-button { line-height: 42px; padding: 0 16px; font-size: 14px; }
    .uk-button-small { line-height: 36px; padding: 0 12px; font-size: 13px; }
    .uk-checkbox, .uk-radio { width: 20px; height: 20px; }
    .uk-subnav > * > :first-child { padding: 8px 12px; }
    .js-combobox-option, .js-combobox-empty { padding: 12px 10px; font-size: 16px; }
    .uk-navbar-container:not(.uk-navbar-transparent) { padding-top: env(safe-area-inset-top); }

    /* Onglets du tableau de bord : une seule ligne défilante au doigt */
    #dashboard-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-left: 0;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #dashboard-tabs::-webkit-scrollbar { display: none; }
    #dashboard-tabs > li { flex: none; padding-left: 6px; white-space: nowrap; }

    /* Tableau de bord : une carte par tâche */
    #dashboard-table, #dashboard-table tbody { display: block; width: 100%; }
    #dashboard-table thead { display: none; }
    #dashboard-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 10px;
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
        border: 1px solid #e5e5e5;
        border-radius: 8px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }
    #dashboard-table tbody tr.row-to-invoice { background: #e6fcf5; border-color: #0ca678; }
    #dashboard-table td { display: block; padding: 0; border: 0; }
    #dashboard-table .td-title { width: 100%; font-size: 14px; font-weight: 600; }
    #dashboard-table .td-client, #dashboard-table .td-status, #dashboard-table .td-actions { width: 100%; }
    #dashboard-table .td-actions .uk-button { width: 100%; }

    /* Écran d'accueil compact : le bouton "+" flottant remplace le bouton d'en-tête, et les compteurs
       résumé / par salarié sont déjà dans les onglets — on gagne la place pour voir les tâches tout de suite. */
    .dashboard-head { margin-top: 6px !important; }
    .dashboard-head h1 { font-size: 1.05rem; }
    .dashboard-head .uk-button,
    #dashboard-summary,
    .dashboard-employee-counts { display: none; }
    #dashboard-tabs { font-size: 13px; }
    #dashboard-tabs .uk-badge { font-size: 11px; }

    /* Autres listes (clients, fournisseurs, emails reçus...) : défilement horizontal plutôt que débordement */
    .uk-table:not(#dashboard-table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
