/* ============================================
   Tarkett Form — Mobile-first CSS
   ============================================ */

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

:root {
    --color-primary: #0078d4;
    --color-primary-dark: #005a9e;
    --color-bg: #f5f5f5;
    --color-card: #ffffff;
    --color-text: #242424;
    --color-muted: #616161;
    --color-border: #d1d1d1;
    --color-success: #107c10;
    --color-error: #c4314b;
    --color-jour: #d4a017;
    --color-soir: #5c6bc0;
    --color-nuit: #1a237e;
    --radius: 4px;
    --shadow: 0 2px 8px rgba(0,0,0,0.12);
    --transition: 0.15s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    background-image: url('../images/indoors-room.jpg');
    background-attachment: fixed;   
    background-repeat: no-repeat;
    background-size: cover;
}

/* ======= Header ======= */
.app-header {
    background: var(--color-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    max-width: 900px;
    margin: 0 auto;
    gap: 0.5rem;
}

.logo-img {
    height: 32px;
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ======= Buttons ======= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    line-height: 1.2;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}
.btn-primary:disabled {
    background: #a0a0a0;
    border-color: #a0a0a0;
    cursor: not-allowed;
}

/* Ghost button — used on coloured backgrounds (header) */
.btn-ghost {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.5);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.22);
}

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

.btn-full { width: 100%; display: flex; }
.btn-lg   { padding: 0.85rem 1.5rem; font-size: 1.05rem; }
.btn-sm   { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* ======= Alerts ======= */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
}
.alert-success {
    background: #dff6dd;
    color: var(--color-success);
    border-left: 4px solid var(--color-success);
}
.alert-error {
    background: #fde7e9;
    color: var(--color-error);
    border-left: 4px solid var(--color-error);
}

/* ======= Login ======= */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
    background-image: url('../images/indoors-room.jpg');
    background-attachment: fixed;   
    background-repeat: no-repeat;
    background-size: cover;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--color-card);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    padding: 2rem 1.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-header .logo-img {
    height: 48px;
    margin: 0 auto 1rem;
}

.login-header h1 {
    font-size: 1.4rem;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}
.login-header p {
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* ======= Form group (login fields) ======= */
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--color-text);
}

/* ======= Unified field input ======= */
/* Covers text inputs, password inputs, selects and textareas */
.field {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--color-text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}
.field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0,120,212,0.15);
}
textarea.field {
    resize: vertical;
    min-height: 100px;
}

/* ======= Hint / helper text ======= */
.hint {
    font-size: 0.82rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}
/* Character counters share .hint but are right-aligned with no bottom margin */
#problem-count,
#correction-count {
    text-align: right;
    margin-top: 0.25rem;
    margin-bottom: 0;
}

/* ======= Main content ======= */
.main-content {
    padding: 1rem;
    min-height: calc(100vh - 56px);
}

/* ======= Form card ======= */
.form-container {
    padding: 0px calc(50% - 595px);
    margin: 0 auto;
}

.form-card {
    background: var(--color-card);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.form-header {
    background: var(--color-primary);
    color: #fff;
    padding: 1.5rem 1.25rem;
}
.form-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.form-header p {
    font-size: 0.88rem;
    opacity: 0.85;
}

.required-star {
    color: #ff6b6b;
    font-weight: 700;
}

/* ======= Question blocks ======= */
.question-block {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    border-bottom: 1px solid #efefef;
}
.question-block:last-of-type {
    border-bottom: none;
}

.question-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 0.1rem;
}

.question-content {
    flex: 1;
    min-width: 0;
}

.question-label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

/* ======= Radio options ======= */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.radio-group-inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition), background var(--transition);
    user-select: none;
}
.radio-option:hover,
.radio-option:has(input:checked) {
    border-color: var(--color-primary);
    background: #f0f6ff;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    flex-shrink: 0;
    transition: border-color var(--transition);
}
.radio-option input[type="radio"]:checked ~ .radio-custom {
    border-color: var(--color-primary);
    background: var(--color-primary);
    box-shadow: inset 0 0 0 3px #fff;
}

.radio-label {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ======= Field errors ======= */
.field-error {
    display: none;
    color: var(--color-error);
    font-size: 0.83rem;
    margin-top: 0.4rem;
    font-weight: 500;
}

/* ======= Upload area ======= */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: #fafafa;
}
.upload-area:hover,
.upload-area:active {
    border-color: var(--color-primary);
    background: #f0f6ff;
}
/* Icon wrapper */
.upload-area > div {
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}
/* Primary text */
.upload-area > p:first-of-type {
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}
/* Secondary hint text */
.upload-area > p:last-of-type {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.image-preview {
    margin-top: 0.75rem;
    text-align: center;
}
.image-preview img {
    max-width: 100%;
    max-height: 280px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    display: block;
    margin: 0 auto 0.5rem;
}
.btn-remove-img {
    background: none;
    border: 1px solid var(--color-error);
    color: var(--color-error);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ======= Form footer ======= */
.form-footer {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid #efefef;
    background: #fafafa;
}

/* ======= Admin ======= */
.admin-container {
    max-width: 1100px;
    margin: 0 auto;
}

.admin-header {
    margin-bottom: 1.5rem;
}
.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.stats-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}
.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-number-accent {
    color: var(--color-success);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--color-muted);
    text-align: center;
}

.admin-section {
    background: var(--color-card);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #efefef;
    background: #f9f9f9;
}
.section-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
}

.admin-section > .btn {
    margin: 1.25rem;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--color-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 700;
    min-width: 24px;
}

/* ======= Table ======= */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 600px;
}
.data-table th,
.data-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid #efefef;
}
.data-table th {
    background: #f3f3f3;
    font-weight: 700;
    color: var(--color-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.data-table tr:hover td {
    background: #f7f7ff;
}

.nowrap       { white-space: nowrap; }
.text-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ======= Inline badges ======= */
/* Shared pill base */
.badge-dept,
.badge-quart {
    display: inline-block;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

.badge-dept { background: #e3f2fd; color: #1565c0; font-weight: 600; }

.badge-shift { color: #fff; font-weight: 700; }
.badge-shift-day    { background: var(--color-jour); }
.badge-shift-evening    { background: var(--color-soir); }
.badge-shift-night    { background: var(--color-nuit); }
.badge-shift-unknown { background: #9e9e9e; }

.badge-role {
    display: inline-block;
    border-radius: var(--radius);
    padding: 0.1rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
}
.badge-role-admin { background: #fde7e9; color: #c4314b; }
.badge-role-user  { background: #e3f2fd; color: #1565c0; }

.has-image { font-size: 1.2rem; }

/* ======= Photo button in the table ======= */
.td-photo { text-align: center; }

.btn-photo {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius);
    transition: background var(--transition), transform var(--transition);
    line-height: 1;
}
.btn-photo:hover {
    background: #e3f2fd;
    transform: scale(1.15);
}

.no-photo { color: var(--color-muted); }

/* ======= Modal photo ======= */
.photo-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.photo-modal.active {
    display: flex;
}
.photo-modal-inner {
    position: relative;
    background: #fff;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-modal-inner img {
    display: block;
    max-width: 85vw;
    max-height: 85vh;
    object-fit: contain;
}
.photo-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.6rem;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    z-index: 1;
}
.photo-modal-close:hover { background: rgba(0,0,0,0.8); }

/* ======= Create user form ======= */
.create-user-form {
    padding: 1.25rem;
    border-top: 1px solid #efefef;
    background: #fafafa;
}
.create-user-form h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}

.inline-form-fields {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.inline-form-fields .field {
    flex: 1;
    min-width: 120px;
}

/* ======= Responsive ======= */
@media (max-width: 480px) {
    .header-inner      { flex-wrap: wrap; }
    .user-label        { display: none; }
    .form-header h1    { font-size: 1.1rem; }

    .question-block {
        padding: 1rem 0.85rem;
        gap: 0.75rem;
    }

    .radio-group-inline            { flex-direction: column; }
    .radio-group-inline .radio-option { width: 100%; }

    .text-truncate { max-width: 130px; }
}

@media (min-width: 600px) {
    .form-footer { flex-direction: row; justify-content: flex-end; }
    .btn-full    { width: auto; }
}

/* ======= SST intro block ======= */
.form-intro {
    background: #e8f4fd;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.form-intro p {
    color: var(--color-text);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.form-intro ul {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.form-intro ul li {
    color: var(--color-text);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 0.35rem;
}

.form-intro-footer {
    font-size: 0.8rem;
    color: var(--color-muted);
    font-style: italic;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* --- Auto-login token UI --- */
.token-url-wrap {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.token-url-field {
    flex: 1;
    min-width: 0;
    font-family: monospace;
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
}

.token-url-field:focus {
    outline: 2px solid var(--color-primary);
}

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