/* ===================================================================
   Support Platform — Thème professionnel sobre (inspiré WHMCS)
   =================================================================== */

:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-border: #dde3ea;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-primary: #1c3f6e;
    --color-primary-dark: #142c4d;
    --color-primary-light: #e8eef7;
    --color-success: #1d7a4c;
    --color-success-bg: #e6f4ec;
    --color-error: #b3261e;
    --color-error-bg: #fbeceb;
    --color-warning: #9a6700;
    --color-warning-bg: #fdf1d6;
    --radius: 6px;
    --sidebar-width: 240px;
    font-size: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

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

/* --- Layout ------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-content { padding: 24px 32px; max-width: 1200px; }

/* --- Sidebar -------------------------------------------------------- */

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary-dark);
    color: #dbe4f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-weight: 600;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark {
    width: 28px; height: 28px;
    background: #ffffff;
    color: var(--color-primary-dark);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
    display: block;
    padding: 9px 18px;
    color: #c9d6e8;
    font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }

.nav-section-title {
    padding: 16px 18px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #7f93b0;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--color-primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}

.user-name { font-size: 13px; color: #fff; }
.user-role { font-size: 11px; color: #92a5c2; text-transform: capitalize; }

.link-button {
    background: none; border: none; color: #92a5c2; cursor: pointer;
    font-size: 12.5px; padding: 0;
}
.link-button:hover { color: #fff; text-decoration: underline; }

/* --- Topbar --------------------------------------------------------- */

.topbar {
    height: 60px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px;
}

.page-title { font-size: 18px; font-weight: 600; margin: 0; }

.icon-button {
    background: none; border: none; cursor: pointer; font-size: 18px;
    position: relative; padding: 6px;
}

.notif-count {
    position: absolute; top: 0; right: 0;
    background: var(--color-error); color: #fff;
    border-radius: 10px; font-size: 10px; padding: 1px 5px;
}

.notif-bell { position: relative; }

.notif-dropdown {
    position: absolute; right: 0; top: 36px;
    width: 300px; background: #fff; border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 20;
}

.notif-dropdown-header { padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--color-border); }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-empty { padding: 16px; color: var(--color-text-muted); font-size: 13px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--color-border); font-size: 12.5px; }
.notif-item-title { font-weight: 600; }
.notif-item-meta { color: var(--color-text-muted); font-size: 11px; margin-top: 2px; }

/* --- Panels / cards --------------------------------------------------- */

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.panel-narrow { max-width: 560px; }

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.panel-header h2 { font-size: 15px; margin: 0; font-weight: 600; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-card-alert { border-left: 3px solid var(--color-error); }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* --- Tables ----------------------------------------------------------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    text-align: left; padding: 8px 10px; color: var(--color-text-muted);
    font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--color-border);
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--color-border); }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--color-primary-light); }
.empty-row { text-align: center; color: var(--color-text-muted); padding: 24px; }

/* --- Badges ------------------------------------------------------------ */

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 600; background: #eef1f5; color: #475467;
}
.badge-priority-low { background: #eef1f5; color: #475467; }
.badge-priority-normal { background: var(--color-primary-light); color: var(--color-primary); }
.badge-priority-high { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-priority-urgent { background: var(--color-error-bg); color: var(--color-error); }

.badge-status-open { background: var(--color-primary-light); color: var(--color-primary); }
.badge-status-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-status-answered { background: #e5eefc; color: #2255a4; }
.badge-status-resolved { background: var(--color-success-bg); color: var(--color-success); }
.badge-status-closed { background: #eef1f5; color: #475467; }
.badge-internal { background: var(--color-warning-bg); color: var(--color-warning); }

/* --- Forms -------------------------------------------------------------- */

label { display: block; font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 12px; }

input[type=text], input[type=email], input[type=password], input[type=file],
select, textarea {
    display: block; width: 100%; margin-top: 5px;
    padding: 8px 10px; font-size: 13.5px; color: var(--color-text);
    border: 1px solid var(--color-border); border-radius: var(--radius);
    font-family: inherit; background: #fff;
}
textarea { resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stacked-form { display: flex; flex-direction: column; }
.inline-form { display: inline-block; }
.inline-form-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.checkbox-inline input { width: auto; margin: 0; }

.filters-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters-bar select, .filters-bar input { width: auto; margin: 0; }

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-block; padding: 8px 16px; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary { background: #fff; border-color: var(--color-border); color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; text-align: center; }

/* --- Flashes -------------------------------------------------------------- */

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; }
.flash-success { background: var(--color-success-bg); color: var(--color-success); }
.flash-error { background: var(--color-error-bg); color: var(--color-error); }

/* --- Auth pages -------------------------------------------------------------- */

.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--color-bg); margin: 0;
}
.auth-card {
    background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
    padding: 32px; width: 380px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 700; font-size: 16px; }
.auth-form label { margin-bottom: 14px; }
.auth-footer { text-align: center; font-size: 12.5px; margin-top: 16px; color: var(--color-text-muted); }

/* --- Ticket conversation -------------------------------------------------------------- */

.ticket-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
.ticket-panel { min-width: 0; }
.ticket-sidebar .panel { padding: 14px; }
.ticket-sidebar h3 { font-size: 12.5px; margin: 0 0 8px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }

.badges-row { display: flex; gap: 6px; }
.ticket-meta { font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 18px; }

.conversation { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.message {
    border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 14px;
    background: #fbfcfd;
}
.message-internal { background: var(--color-warning-bg); border-color: #f0d8a0; }
.message-header { display: flex; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.message-author { font-weight: 600; }
.message-date { color: var(--color-text-muted); margin-left: auto; }
.message-body { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.message-signature { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--color-border); font-size: 12px; color: var(--color-text-muted); white-space: pre-wrap; }

.reply-form textarea { margin-bottom: 10px; }
.reply-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.attachments-block { margin-bottom: 18px; }
.attachments-block h3 { font-size: 12.5px; color: var(--color-text-muted); text-transform: uppercase; }
.attachments-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.attachments-list li { padding: 4px 0; }

.permissions-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 16px; margin: 12px 0 16px;
}

.muted { color: var(--color-text-muted); }

.error-page { text-align: center; padding: 80px 20px; font-family: sans-serif; }
.error-page h1 { font-size: 48px; margin-bottom: 8px; color: var(--color-primary); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .app-content { padding: 16px; }
    .ticket-layout { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
