/* =====================================================================
   MaintenancePro - Feuille de style principale
   ===================================================================== */

:root {
    --ink:        #1c2531;
    --ink-soft:   #5a6678;
    --bg:         #eef1f5;
    --card:       #ffffff;
    --border:     #dde3ea;

    --accent:       #007bff;
    --accent-dark:  #0056cc;
    --accent-soft:  #e7f0ff;

    --pending:      #f0a020;
    --pending-bg:   #fef3e0;
    --progress:     #2f6fed;
    --progress-bg:  #e7eefd;
    --done:         #1f9d55;
    --done-bg:      #e6f6ec;

    --danger:       #d6483f;
    --danger-bg:    #fbe7e5;

    --radius:     10px;
    --radius-lg:  14px;
    --shadow:     0 1px 3px rgba(28, 37, 49, 0.06), 0 1px 2px rgba(28, 37, 49, 0.08);
    --shadow-lg:  0 8px 24px rgba(28, 37, 49, 0.08);

    --font-display: 'Space Grotesk', sans-serif;
    --font-body:    'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:    'Space Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

/* ---------------------------------------------------------------------
   Mode sombre — active via html[data-theme="dark"]
--------------------------------------------------------------------- */
html[data-theme="dark"] {
    --ink:        #eef1f5;
    --ink-soft:   #a3adbd;
    --bg:         #14181f;
    --card:       #1c222c;
    --border:     #2b323f;

    --accent-soft: #16283f;
    --pending-bg:  #3a2c10;
    --progress-bg: #17223f;
    --done-bg:     #123322;
    --danger-bg:   #3a1917;

    --shadow:     0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .status-select,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: var(--card);
    color: var(--ink);
}

html[data-theme="dark"] table tbody tr:hover {
    background: #232a36;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------------
   Topbar
--------------------------------------------------------------------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    width: 100%;
    margin: 0 auto;
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 1px;
    transform: rotate(-4deg);
}

.brand-accent { color: var(--accent); }

.topnav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.topnav a:not(.btn) {
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 15px;
    padding: 6px 4px;
    border-bottom: 2px solid transparent;
}

.topnav a:not(.btn):hover,
.topnav a:not(.btn).active {
    color: var(--ink);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

/* ---------------------------------------------------------------------
   Layout
--------------------------------------------------------------------- */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 28px 32px 60px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.page-head h1 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.footer {
    width: 100%;
    margin: 0 auto;
    padding: 20px 32px;
    color: var(--ink-soft);
    font-size: 13px;
    text-align: center;
}

/* ---------------------------------------------------------------------
   Alerts
--------------------------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.alert-success {
    background: var(--done-bg);
    color: #156a3a;
    border: 1px solid #c7ebd5;
}

/* ---------------------------------------------------------------------
   Search bar
--------------------------------------------------------------------- */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-bar input[type="text"] {
    flex: 1;
    min-width: 220px;
}

/* ---------------------------------------------------------------------
   Card
--------------------------------------------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}

/* ---------------------------------------------------------------------
   Table
--------------------------------------------------------------------- */
.table-wrapper {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 980px;
}

thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    font-weight: 600;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #fafbfc; }

tbody tr.row-en_attente td:first-child { border-left: 3px solid var(--pending); }
tbody tr.row-en_cours td:first-child   { border-left: 3px solid var(--progress); }
tbody tr.row-termine td:first-child    { border-left: 3px solid var(--done); }

td.empty {
    text-align: center;
    color: var(--ink-soft);
    padding: 40px 14px;
}

td:first-child {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--ink-soft);
}

td.actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* ---------------------------------------------------------------------
   Status select (colored by current status)
--------------------------------------------------------------------- */
.status-form { margin: 0; }

.status-select {
    border: none;
    border-radius: 999px;
    padding: 6px 12px 6px 28px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 10px 10px;
    width: 140px;
    min-width: 140px;
}

.status-select.status-pending {
    background-color: var(--pending-bg);
    color: #8a5a0a;
    background-image: radial-gradient(circle, var(--pending) 45%, transparent 46%);
}
.status-select.status-progress {
    background-color: var(--progress-bg);
    color: #1e4ea8;
    background-image: radial-gradient(circle, var(--progress) 45%, transparent 46%);
}
.status-select.status-done {
    background-color: var(--done-bg);
    color: #156a3a;
    background-image: radial-gradient(circle, var(--done) 45%, transparent 46%);
}

/* Static badge (used on receipt) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
}
.badge.status-pending  { background: var(--pending-bg);  color: #8a5a0a; }
.badge.status-progress { background: var(--progress-bg); color: #1e4ea8; }
.badge.status-done     { background: var(--done-bg);     color: #156a3a; }

/* ---------------------------------------------------------------------
   Forms
--------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

input, select, textarea {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

textarea { resize: vertical; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.35);
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
    background: var(--ink);
    color: #fff;
}
.btn-secondary:hover { background: #11161f; }

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--border);
}
.btn-ghost:hover { background: #f3f5f8; color: var(--ink); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #f6cfcb;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* ---------------------------------------------------------------------
   Info table (used on the client tracking page)
--------------------------------------------------------------------- */
.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.info-table th, .info-table td {
    text-align: left;
    padding: 9px 4px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.info-table th {
    width: 160px;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 13px;
}
.info-table tr:last-child th,
.info-table tr:last-child td {
    border-bottom: none;
}

/* ---------------------------------------------------------------------
   Modal (confirmation dialogs)
--------------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 37, 49, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.open {
    display: flex;
}
.modal-box {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    max-width: 380px;
    width: 100%;
}
.modal-box h3 {
    font-family: var(--font-display);
    font-size: 18px;
    margin: 0 0 8px;
}
.modal-box p {
    color: var(--ink-soft);
    font-size: 14px;
    margin: 0 0 20px;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------- */
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 22px; }
}

/* =====================================================================
   Auth / Login page
===================================================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    transform: rotate(-4deg);
    margin-bottom: 12px;
}

.auth-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--ink-soft);
    margin: 0 0 24px;
    line-height: 1.5;
}

.auth-link {
    display: block;
    margin-top: 20px;
    font-size: 13px;
    color: var(--ink-soft);
}
.auth-link:hover { color: var(--ink); }

/* User selection grid */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.user-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.user-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,123,255,.12);
    text-decoration: none;
    color: var(--ink);
}

/* Avatars */
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 13px;
}

/* PIN dots */
.pin-dots {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 4px 0 20px;
}
.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    transition: background 0.1s, border-color 0.1s;
}
.pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
}

/* PIN keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 0 auto;
    max-width: 280px;
}
.keypad button {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    padding: 18px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    width: 100%;
}
.keypad button:hover  { background: var(--accent-soft); border-color: var(--accent); }
.keypad button:active { background: var(--accent); color: #fff; }
.keypad .key-empty    { background: transparent; border-color: transparent; cursor: default; }
.keypad .key-empty:hover { background: transparent; border-color: transparent; }
.keypad .key-delete   { font-size: 13px; font-weight: 600; color: var(--ink-soft); }

/* Topbar user session area */
.user-session {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
    margin-left: 4px;
}
.session-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

/* =====================================================================
   Statistics Dashboard
===================================================================== */
.stats-section { margin-bottom: 8px; }

/* Revenue cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}
.stat-card {
    border-radius: var(--radius);
    padding: 20px 18px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    right: -16px; top: -16px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,.10);
}
.stat-blue   { background: linear-gradient(135deg, #007bff 0%, #0056cc 100%); }
.stat-indigo { background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%); }
.stat-violet { background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%); }
.stat-dark   { background: linear-gradient(135deg, #1c2531 0%, #374151 100%); }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    opacity: .80;
    margin-bottom: 8px;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
}
.stat-currency { font-size: 14px; font-weight: 500; opacity: .80; }
.stat-sub { font-size: 12px; opacity: .65; }

/* Status mini cards */
.status-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}
.sstат {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}
.sstat-icon { font-size: 26px; line-height: 1; flex-shrink: 0; }
.sstat-num  {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}
.sstat-lbl  { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }

.sstат-all  { border-left: 3px solid #6b7280; }
.sstат-wait { border-left: 3px solid var(--pending); }
.sstат-prog { border-left: 3px solid var(--progress); }
.sstат-done { border-left: 3px solid var(--done); }

.sstат-wait .sstat-num { color: var(--pending); }
.sstат-prog .sstat-num { color: var(--progress); }
.sstат-done .sstat-num { color: var(--done); }

/* Bar chart */
.chart-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 20px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 0;
}
.chart-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 16px;
}
.chart-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 120px;
}
.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    gap: 4px;
}
.chart-val {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-soft);
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
}
.chart-bar-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.chart-bar {
    width: 70%;
    background: linear-gradient(180deg, #007bff 0%, #0056cc 100%);
    border-radius: 4px 4px 0 0;
    transition: height .4s ease;
    min-height: 3px;
}
.chart-month {
    font-size: 11px;
    color: var(--ink-soft);
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .stats-grid, .status-stats { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 540px) {
    .stats-grid, .status-stats { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 20px; }
}

/* Non réparé - red status */
:root {
    --failed:    #d6483f;
    --failed-bg: #fbe7e5;
}
.status-select.status-failed {
    background-color: var(--failed-bg);
    color: #8b1a14;
    background-image: radial-gradient(circle, var(--failed) 45%, transparent 46%);
}
.badge.status-failed { background: var(--failed-bg); color: #8b1a14; }
tbody tr.row-non_repare td:first-child { border-left: 3px solid var(--failed); }
