/* ============================================================
   QUALITY CONTROL PLATFORM - STYLESHEET
   ============================================================ */

/* === VARIABLES === */
:root {
    --primary: #0f766e;
    --primary-light: #14b8a6;
    --primary-dark: #0d5f59;
    --secondary: #f59e0b;
    --secondary-light: #fbbf24;
    --danger: #dc2626;
    --danger-light: #fecaca;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #2563eb;
    --info-light: #dbeafe;
    --bg-body: #f0f4f8;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-sidebar: #cbd5e1;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* === LAYOUT === */
.app-wrapper { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition);
}
.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}
.sidebar-header small {
    font-size: 0.75rem;
    color: var(--text-light);
    display: block;
    margin-top: 2px;
}
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--text-sidebar);
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-sidebar-hover);
    color: #fff;
    border-left-color: var(--primary-light);
}
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 1.1rem; }
.sidebar-nav .nav-section {
    padding: 16px 24px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-light);
    font-weight: 600;
}
.sidebar-user {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.2);
}
.sidebar-user .user-name { font-weight: 600; color: #fff; font-size: 0.85rem; }
.sidebar-user .user-role {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--primary-light);
    letter-spacing: 0.5px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    min-height: 100vh;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }

/* === CARDS === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

/* === STAT CARDS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.primary { background: rgba(15,118,110,0.1); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-light); color: var(--danger); }
.stat-icon.info    { background: var(--info-light); color: var(--info); }
.stat-info h4 { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-info p { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* === TABLES === */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
table thead th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
    vertical-align: middle;
}
table tbody tr:hover { background: #f8fafc; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: #f8fafc; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-group { display: flex; gap: 6px; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: #fff;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,118,110,0.1);
}
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-primary { background: rgba(15,118,110,0.1); color: var(--primary); }

/* === MODALS === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}
@keyframes modalSlide {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* === AUDIO PLAYER === */
.audio-player {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.audio-player audio { width: 100%; }
.audio-player .audio-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* === PROGRESS BAR === */
.progress-bar {
    background: #e2e8f0;
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.6s ease;
}
.progress-bar .fill.green { background: var(--success); }
.progress-bar .fill.yellow { background: var(--warning); }
.progress-bar .fill.red { background: var(--danger); }

/* === NOTE DISPLAY === */
.note-display {
    font-size: 1.6rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.note-display.excellent { color: var(--success); }
.note-display.good { color: var(--primary); }
.note-display.warning { color: var(--warning); }
.note-display.danger { color: var(--danger); }

/* === LOGIN PAGE === */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--primary);
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 28px;
}
.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    margin-top: 8px;
}

/* === GRILLE AUDIT === */
.grille-question {
    padding: 14px 0;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.grille-question:last-child { border-bottom: none; }
.grille-question .q-text { flex: 1; font-size: 0.9rem; }
.grille-question .q-poids {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
}
.grille-question .q-response { min-width: 160px; }
.toggle-group { display: flex; gap: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.toggle-group label {
    padding: 6px 16px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    background: #fff;
    transition: var(--transition);
}
.toggle-group input { display: none; }
.toggle-group input:checked + label.oui { background: var(--success); color: #fff; }
.toggle-group input:checked + label.non { background: var(--danger); color: #fff; }

/* === CHARTS === */
.chart-container { position: relative; height: 300px; padding: 10px; }

/* === ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; padding: 20px; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 260px; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* === UTILITY === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }
