/* ============================================================
   Plank — Design System
   Thème : light uniquement, minimaliste, typographie soignée
   Police : DM Sans (Google Fonts, chargée dans les layouts)
   ============================================================ */

/* ============================================================
   1. VARIABLES
   ============================================================ */

:root {
    /* Couleurs de base */
    --c-white:       #ffffff;
    --c-bg:          #f5f4f1;       /* fond page — légèrement chaud */
    --c-surface:     #ffffff;       /* cartes, sidebar, topbar */
    --c-border:      #e8e6e1;       /* bordures principales */
    --c-border-soft: #f0ede8;       /* bordures subtiles */

    /* Texte */
    --c-text-primary:   #1a1917;
    --c-text-secondary: #6b6860;
    --c-text-tertiary:  #a09d96;
    --c-text-inverse:   #ffffff;

    /* Accent — un seul, utilisé avec parcimonie */
    --c-accent:       #1a1917;      /* boutons primaires */
    --c-accent-hover: #2d2b28;

    /* Statuts tickets */
    --c-new:       #dbeafe; --c-new-text:       #1e40af;
    --c-wip:       #fef3c7; --c-wip-text:       #92400e;
    --c-standby:   #ede9fe; --c-standby-text:   #5b21b6;
    --c-resolved:  #d1fae5; --c-resolved-text:  #065f46;
    --c-closed:    #f3f4f6; --c-closed-text:    #6b7280;
    --c-rejected:  #fee2e2; --c-rejected-text:  #991b1b;

    /* Priorités */
    --c-prio-high:   #fee2e2; --c-prio-high-text:   #991b1b;
    --c-prio-medium: #fef3c7; --c-prio-medium-text: #92400e;
    --c-prio-low:    #f3f4f6; --c-prio-low-text:    #6b7280;

    /* Flash messages */
    --c-success:      #d1fae5; --c-success-text: #065f46; --c-success-border: #6ee7b7;
    --c-error:        #fee2e2; --c-error-text:   #991b1b; --c-error-border:   #fca5a5;
    --c-info:         #dbeafe; --c-info-text:    #1e40af; --c-info-border:    #93c5fd;

    /* Layout */
    --sidebar-w: 220px;
    --topbar-h:  52px;

    /* Typographie */
    --font: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'DM Mono', 'Fira Mono', monospace;

    /* Rayons */
    --r-sm:  4px;
    --r-md:  7px;
    --r-lg: 10px;
    --r-xl: 14px;

    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */

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

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

body {
    font-family: var(--font);
    background: var(--c-bg);
    color: var(--c-text-primary);
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; }

button { font-family: var(--font); cursor: pointer; }

textarea, input, select {
    font-family: var(--font);
    font-size: inherit;
}

/* ============================================================
   3. LAYOUT PRINCIPAL (app)
   ============================================================ */

.layout-app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}

/* ============================================================
   4. SIDEBAR
   ============================================================ */

.sidebar {
    grid-area: sidebar;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

/* Logo */
.sidebar__logo {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.logo-mark {
    width: 22px;
    height: 22px;
    background: var(--c-accent);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-mark svg {
    width: 12px;
    height: 12px;
    fill: var(--c-white);
}

.logo-text {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--c-text-primary);
}

/* Sections */
.sidebar__section {
    padding: 14px 10px 6px;
}

.sidebar__section + .sidebar__section {
    border-top: 1px solid var(--c-border-soft);
    margin-top: 4px;
}

.sidebar__label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--c-text-tertiary);
    padding: 0 8px;
    margin-bottom: 4px;
}

/* Items de navigation */
.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    color: var(--c-text-secondary);
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: var(--c-bg);
    color: var(--c-text-primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--c-bg);
    color: var(--c-text-primary);
    font-weight: 500;
}

.nav-item__icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.55;
}

.nav-item.active .nav-item__icon,
.nav-item:hover .nav-item__icon {
    opacity: 1;
}

.nav-item__count {
    margin-left: auto;
    font-size: 11px;
    background: var(--c-border);
    color: var(--c-text-tertiary);
    border-radius: 10px;
    padding: 1px 6px;
    font-weight: 500;
}

/* Org switcher */
.org-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-primary);
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
}

.org-switcher:hover {
    background: var(--c-bg);
    text-decoration: none;
}

.org-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--r-sm);
    background: var(--c-accent);
    color: var(--c-white);
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

/* Bas de sidebar : utilisateur connecté */
.sidebar__bottom {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid var(--c-border);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.12s;
}

.user-pill:hover {
    background: var(--c-bg);
    text-decoration: none;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--c-border);
    color: var(--c-text-secondary);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-pill__info { min-width: 0; }

.user-pill__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-pill__email {
    font-size: 11px;
    color: var(--c-text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   5. TOPBAR
   ============================================================ */

.topbar {
    grid-area: topbar;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar__breadcrumb {
    font-size: 13.5px;
    color: var(--c-text-tertiary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar__breadcrumb a {
    color: var(--c-text-tertiary);
    transition: color 0.12s;
}

.topbar__breadcrumb a:hover {
    color: var(--c-text-primary);
    text-decoration: none;
}

.topbar__breadcrumb strong {
    color: var(--c-text-primary);
    font-weight: 500;
}

.topbar__sep {
    color: var(--c-border);
    font-size: 16px;
    user-select: none;
}

.topbar__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   6. MAIN CONTENT
   ============================================================ */

.main {
    grid-area: main;
    min-height: calc(100vh - var(--topbar-h));
    overflow-x: hidden;
}

.page {
    padding: 24px;
    max-width: 1100px;
}

.page--wide {
    max-width: none;
    padding: 0;
}

/* ============================================================
   7. FLASH MESSAGES
   ============================================================ */

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 500;
    margin: 16px 24px 0;
    border: 1px solid;
}

.flash--success {
    background: var(--c-success);
    color: var(--c-success-text);
    border-color: var(--c-success-border);
}

.flash--error {
    background: var(--c-error);
    color: var(--c-error-text);
    border-color: var(--c-error-border);
}

.flash--info {
    background: var(--c-info);
    color: var(--c-info-text);
    border-color: var(--c-info-border);
}

/* ============================================================
   8. BOUTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s, opacity 0.12s;
    white-space: nowrap;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn--primary {
    background: var(--c-accent);
    color: var(--c-white);
    border-color: var(--c-accent);
}

.btn--primary:hover {
    background: var(--c-accent-hover);
    border-color: var(--c-accent-hover);
}

.btn--secondary {
    background: var(--c-surface);
    color: var(--c-text-primary);
    border-color: var(--c-border);
}

.btn--secondary:hover {
    background: var(--c-bg);
}

.btn--ghost {
    background: transparent;
    color: var(--c-text-secondary);
    border-color: var(--c-border);
}

.btn--ghost:hover {
    background: var(--c-bg);
    color: var(--c-text-primary);
}

.btn--danger {
    background: var(--c-rejected);
    color: var(--c-rejected-text);
    border-color: #fca5a5;
}

.btn--danger:hover { opacity: 0.85; }

.btn--sm {
    padding: 4px 10px;
    font-size: 12.5px;
}

.btn--full { width: 100%; justify-content: center; }

.btn--icon {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--c-text-tertiary);
    border-radius: var(--r-sm);
}

.btn--icon:hover {
    background: var(--c-bg);
    color: var(--c-text-primary);
}

/* ============================================================
   9. FORMULAIRES
   ============================================================ */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-primary);
    margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: 13.5px;
    color: var(--c-text-primary);
    background: var(--c-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #a09d96;
    box-shadow: 0 0 0 3px rgba(160,157,150,0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--c-text-tertiary);
}

.form-select {
    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='%23a09d96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    cursor: pointer;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--c-text-tertiary);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ============================================================
   10. BADGES / TAGS
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
}

/* Statuts */
.badge--new      { background: var(--c-new);      color: var(--c-new-text); }
.badge--in_progress { background: var(--c-wip);   color: var(--c-wip-text); }
.badge--standby  { background: var(--c-standby);  color: var(--c-standby-text); }
.badge--resolved { background: var(--c-resolved); color: var(--c-resolved-text); }
.badge--closed   { background: var(--c-closed);   color: var(--c-closed-text); }
.badge--rejected { background: var(--c-rejected); color: var(--c-rejected-text); }

/* Priorités */
.badge--high   { background: var(--c-prio-high);   color: var(--c-prio-high-text); }
.badge--medium { background: var(--c-prio-medium); color: var(--c-prio-medium-text); }
.badge--low    { background: var(--c-prio-low);    color: var(--c-prio-low-text); }

/* ============================================================
   11. AVATARS
   ============================================================ */

.avatar {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--c-border);
    color: var(--c-text-secondary);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar--sm  { width: 22px; height: 22px; font-size: 9px; }
.avatar--md  { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg  { width: 36px; height: 36px; font-size: 13px; }

/* ============================================================
   12. CARDS
   ============================================================ */

.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 20px;
}

.card--sm { padding: 14px 16px; }

.card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================================
   13. MENTION
   ============================================================ */

.mention {
    color: #1d4ed8;
    font-weight: 500;
    background: #eff6ff;
    padding: 0 3px;
    border-radius: 3px;
}

/* ============================================================
   14. LAYOUT AUTH (centré, pages login/onboarding/invite)
   ============================================================ */

.layout-auth {
    min-height: 100vh;
    background: var(--c-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    padding: 36px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-card__logo {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 28px;
}

.auth-card__title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--c-text-primary);
    margin-bottom: 6px;
}

.auth-card__subtitle {
    font-size: 14px;
    color: var(--c-text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.auth-form { display: flex; flex-direction: column; gap: 4px; }

.auth-form .btn { margin-top: 8px; }

.auth-hint {
    font-size: 13px;
    color: var(--c-text-tertiary);
    margin: 12px 0;
    text-align: center;
}

/* ============================================================
   15. UTILITAIRES
   ============================================================ */

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.text-muted    { color: var(--c-text-secondary); }
.text-tertiary { color: var(--c-text-tertiary); }
.text-sm       { font-size: 12.5px; }
.text-xs       { font-size: 11.5px; }
.font-mono     { font-family: var(--font-mono); }

.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-2         { gap: 4px; }
.gap-4         { gap: 8px; }
.gap-6         { gap: 12px; }
.gap-8         { gap: 16px; }

.mt-4  { margin-top: 8px; }
.mt-6  { margin-top: 12px; }
.mt-8  { margin-top: 16px; }
.mt-12 { margin-top: 24px; }
.mb-4  { margin-bottom: 8px; }
.mb-6  { margin-bottom: 12px; }
.mb-8  { margin-bottom: 16px; }

.divider {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 20px 0;
}

/* Ticket count dot */
.dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot--new      { background: var(--c-new-text); }
.dot--in_progress { background: var(--c-wip-text); }
.dot--standby  { background: var(--c-standby-text); }
.dot--resolved { background: var(--c-resolved-text); }
.dot--closed   { background: var(--c-closed-text); }
.dot--rejected { background: var(--c-rejected-text); }
