/* ==========================================================================
   INPI Formalités Manager — Apple-inspired design
   Ultra-clean, lots of white space, SF Pro, subtle grays
   ========================================================================== */

:root {
    --white:     #ffffff;
    --gray-50:   #fafafa;
    --gray-100:  #f5f5f7;
    --gray-200:  #e8e8ed;
    --gray-300:  #d2d2d7;
    --gray-400:  #aeaeb2;
    --gray-500:  #86868b;
    --gray-600:  #6e6e73;
    --gray-700:  #48484a;
    --gray-800:  #3a3a3c;
    --gray-900:  #1d1d1f;

    --navy:       #1a2b4b;
    --navy-dark:  #111d33;
    --navy-light: #243756;
    --cyan:       #00b8d4;
    --cyan-hover: #00cce8;
    --cyan-light: #e5f8fb;

    --blue:      var(--cyan);
    --blue-hover:var(--cyan-hover);
    --blue-light:var(--cyan-light);
    --green:     #34c759;
    --green-bg:  #e8faf0;
    --red:       #ff3b30;
    --red-bg:    #ffeae9;
    --orange:    #ff9500;
    --orange-bg: #fff4e5;

    --radius:    12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow:    0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 16px 48px rgba(0,0,0,0.06);

    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--gray-900);
    background: var(--gray-100);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ── NAV ────────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--gray-200);
}

.nav__inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav__brand {
    display: flex;
    align-items: center;
}

.nav__logo {
    height: 32px;
    width: auto;
}

.nav__right {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.8rem;
}

.nav__env {
    background: var(--navy);
    color: var(--cyan);
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav__user {
    color: var(--gray-600);
}

.nav__logout-form { display:inline; margin:0; padding:0; }
.nav__logout-btn { background:none; border:none; cursor:pointer; font-family:inherit; font-size:inherit; }
.nav__link,
.nav__logout-btn {
    color: var(--navy);
    font-size: 0.8rem;
    font-weight: 500;
}

/* ── CONTAINER ──────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ── FLASH ──────────────────────────────────────────────── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: fadeDown 0.25s var(--ease);
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.flash--success { background: var(--green-bg); color: #1a7f37; }
.flash--error   { background: var(--red-bg); color: var(--red); }

/* ── DEBUG PANEL ────────────────────────────────────────── */
.debug-panel {
    background: var(--navy-dark);
    color: #e0e0e0;
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
    font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.65;
    animation: fadeDown 0.3s var(--ease);
}

.debug-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    user-select: none;
}

.debug-panel__header span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #ff9500;
}

.debug-panel__badge {
    background: #ff9500;
    color: var(--gray-900);
    padding: 1px 7px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
}

.debug-panel__toggle {
    color: var(--gray-400);
    font-size: 0.7rem;
    font-family: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

.debug-panel__body {
    padding: 16px;
    max-height: 400px;
    overflow: auto;
}

.debug-panel__body::-webkit-scrollbar { width: 6px; }
.debug-panel__body::-webkit-scrollbar-track { background: transparent; }
.debug-panel__body::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 3px; }

.debug-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 4px 12px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.debug-row:last-child { border-bottom: none; }

.debug-label {
    color: var(--gray-500);
    font-weight: 500;
    white-space: nowrap;
}

.debug-value {
    color: #e0e0e0;
    word-break: break-all;
}

.debug-value--error { color: var(--red); }

.debug-value--url { color: #64d2ff; }

.debug-value--code {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.debug-code-ok   { background: rgba(52,199,89,0.15); color: var(--green); }
.debug-code-err  { background: rgba(255,59,48,0.15); color: var(--red); }

.debug-raw {
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
    max-height: 250px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--gray-400);
    font-size: 0.7rem;
}

/* ── LOGIN ──────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    padding: 24px;
}

.login-wrapper {
    width: 100%;
    max-width: 380px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 40px 32px 32px;
    box-shadow: var(--shadow-md);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.025em;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* ── TRUST BADGES ──────────────────────────────────────── */
.trust-badges {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.trust-badge {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
}

.trust-badge__icon {
    width: 22px;
    height: 22px;
    color: #6366f1;
    flex-shrink: 0;
    margin-top: 1px;
}

.trust-badge div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.trust-badge strong {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-800);
}

.trust-badge span {
    font-size: 0.7rem;
    color: var(--gray-400);
    line-height: 1.3;
}

.login-cpu-notice {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
    font-size: 0.72rem;
    color: var(--gray-400);
    line-height: 1.6;
}

.login-cpu-notice strong {
    color: var(--gray-600);
    font-weight: 600;
}

.login-cpu-notice a {
    color: var(--primary);
}

/* ── FORMS ──────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    outline: none;
}

.form-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,184,212,0.12);
}

.form-input::placeholder { color: var(--gray-400); }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2386868b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
    background: var(--navy);
    color: white;
}
.btn--primary:hover { background: var(--navy-light); color: white; }

.btn--full { width: 100%; }
.btn--lg   { padding: 11px 20px; font-size: 0.9rem; border-radius: var(--radius); }

.btn--secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}
.btn--secondary:hover { background: var(--gray-200); }

.btn--ghost {
    background: transparent;
    color: var(--blue);
}
.btn--ghost:hover { background: var(--blue-light); }

.btn--sm {
    padding: 5px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* ── PAGE HEADER ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.03em;
}

.page-header__count {
    color: var(--gray-500);
    font-size: 0.85rem;
    font-weight: 400;
}

/* ── SEARCH BAR (always visible) ─────────────────────────── */
.search-bar {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.search-bar__main {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-bar__input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.search-bar__toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cyan);
    cursor: pointer;
    transition: color 0.15s;
}

.search-bar__toggle:hover {
    color: var(--cyan-hover);
}

.search-bar__chevron {
    transition: transform 0.2s;
}

.search-bar__advanced.open ~ .search-bar__toggle .search-bar__chevron,
.search-bar__toggle.active .search-bar__chevron {
    transform: rotate(180deg);
}

.search-bar__advanced {
    display: none;
    padding-top: 14px;
    margin-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.search-bar__advanced.open {
    display: block;
}

.search-bar__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
    align-items: end;
}

.search-bar__group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.search-bar__group .form-input {
    padding: 8px 12px;
    font-size: 0.82rem;
}

/* ── TABLE ──────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 10px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.table td {
    padding: 12px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }

.table__row--link {
    cursor: pointer;
}
.table__row--link:hover {
    background: var(--cyan-light) !important;
}

.table__mono {
    font-family: 'SF Mono', SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
    font-weight: 500;
}

.table__actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    white-space: nowrap;
}

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--green  { background: var(--green-bg); color: #1a7f37; }
.badge--red    { background: var(--red-bg); color: var(--red); }
.badge--orange { background: var(--orange-bg); color: #a05a00; }
.badge--blue   { background: var(--blue-light); color: var(--blue); }
.badge--gray   { background: var(--gray-100); color: var(--gray-600); }

/* ── PAGINATION ─────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 16px;
}

.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.pagination a { color: var(--gray-700); }
.pagination a:hover { background: var(--gray-100); }
.pagination .active { background: var(--navy); color: white; }
.pagination .disabled { color: var(--gray-300); pointer-events: none; }

/* ── DETAIL ─────────────────────────────────────────────── */
.detail-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.detail-top h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--navy);
}

.detail-top__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    color: var(--gray-500);
    font-size: 0.82rem;
}

.detail-top__actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.stat__label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.stat__value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* ── JSON VIEWER ────────────────────────────────────────── */
.json-viewer {
    background: var(--navy-dark);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.json-viewer__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.json-viewer__title {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-400);
}

.json-viewer__btns {
    display: flex;
    gap: 4px;
}

.json-viewer__btn {
    background: rgba(255,255,255,0.07);
    color: var(--gray-400);
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.json-viewer__btn:hover {
    background: rgba(255,255,255,0.14);
    color: white;
}

.json-viewer__body {
    padding: 16px;
    max-height: 70vh;
    overflow: auto;
    font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    color: #c7c7cc;
    tab-size: 2;
}

.json-viewer__body::-webkit-scrollbar { width: 6px; height: 6px; }
.json-viewer__body::-webkit-scrollbar-track { background: transparent; }
.json-viewer__body::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 3px; }

/* JSON highlighting */
.j-key  { color: #64d2ff; }
.j-str  { color: #30d158; }
.j-num  { color: #ffd60a; }
.j-bool { color: #bf5af2; }
.j-null { color: #636366; font-style: italic; }

/* ── MODAL ──────────────────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.overlay.active { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 520px;
    max-height: 75vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: var(--shadow-lg);
    animation: modalUp 0.25s var(--ease);
}

@keyframes modalUp {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal__head h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal__close {
    background: var(--gray-100);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: background 0.15s;
}

.modal__close:hover { background: var(--gray-200); }

/* ── TIMELINE ───────────────────────────────────────────── */
.timeline { padding-left: 20px; position: relative; }

.timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 6px;
    bottom: 6px;
    width: 1.5px;
    background: var(--gray-200);
}

.tl-item {
    position: relative;
    padding-bottom: 20px;
}

.tl-item:last-child { padding-bottom: 0; }

.tl-item::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--blue);
}

.tl-item__date {
    font-size: 0.72rem;
    color: var(--gray-500);
}

.tl-item__status {
    font-weight: 600;
    font-size: 0.85rem;
}

/* ── EMPTY ──────────────────────────────────────────────── */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-400);
}

.empty p { font-size: 0.9rem; margin-top: 8px; }

/* ── SPINNER ────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── FOOTER ──────────────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--gray-200);
    background: var(--white);
    margin-top: 48px;
}

.footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 24px;
}

.footer__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 32px;
    flex-wrap: wrap;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
}

.footer__brand img {
    height: 28px;
    margin-bottom: 10px;
}

.footer__brand p {
    font-size: 0.78rem;
    color: var(--gray-500);
    max-width: 280px;
    line-height: 1.5;
}

.footer__links {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.footer__col h4 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.footer__col a {
    display: block;
    font-size: 0.8rem;
    color: var(--gray-700);
    padding: 3px 0;
    transition: color 0.15s;
}

.footer__col a:hover { color: var(--cyan); }

.footer__social {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.footer__social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--gray-100);
    color: var(--gray-600);
    transition: all 0.15s;
}

.footer__social a:hover {
    background: var(--navy);
    color: white;
}

.footer__social svg { width: 16px; height: 16px; }

.footer__bottom {
    padding-top: 16px;
    text-align: center;
    font-size: 0.7rem;
    color: var(--gray-400);
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .nav__inner { padding: 0 16px; }
    .container { padding: 20px 16px; }
    .search-bar__grid { grid-template-columns: 1fr 1fr; }
    .detail-top { flex-direction: column; }
    .stats { grid-template-columns: 1fr 1fr; }
    .card { overflow-x: auto; }
    .table { min-width: 550px; }
    .footer__top { flex-direction: column; }
}

@media (max-width: 480px) {
    .stats { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px 24px; }
    .search-bar__grid { grid-template-columns: 1fr; }
}
