/* ═══════════════════════════════════════════════════════════
   entreprises.css — Base de données des Entreprises
   Thème cohérent avec l'app principale (vert WhatsApp)
═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
    --green-main:   #25D366;
    --green-dark:   #075E54;
    --green-light:  #DCF8C6;
    --green-pale:   #f0fdf4;
    --white:        #ffffff;
    --bg:           #f5f5f5;
    --border:       #e0e0e0;
    --text-main:    #111;
    --text-muted:   #666;
    --red:          #dc3545;
    --header-h:     56px;
    --search-h:     96px;
    --tabs-h:       44px;
    --radius:       10px;
    --shadow:       0 2px 8px rgba(0,0,0,0.10);
}

/* ── Reset / Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    font-size: 14px;
    overflow-x: hidden;
}

/* ── Loading overlay ───────────────────────────────────── */
#loading-overlay {
    position: fixed; inset: 0;
    background: var(--green-dark);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999; color: white; gap: 16px;
}
.loader-ring {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App wrapper ───────────────────────────────────────── */
#app {
    display: flex; flex-direction: column;
    height: 100dvh; overflow: hidden;
}

/* ── Header ────────────────────────────────────────────── */
.app-header {
    display: flex; align-items: center; gap: 10px;
    background: var(--green-main);
    color: white;
    padding: 0 14px;
    height: var(--header-h);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: sticky; top: 0; z-index: 100;
}
.back-btn {
    background: none; border: none;
    color: white; font-size: 22px;
    cursor: pointer; padding: 4px 8px 4px 0;
    line-height: 1; flex-shrink: 0;
    opacity: 0.9; transition: opacity .2s;
}
.back-btn:hover { opacity: 1; }
.header-title {
    font-size: 15px; font-weight: 700; text-align: center;
    flex: 1; overflow: hidden; text-overflow: ellipsis;
}
.header-count {
    font-size: 12px; background: rgba(255,255,255,0.2);
    padding: 2px 8px; border-radius: 20px;
    white-space: nowrap; flex-shrink: 0;
}

/* ── Search + Filter bar ───────────────────────────────── */
.search-filter-bar {
    background: var(--green-dark);
    padding: 8px 12px 10px;
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 6px;
}
.search-wrap {
    display: flex; align-items: center;
    background: white; border-radius: 22px;
    padding: 0 12px; gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.search-icon { font-size: 14px; }
#search-input {
    flex: 1; border: none; outline: none;
    font-size: 13px; padding: 8px 0; background: transparent;
    color: var(--text-main);
}
#search-input::placeholder { color: #aaa; }
.clear-search {
    background: none; border: none; cursor: pointer;
    color: #aaa; font-size: 14px; padding: 2px 4px;
    transition: color .2s;
}
.clear-search:hover { color: var(--red); }

.filters-row {
    display: flex; gap: 6px; align-items: center;
}
.filters-row select {
    flex: 1; padding: 6px 8px;
    border: none; border-radius: 20px;
    font-size: 12px; background: rgba(255,255,255,0.15);
    color: white; outline: none; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    min-width: 0;
}
.filters-row select option { color: var(--text-main); background: white; }
.reset-filter-btn {
    background: rgba(255,255,255,0.15); border: none;
    color: white; border-radius: 50%; width: 32px; height: 32px;
    font-size: 16px; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.reset-filter-btn:hover { background: rgba(255,255,255,0.3); }

/* ── Tabs navigation ───────────────────────────────────── */
.tabs-nav {
    display: flex; background: var(--white);
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.tab-btn {
    flex: 1; border: none; background: none;
    padding: 12px 6px; font-size: 13px; font-weight: 600;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color .2s, border-color .2s;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--green-main); }
.tab-btn.active {
    color: var(--green-dark);
    border-bottom-color: var(--green-main);
}
.admin-tab-btn { color: #e53e3e; }
.admin-tab-btn.active { color: #c53030; border-bottom-color: #e53e3e; }

/* ── Tab panes ─────────────────────────────────────────── */
.tab-pane {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column;
    min-height: 0;
}

/* ════════════════════════════════════════════════════════
   ONGLET LISTE
════════════════════════════════════════════════════════ */
.list-col-headers {
    display: grid;
    grid-template-columns: 30% 30% 40%;
    background: var(--green-dark);
    color: white; font-weight: 700; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.5px;
    flex-shrink: 0;
    position: sticky; top: 0; z-index: 10;
}
.col-hdr {
    padding: 10px 8px;
    border-right: 1px solid rgba(255,255,255,0.2);
}
.col-hdr:last-child { border-right: none; }

#entreprises-body {
    flex: 1; overflow-y: auto;
}

/* Ligne entreprise */
.entreprise-row {
    display: grid;
    grid-template-columns: 30% 30% 40%;
    border-bottom: 1px solid var(--border);
    background: white;
    transition: background .15s;
    min-height: 60px;
}
.entreprise-row:hover { background: var(--green-pale); }
.entreprise-row:nth-child(even) { background: #fafafa; }
.entreprise-row:nth-child(even):hover { background: var(--green-pale); }

.cell {
    padding: 10px 8px;
    border-right: 1px solid var(--border);
    font-size: 12.5px; line-height: 1.5;
    word-break: break-word; overflow-wrap: anywhere;
    display: flex; align-items: flex-start;
}
.cell:last-child { border-right: none; }
.cell-content { width: 100%; }

.cell-nom { font-weight: 700; color: var(--green-dark); font-size: 13px; }
.cell-location { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.cell-link { color: var(--green-main); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }
.cell-tag {
    display: inline-block;
    background: var(--green-light); color: var(--green-dark);
    border-radius: 4px; padding: 1px 5px; font-size: 11px;
    margin: 1px 1px 0 0; font-weight: 600;
}

/* Empty / error states */
.empty-state, .error-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted); font-size: 15px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state .empty-icon { font-size: 48px; }

/* Pagination */
.pagination-controls {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; padding: 14px 12px;
    background: white; border-top: 1px solid var(--border);
    flex-wrap: wrap; flex-shrink: 0;
}
.page-btn {
    padding: 6px 12px; border: 1px solid var(--border);
    border-radius: 20px; background: white; cursor: pointer;
    font-size: 13px; color: var(--text-main);
    transition: all .2s;
}
.page-btn:hover:not(:disabled) { background: var(--green-pale); border-color: var(--green-main); color: var(--green-dark); }
.page-btn.active { background: var(--green-dark); color: white; border-color: var(--green-dark); font-weight: 700; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 12px; color: var(--text-muted); padding: 0 6px; }

/* ════════════════════════════════════════════════════════
   ONGLET CRÉER
════════════════════════════════════════════════════════ */
.form-container {
    max-width: 600px; width: 100%;
    margin: 0 auto; padding: 20px 16px 80px;
}
.form-title {
    font-size: 18px; font-weight: 700;
    color: var(--green-dark); margin-bottom: 20px;
    padding-bottom: 10px; border-bottom: 2px solid var(--green-light);
}
.form-group {
    margin-bottom: 16px; display: flex; flex-direction: column; gap: 5px;
}
.form-group label {
    font-size: 13px; font-weight: 600; color: var(--text-main);
}
.required { color: var(--red); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 13.5px;
    outline: none; background: white;
    transition: border-color .2s, box-shadow .2s;
    color: var(--text-main);
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--green-main);
    box-shadow: 0 0 0 3px rgba(37,211,102,0.15);
}
.form-group textarea {
    resize: vertical; min-height: 90px; max-height: 180px;
    line-height: 1.5;
}
.field-hint { font-size: 11px; color: var(--text-muted); }
.char-counter { font-size: 11px; color: var(--text-muted); text-align: right; }

/* Autocomplete catégorie */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 500;
    background: white; border: 1.5px solid var(--green-main);
    border-top: none; border-radius: 0 0 var(--radius) var(--radius);
    max-height: 220px; overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}
.autocomplete-item {
    padding: 9px 12px; cursor: pointer; font-size: 13px;
    transition: background .15s; border-bottom: 1px solid #f0f0f0;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.highlighted {
    background: var(--green-pale); color: var(--green-dark); font-weight: 600;
}
.autocomplete-item mark {
    background: var(--green-light); color: var(--green-dark);
    border-radius: 2px; padding: 0 1px; font-weight: 700;
}
.no-results-item {
    padding: 10px 12px; color: var(--text-muted); font-size: 12px; font-style: italic;
}

/* Notification / Toast */
.form-notification {
    padding: 12px 16px; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}
.form-notification.success { background: var(--green-light); color: var(--green-dark); }
.form-notification.error   { background: #fde8e8; color: var(--red); }

.submit-btn {
    width: 100%; padding: 13px;
    background: var(--green-main); color: white;
    border: none; border-radius: var(--radius);
    font-size: 15px; font-weight: 700;
    cursor: pointer; transition: background .2s, transform .1s;
    letter-spacing: 0.3px;
}
.submit-btn:hover { background: #1db955; }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { background: #aaa; cursor: not-allowed; }

/* ════════════════════════════════════════════════════════
   ONGLET ADMIN PANEL
════════════════════════════════════════════════════════ */
.admin-container {
    padding: 24px 16px; max-width: 600px; margin: 0 auto;
}
.admin-header {
    text-align: center; margin-bottom: 28px;
}
.admin-badge { font-size: 48px; }
.admin-header h2 {
    font-size: 22px; color: #c53030; font-weight: 800;
    margin: 8px 0 6px;
}
.admin-header p { color: var(--text-muted); font-size: 13px; }

.admin-buttons-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.admin-placeholder {
    grid-column: 1 / -1;
    background: white; border: 2px dashed var(--border);
    border-radius: var(--radius); padding: 40px 20px;
    text-align: center; color: var(--text-muted);
}
.placeholder-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Toast global ──────────────────────────────────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #333; color: white;
    padding: 10px 20px; border-radius: 22px;
    font-size: 13px; font-weight: 600;
    z-index: 9999; max-width: 85vw; text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    animation: fadeInUp .3s ease;
}
.toast.success { background: var(--green-dark); }
.toast.error   { background: var(--red); }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive mobile ─────────────────────────────────── */
@media (max-width: 480px) {
    .list-col-headers,
    .entreprise-row {
        grid-template-columns: 32% 28% 40%;
    }
    .col-hdr, .cell {
        padding: 8px 6px; font-size: 11.5px;
    }
    .cell-nom { font-size: 12px; }
    .form-container { padding: 16px 12px 80px; }
    .header-title { font-size: 13px; }
    .tab-btn { font-size: 12px; padding: 10px 4px; }
}
