﻿@import "variables.css";

/* ===== Base ===== */
html {
    font-size: var(--fs-text);
    font-family: var(--font-family);
    position: relative;
    min-height: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--fs-text);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    margin-bottom: 60px;
}

/* ===== Typographie ===== */
h1 { font-size: var(--fs-page); font-weight: 700; }
h2 { font-size: var(--fs-section); font-weight: 600; }
h3 { font-size: var(--fs-block); font-weight: 600; }

.text-muted {
    color: var(--text-secondary) !important;
    font-size: var(--fs-small);
}

.text-accent  { color: var(--accent); }
.text-warning-custom { color: var(--warning); }
.text-success-custom { color: var(--success); }
.text-primary-custom { color: var(--action); }
.text-error   { color: var(--error); }

/* ===== Boutons ===== */
.btn {
    border-radius: var(--radius-input);
    font-family: var(--font-family);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
    background-color: var(--action);
    border-color: var(--action);
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--action-hover);
    border-color: var(--action-hover);
    color: #fff;
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: #fff;
    font-weight: 600;
}

.btn-success:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--error);
    border-color: var(--error);
    color: #fff;
    font-weight: 600;
}

/* ===== Focus ===== */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--action);
}

/* ===== Cartes ===== */
.card {
    background-color: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--separator);
    color: var(--text-primary);
    transition: var(--transition);
}

html[data-theme="dark"] .card {
    border-color: transparent;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .card {
        border-color: transparent;
    }
}

.card-header {
    background-color: var(--card);
    border-bottom: 1px solid var(--separator);
    border-radius: calc(var(--radius-card) - 1px) calc(var(--radius-card) - 1px) 0 0 !important;
    padding: var(--padding-card);
}

.card-body { padding: var(--padding-card); }

.dashboard-card {
    border-left: 4px solid var(--action);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    background-color: var(--card);
    transition: var(--transition);
}

.dashboard-card:hover,
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-raised);
}

/* ===== Formulaires ===== */
.form-control, .form-select {
    border-radius: var(--radius-input);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--separator);
    font-family: var(--font-family);
    min-height: 46px;
    padding: 0 var(--space-base);
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--action);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.20);
}

textarea.form-control {
    height: auto;
    padding: 12px var(--space-base);
    resize: vertical;
}

.form-control-sm, .form-select-sm {
    min-height: 40px;
    font-size: var(--fs-small);
    padding: 0 10px;
}

textarea.form-control-sm { height: auto; }

.form-label {
    color: var(--text-secondary);
    font-size: var(--fs-small);
    font-weight: 500;
    margin-bottom: 4px;
}

/* Placeholders */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--text-secondary);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ===== Badges sémantiques ===== */
.badge-success-soft {
    background-color: #DCFCE7;
    color: #16A34A;
    border-radius: var(--radius-badge);
    padding: 4px 10px;
    font-size: var(--fs-small);
    font-weight: 500;
    display: inline-block;
}

.badge-warning-soft {
    background-color: #FEF3C7;
    color: #D97706;
    border-radius: var(--radius-badge);
    padding: 4px 10px;
    font-size: var(--fs-small);
    font-weight: 500;
    display: inline-block;
}

.badge-danger-soft {
    background-color: #FEE2E2;
    color: #DC2626;
    border-radius: var(--radius-badge);
    padding: 4px 10px;
    font-size: var(--fs-small);
    font-weight: 500;
    display: inline-block;
}

.badge-primary-soft {
    background-color: #DBEAFE;
    color: #2563EB;
    border-radius: var(--radius-badge);
    padding: 4px 10px;
    font-size: var(--fs-small);
    font-weight: 500;
    display: inline-block;
}

.badge-accent-soft {
    background-color: #CCFBF1;
    color: #0F766E;
    border-radius: var(--radius-badge);
    padding: 4px 10px;
    font-size: var(--fs-small);
    font-weight: 500;
    display: inline-block;
}

html[data-theme="dark"] .badge-success-soft  { background-color: #14352A; color: #4ADE80; }
html[data-theme="dark"] .badge-warning-soft  { background-color: #3D2E0A; color: #F59E0B; }
html[data-theme="dark"] .badge-danger-soft   { background-color: #4A1C1C; color: #F87171; }
html[data-theme="dark"] .badge-primary-soft  { background-color: #1E3A5F; color: #60A5FA; }
html[data-theme="dark"] .badge-accent-soft   { background-color: #134E4A; color: #2DD4BF; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .badge-success-soft  { background-color: #14352A; color: #4ADE80; }
    html:not([data-theme="light"]) .badge-warning-soft  { background-color: #3D2E0A; color: #F59E0B; }
    html:not([data-theme="light"]) .badge-danger-soft   { background-color: #4A1C1C; color: #F87171; }
    html:not([data-theme="light"]) .badge-primary-soft  { background-color: #1E3A5F; color: #60A5FA; }
    html:not([data-theme="light"]) .badge-accent-soft   { background-color: #134E4A; color: #2DD4BF; }
}

/* ===== Bannière d'erreur API ===== */
.alert-api-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background-color: #FEE2E2;
    color: #DC2626;
    border: 1px solid #FECACA;
    border-radius: var(--radius-badge);
    padding: 12px 16px;
    margin-bottom: 1rem;
}

.alert-api-error .btn-close-text {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

html[data-theme="dark"] .alert-api-error { background-color: #4A1C1C; color: #F87171; border-color: #7F1D1D; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .alert-api-error { background-color: #4A1C1C; color: #F87171; border-color: #7F1D1D; }
}

/* bg-primary override */
.bg-primary { background-color: var(--action) !important; }

/* ===== Avatars ===== */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-avatar);
    color: #fff;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    user-select: none;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 22px;
}

/* ===== Navbar ===== */
.navbar {
    background: var(--gradient-hero) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.navbar-brand { font-size: 1.3rem; font-weight: 700; }

.navbar .nav-link { transition: var(--transition); }

.navbar .nav-link.active,
.navbar .nav-link[aria-current="page"] {
    font-weight: 600;
    border-bottom: 2px solid rgba(255,255,255,0.8);
    padding-bottom: 2px;
}

.navbar .nav-link:hover { opacity: 0.85; }

.navbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    flex-shrink: 0;
}

/* ===== Barre de recherche ===== */
.search-bar-wrapper {
    position: relative;
    margin-bottom: var(--space-base);
}

.search-bar-wrapper .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 18px;
    pointer-events: none;
}

.search-bar-wrapper .form-control {
    padding-left: 40px;
    min-height: 46px;
    border: 1px solid var(--separator);
    background-color: var(--card);
}

.search-bar-wrapper .form-control:focus {
    border-color: var(--action);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.20);
}

/* ===== États vides ===== */
.empty-state {
    text-align: center;
    padding: 32px 24px;
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: var(--space-base);
    display: block;
}

.empty-state-title {
    font-size: var(--fs-block);
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state-subtitle {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    margin-bottom: var(--space-large);
}

/* ===== Séparateur ===== */
.section-separator {
    height: 1px;
    background-color: var(--separator);
    border: none;
    margin: var(--space-base) 0;
}

/* ===== Cartes clients (grid) ===== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap-cards);
}

.client-card {
    background-color: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--padding-card);
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: var(--space-compact);
    border: 1.5px solid var(--separator);
    transition: var(--transition);
}

.client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-raised);
    border-color: var(--action);
    color: var(--text-primary);
    text-decoration: none;
}

.client-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.client-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.client-card-name {
    font-size: var(--fs-block);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-card-company {
    font-size: var(--fs-small);
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: var(--fs-small);
    color: var(--text-secondary);
}

.client-card-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-card-footer {
    display: flex;
    gap: var(--space-compact);
    margin-top: auto;
    padding-top: var(--space-compact);
    border-top: 1px solid var(--separator);
}

/* ===== Stat cards (dashboard) ===== */
.stat-card {
    background-color: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--space-large);
    display: flex;
    align-items: center;
    gap: var(--space-base);
    border: 1px solid var(--separator);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-raised);
}

.stat-card-add {
    border: 1.5px dashed var(--separator) !important;
    box-shadow: none;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon-primary  { background-color: #DBEAFE; }
.stat-icon-success  { background-color: #DCFCE7; }
.stat-icon-warning  { background-color: #FEF3C7; }
.stat-icon-accent   { background-color: #CCFBF1; }

html[data-theme="dark"] .stat-icon-primary  { background-color: #1E3A5F; }
html[data-theme="dark"] .stat-icon-success  { background-color: #14352A; }
html[data-theme="dark"] .stat-icon-warning  { background-color: #3D2E0A; }
html[data-theme="dark"] .stat-icon-accent   { background-color: #134E4A; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .stat-icon-primary  { background-color: #1E3A5F; }
    html:not([data-theme="light"]) .stat-icon-success  { background-color: #14352A; }
    html:not([data-theme="light"]) .stat-icon-warning  { background-color: #3D2E0A; }
    html:not([data-theme="light"]) .stat-icon-accent   { background-color: #134E4A; }
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-value-sm {
    font-size: var(--fs-text);
    font-weight: 600;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Cartes rappels ===== */
.reminders-list {
    display: flex;
    flex-direction: column;
    gap: var(--gap-cards);
}

.reminder-card {
    background-color: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--padding-card);
    display: flex;
    align-items: flex-start;
    gap: var(--space-base);
    border: 1px solid var(--separator);
    border-left: 4px solid var(--warning);
    transition: var(--transition);
}

.reminder-card.completed {
    border-left-color: var(--success);
    opacity: 0.75;
}

.reminder-card.overdue {
    border-left-color: var(--error);
}

.reminder-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-raised);
}

.reminder-card-body {
    flex: 1;
    min-width: 0;
}

.reminder-card-title {
    font-size: var(--fs-text);
    font-weight: 600;
    margin-bottom: 4px;
}

.reminder-card-meta {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.reminder-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== Profil ===== */
.profile-header {
    margin-bottom: var(--space-large);
}

.profile-header h1 { margin-bottom: 4px; }

.profile-subtitle {
    color: var(--text-secondary);
    font-size: var(--fs-small);
    margin: 0;
}

.profile-card { transition: var(--transition); }

.profile-card-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.profile-card-title {
    font-size: var(--fs-block);
    font-weight: 600;
    margin-bottom: var(--space-base);
    color: var(--text-primary);
}

/* ===== Utilitaires typographie ===== */
.fs-micro { font-size: var(--fs-micro) !important; }

/* ===== Logs ===== */
.log-container {
    max-height: 70vh;
    overflow-y: auto;
    font-family: monospace;
}

.log-line {
    display: flex;
    gap: 10px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--separator);
    line-height: 1.4;
    font-size: 0.8rem;
    font-family: monospace;
}

.log-line:last-child { border-bottom: none; }

.log-line.log-err, .log-line.log-error { background-color: rgba(220, 38, 38, 0.08); }
.log-line.log-wrn, .log-line.log-warning { background-color: rgba(217, 119, 6, 0.06); }

.log-ts { color: var(--text-secondary); white-space: nowrap; }
.log-src { font-weight: 600; white-space: nowrap; }
.log-src-web { color: var(--action); }
.log-src-api { color: var(--accent); }
.log-lvl { font-weight: 700; white-space: nowrap; min-width: 36px; }
.log-msg { flex: 1; word-break: break-word; }

/* ===== Navbar améliorée ===== */
.navbar .nav-link.active,
.navbar .nav-link[aria-current="page"] {
    font-weight: 600;
    border-bottom: 2px solid rgba(255,255,255,0.8);
    padding-bottom: 2px;
}

/* ===== Cookie notice ===== */
.cookie-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--separator);
    padding: 12px 0;
    z-index: 1050;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}

.cookie-notice-link {
    color: var(--action);
}

.cookie-notice-hidden {
    display: none;
}

/* ===== Telegram icon theme ===== */
.telegram-icon-light { display: inline-block; }
.telegram-icon-dark  { display: none; }

html[data-theme="dark"] .telegram-icon-light { display: none; }
html[data-theme="dark"] .telegram-icon-dark  { display: inline-block; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .telegram-icon-light { display: none; }
    html:not([data-theme="light"]) .telegram-icon-dark  { display: inline-block; }
}

/* ===== Footer ===== */
.footer {
    background-color: var(--card);
    border-top: 1px solid var(--separator) !important;
    padding: 12px 0;
    font-size: var(--fs-small);
}

/* ===== Transitions globales ===== */
.card, .btn, .nav-link, .list-group-item, .client-card, .reminder-card, .stat-card {
    transition: var(--transition);
}

