/* ============================================================
   FlowMind Smart Factory — CSS principal
   Fichier : assets/css/app.css
   Design : tablette industrielle, gros boutons, lisible
   ============================================================ */

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

:root {
    --green:       #16a34a;
    --green-light: #dcfce7;
    --green-dark:  #14532d;
    --blue:        #2563eb;
    --blue-light:  #dbeafe;
    --orange:      #ea580c;
    --orange-light:#ffedd5;
    --red:         #dc2626;
    --red-light:   #fee2e2;
    --purple:      #7c3aed;
    --purple-light:#ede9fe;
    --teal:        #0d9488;
    --teal-light:  #ccfbf1;
    --gray:        #6b7280;
    --gray-light:  #f3f4f6;
    --gray-border: #e5e7eb;
    --text:        #111827;
    --text-muted:  #6b7280;
    --white:       #ffffff;
    --bg:          #f9fafb;
    --navbar-h:    60px;
    --radius:      8px;
    --radius-lg:   12px;
    --shadow:      0 1px 3px rgba(0,0,0,.1);
    --shadow-md:   0 4px 12px rgba(0,0,0,.1);
}

html { font-size: 16px; }
body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* --- Navbar ------------------------------------------------- */
.navbar {
    position: sticky; top: 0; z-index: 100;
    height: var(--navbar-h);
    background: var(--text);
    display: flex; align-items: center;
    padding: 0 1.5rem; gap: 1rem;
    box-shadow: var(--shadow-md);
}

.navbar-brand { flex-shrink: 0; }
.brand-link { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand-logo {
    width: 36px; height: 36px; border-radius: var(--radius);
    background: var(--blue); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px;
}
.brand-name { color: white; font-weight: 600; font-size: 15px; }

.navbar-menu { flex: 1; display: flex; align-items: center; gap: .25rem; padding-left: 1rem; }

.nav-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.8); font-size: 14px;
    padding: .5rem .85rem; border-radius: var(--radius);
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.nav-btn:hover, .nav-btn.active {
    background: rgba(255,255,255,.15); color: white;
}
.navbar-menu a.nav-btn { display: block; }

/* Dropdown nav */
.nav-dropdown { position: relative; }
.nav-dropdown .dropdown-menu {
    display: none; position: absolute; top: calc(100% + 8px); left: 0;
    background: white; border: 1px solid var(--gray-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    min-width: 220px; z-index: 200; overflow: hidden;
}
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu { display: block; }

.dropdown-item {
    display: block; padding: .7rem 1rem; color: var(--text);
    font-size: 14px; transition: background .1s;
    text-decoration: none;
}
.dropdown-item:hover { background: var(--gray-light); text-decoration: none; }
.dropdown-item.dropdown-danger { color: var(--red); }
.dropdown-header {
    padding: .75rem 1rem; display: flex; flex-direction: column; gap: .15rem;
}
.dropdown-header strong { font-size: 14px; }
.dropdown-header small  { font-size: 12px; color: var(--text-muted); }
.dropdown-divider { border: none; border-top: 1px solid var(--gray-border); }
.dropdown-right { left: auto; right: 0; }

/* User nav */
.navbar-user { margin-left: auto; flex-shrink: 0; }
.nav-user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: rgba(255,255,255,.1); border: none; cursor: pointer;
    color: white; padding: .4rem .75rem; border-radius: 99px;
    font-size: 14px;
}
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--blue); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.user-name-short { display: none; }
@media(min-width: 768px) { .user-name-short { display: inline; } }

/* --- Flash messages ----------------------------------------- */
.flash {
    display: flex; align-items: center; justify-content: space-between;
    padding: .85rem 1.25rem; font-size: 14px; font-weight: 500;
}
.flash-success { background: var(--green-light); color: var(--green-dark); }
.flash-error   { background: var(--red-light);   color: var(--red); }
.flash-info    { background: var(--blue-light);   color: var(--blue); }
.flash-close   { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; }

/* --- Main content ------------------------------------------- */
.main-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* --- Page header -------------------------------------------- */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-title    { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: .25rem; }

/* --- Stats grid --------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: white; border-radius: var(--radius-lg);
    padding: 1.25rem; text-align: center;
    border-left: 4px solid transparent;
    box-shadow: var(--shadow);
}
.stat-card-green  { border-color: var(--green); }
.stat-card-orange { border-color: var(--orange); }
.stat-card-blue   { border-color: var(--blue); }
.stat-card-purple { border-color: var(--purple); }
.stat-icon   { font-size: 1.75rem; margin-bottom: .4rem; }
.stat-number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 13px; color: var(--text-muted); margin-top: .3rem; }

/* --- Quick actions ------------------------------------------ */
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .75rem; margin-bottom: 1.5rem;
}
.quick-card {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: .5rem;
    padding: 1.25rem .75rem; border-radius: var(--radius-lg);
    text-decoration: none; color: var(--text);
    border: 2px solid transparent;
    transition: transform .15s, box-shadow .15s;
    cursor: pointer; min-height: 100px;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.quick-card-green  { background: var(--green-light);  border-color: var(--green); }
.quick-card-teal   { background: var(--teal-light);   border-color: var(--teal); }
.quick-card-orange { background: var(--orange-light); border-color: var(--orange); }
.quick-card-red    { background: var(--red-light);    border-color: var(--red); }
.quick-card-blue   { background: var(--blue-light);   border-color: var(--blue); }
.quick-card-gray   { background: var(--gray-light);   border-color: var(--gray); }
.quick-icon  { font-size: 1.75rem; }
.quick-label { font-size: 13px; font-weight: 500; text-align: center; }

/* --- Cards -------------------------------------------------- */
.card {
    background: white; border-radius: var(--radius-lg);
    border: 1px solid var(--gray-border); box-shadow: var(--shadow);
    overflow: hidden; margin-bottom: 1.25rem;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-border);
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-link  { font-size: 13px; color: var(--blue); }
.card-body  { padding: 1.25rem; }

.dashboard-tables { display: grid; gap: 1.25rem; }
@media(min-width: 1024px) {
    .dashboard-tables { grid-template-columns: 1fr 1fr; }
}

/* --- Tables ------------------------------------------------- */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; padding: .75rem 1rem;
    border-bottom: 2px solid var(--gray-border);
    font-weight: 600; color: var(--text-muted);
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
    white-space: nowrap;
}
.table td {
    padding: .75rem 1rem; border-bottom: 1px solid var(--gray-border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td     { background: var(--gray-light); }
.table .truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Buttons ------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1.1rem; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1.5px solid transparent; transition: all .15s;
    text-decoration: none; white-space: nowrap; line-height: 1.4;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--blue);   color: white; border-color: var(--blue); }
.btn-success   { background: var(--green);  color: white; border-color: var(--green); }
.btn-danger    { background: var(--red);    color: white; border-color: var(--red); }
.btn-warning   { background: var(--orange); color: white; border-color: var(--orange); }
.btn-outline   { background: white; color: var(--text); border-color: var(--gray-border); }
.btn-outline:hover { background: var(--gray-light); }
.btn-secondary { background: var(--gray-light); color: var(--text); border-color: var(--gray-border); }

.btn-sm  { padding: .35rem .75rem; font-size: 13px; }
.btn-lg  { padding: .75rem 1.5rem; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }
.btn-xl  { padding: 1rem 2rem; font-size: 18px; border-radius: var(--radius-lg); }

/* --- Forms -------------------------------------------------- */
.form-group { margin-bottom: 1.1rem; }
.form-label {
    display: block; font-size: 14px; font-weight: 500;
    margin-bottom: .4rem; color: var(--text);
}
.form-label .required { color: var(--red); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: .65rem .9rem;
    border: 1.5px solid var(--gray-border); border-radius: var(--radius);
    font-size: 15px; color: var(--text); background: white;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: .35rem; }
.form-error { font-size: 12px; color: var(--red); margin-top: .35rem; }

/* Scan input (gros, usine) */
.scan-input {
    font-size: 1.25rem; padding: 1rem 1.25rem;
    border-width: 2px; border-radius: var(--radius-lg);
    letter-spacing: .05em;
}
.scan-input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(22,163,74,.15); }

.form-row { display: grid; gap: 1rem; }
@media(min-width: 640px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } }
@media(min-width: 640px) { .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* --- Badges ------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center;
    padding: .2rem .6rem; border-radius: 99px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-success   { background: var(--green-light);  color: var(--green-dark); }
.badge-warning   { background: var(--orange-light); color: #7c2d12; }
.badge-danger    { background: var(--red-light);    color: var(--red); }
.badge-danger-dark { background: var(--red);        color: white; }
.badge-info      { background: var(--blue-light);   color: var(--blue); }
.badge-primary   { background: var(--purple-light); color: var(--purple); }
.badge-secondary { background: var(--gray-light);   color: var(--gray); }

/* --- Alerts ------------------------------------------------- */
.alert {
    padding: .85rem 1rem; border-radius: var(--radius);
    font-size: 14px; margin-bottom: 1rem; border-left: 4px solid;
}
.alert-success { background: var(--green-light);  border-color: var(--green); color: var(--green-dark); }
.alert-danger  { background: var(--red-light);    border-color: var(--red);   color: var(--red); }
.alert-info    { background: var(--blue-light);   border-color: var(--blue);  color: var(--blue); }
.alert-warning { background: var(--orange-light); border-color: var(--orange);color: #7c2d12; }

/* --- Login page --------------------------------------------- */
.login-card {
    background: white; border-radius: var(--radius-lg);
    padding: 2rem; width: 100%; max-width: 440px;
    box-shadow: var(--shadow-md); margin: 1rem;
}
.login-header { text-align: center; margin-bottom: 1.75rem; }
.login-logo {
    width: 56px; height: 56px; border-radius: var(--radius-lg);
    background: var(--blue); color: white; font-size: 20px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; margin: 0 auto .85rem;
}
.login-title    { font-size: 1.35rem; font-weight: 700; }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-top: .25rem; }
.login-form     { display: flex; flex-direction: column; gap: 0; }

.demo-accounts {
    margin-top: 1.5rem; padding-top: 1.25rem;
    border-top: 1px solid var(--gray-border);
}
.demo-title    { font-size: 13px; color: var(--text-muted); margin-bottom: .75rem; }
.demo-grid     { display: flex; flex-direction: column; gap: .4rem; }
.demo-btn {
    display: flex; align-items: center; gap: .6rem;
    background: var(--gray-light); border: 1px solid var(--gray-border);
    padding: .55rem .85rem; border-radius: var(--radius);
    font-size: 13px; cursor: pointer; text-align: left;
    transition: background .1s;
}
.demo-btn:hover { background: #e5e7eb; }
.demo-role {
    padding: .15rem .5rem; border-radius: 4px;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.demo-role.admin      { background: #7c3aed; color: white; }
.demo-role.supervisor { background: var(--blue); color: white; }
.demo-role.operator   { background: var(--green); color: white; }
.demo-password { font-size: 12px; color: var(--text-muted); margin-top: .6rem; }

/* --- Footer ------------------------------------------------- */
.app-footer {
    text-align: center; padding: 1rem;
    font-size: 12px; color: var(--text-muted);
    display: flex; gap: .5rem; justify-content: center;
    border-top: 1px solid var(--gray-border); margin-top: 2rem;
}

/* --- Utilities ---------------------------------------------- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 13px; }
.text-danger  { color: var(--red); }
.text-success { color: var(--green); }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-1        { gap: .5rem; }
.gap-2        { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.p-0  { padding: 0; }

code {
    background: var(--gray-light); padding: .15rem .4rem;
    border-radius: 4px; font-size: 13px; font-family: monospace;
}

/* --- Responsive tablette ------------------------------------ */
@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .page-title   { font-size: 1.4rem; }
    .stats-grid   { grid-template-columns: repeat(2, 1fr); }
    .brand-name   { display: none; }
    .navbar-menu  { gap: 0; }
}
