/* =====================================================================
   beenota-web — feuille de style (basée sur les vraies classes utilisées
   dans views/_header.php, login.php, register.php, dashboard.php,
   traites.php, cheques.php, telegram.php).
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
    background: #f5f6fa;
    color: #1f2937;
    min-height: 100vh;
    line-height: 1.5;
}

a { color: #0a66c2; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin-top: 0; color: #111827; }

/* -----------------------------------------------------------------
   Topbar (barre de navigation après connexion)
   ----------------------------------------------------------------- */
.topbar {
    background: linear-gradient(90deg, #1e3a8a 0%, #1e40af 100%);
    color: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.topbar .brand {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.topbar .brand .accent {
    color: #fbbf24;
}
.topbar nav {
    display: flex;
    gap: 4px;
    margin-left: 24px;
}
.topbar nav a {
    color: #cbd5e1;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.topbar nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
    text-decoration: none;
}
.topbar nav a.active {
    color: #fff;
    background: rgba(255,255,255,.18);
    font-weight: 600;
}
.topbar .flex {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar .muted {
    color: rgba(255,255,255,.85);
    font-size: 13px;
}
.topbar .logout {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.topbar .logout:hover {
    background: rgba(255,255,255,.22);
}

/* -----------------------------------------------------------------
   Layout principal (sous la topbar)
   ----------------------------------------------------------------- */
main.layout, .layout {
    max-width: 1240px;
    margin: 24px auto;
    padding: 0 16px;
}

/* -----------------------------------------------------------------
   Carte de connexion / inscription (login.php, register.php)
   ----------------------------------------------------------------- */
.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}
.login-card {
    background: #fff;
    padding: 36px 30px 28px;
    border-radius: 14px;
    box-shadow: 0 16px 56px rgba(0,0,0,.35);
    width: 100%;
    max-width: 420px;
}
.login-card h1 {
    margin: 0 0 8px;
    font-size: 28px;
    text-align: center;
    color: #0f172a;
    letter-spacing: 0.5px;
}
.login-card h1 .accent {
    color: #f59e0b;
}
.login-card .subtitle {
    color: #64748b;
    margin: 0 0 22px;
    font-size: 14px;
    text-align: center;
}
.login-card label {
    display: block;
    font-size: 13px;
    margin: 14px 0 4px;
    font-weight: 600;
    color: #334155;
}
.login-card input,
.login-card select,
.login-card textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 14px;
    background: #fff;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus,
.login-card select:focus,
.login-card textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.login-card .btn {
    width: 100%;
    padding: 12px 14px;
    margin-top: 18px;
    background: linear-gradient(90deg, #2563eb, #1d4ed8);
    color: #fff;
    border: 0;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.login-card .btn:hover { opacity: 0.92; }
.login-card .btn:active { transform: translateY(1px); }
.login-card .btn:disabled { opacity: 0.6; cursor: wait; }
.login-card .muted {
    color: #64748b;
    font-size: 13px;
}
.login-card .hint {
    color: #64748b;
    font-size: 12px;
    margin-top: 4px;
}

/* Alerts dans la carte */
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 7px;
    margin-top: 12px;
    font-size: 13px;
    border: 1px solid #fecaca;
}
.alert-success {
    background: #f0fdf4;
    color: #166534;
    padding: 10px 14px;
    border-radius: 7px;
    margin-top: 12px;
    font-size: 13px;
    border: 1px solid #bbf7d0;
}

/* Onglets (register Créer / Rejoindre) */
.tabs {
    display: flex;
    gap: 6px;
    margin: 10px 0 16px;
}
.tabs button {
    flex: 1;
    padding: 9px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    transition: all .15s;
    font-family: inherit;
}
.tabs button:hover {
    background: #e2e8f0;
}
.tabs button.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* -----------------------------------------------------------------
   Cartes / sections dans le layout principal
   ----------------------------------------------------------------- */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    padding: 20px;
    margin-bottom: 18px;
    border: 1px solid #e5e7eb;
}
.card h2 {
    margin: 0 0 14px;
    font-size: 18px;
    color: #111827;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}
.card h3 { font-size: 16px; margin-bottom: 12px; }

/* -----------------------------------------------------------------
   Boutons génériques (.btn)
   ----------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: #2563eb;
    color: #fff;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover {
    background: #1d4ed8;
    text-decoration: none;
    color: #fff;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-pay {
    background: #16a34a;
}
.btn-pay:hover {
    background: #15803d;
}

/* -----------------------------------------------------------------
   Tables (échéancier, traites, chèques)
   ----------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #fff;
}
table thead th {
    background: #f9fafb;
    text-align: left;
    padding: 11px 12px;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
table tbody tr:hover { background: #f8fafc; }
table tbody tr:last-child td { border-bottom: 0; }

.amount {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-weight: 500;
}
.right { text-align: right; }

/* -----------------------------------------------------------------
   Badges de statut
   ----------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge.green   { background: #dcfce7; color: #166534; }
.badge.red     { background: #fee2e2; color: #991b1b; }
.badge.yellow  { background: #fef3c7; color: #92400e; }
.badge.orange  { background: #ffedd5; color: #9a3412; }
.badge.blue    { background: #dbeafe; color: #1e40af; }
.badge.gray    { background: #f3f4f6; color: #4b5563; }

/* État vide */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #64748b;
    font-size: 15px;
}

/* -----------------------------------------------------------------
   Utilitaires
   ----------------------------------------------------------------- */
.muted     { color: #64748b; font-size: 13px; }
.hint      { color: #64748b; font-size: 12px; margin-top: 2px; }
.subtitle  { color: #64748b; font-size: 14px; margin-bottom: 12px; }
.flex      { display: flex; align-items: center; gap: 10px; }
.spacer    { flex: 1; }
.actions   { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Spinner inline */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -----------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------- */
@media (max-width: 720px) {
    .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px 14px; }
    .topbar .brand { font-size: 20px; }
    .topbar nav { margin-left: 0; gap: 2px; width: 100%; order: 3; flex-wrap: wrap; }
    .topbar nav a { padding: 6px 10px; font-size: 13px; }
    .topbar .flex { margin-left: auto; gap: 8px; }
    .topbar .muted { font-size: 12px; }

    main.layout, .layout { margin: 14px auto; padding: 0 10px; }

    /* La carte défile horizontalement si son tableau est trop large */
    .card { padding: 16px; overflow-x: auto; }
    .card h2 { font-size: 16px; }

    /* Champs en 16px : empêche le zoom automatique au focus sur iOS */
    .login-card input, .login-card select, .login-card textarea,
    .card input, .card select, .card textarea { font-size: 16px; }

    table { font-size: 13px; white-space: nowrap; }
    table thead th, table tbody td { padding: 8px 8px; }

    /* Boutons d'action pleine largeur, empilables */
    .actions .btn { flex: 1 1 auto; text-align: center; }

    .login-shell { align-items: flex-start; padding: 16px; }
    .login-card { margin-top: 5vh; padding: 26px 20px 22px; }
}

@media (max-width: 420px) {
    .topbar .brand { font-size: 18px; }
    .card { padding: 14px; }
}
