/* ============================================================
   ZenTime - PWA Tablette - Style sombre
   ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

:root {
    --bg-deep:      #0a0e14;
    --bg-surface:   #131922;
    --bg-card:      #1c2433;
    --bg-elevated:  #25304a;
    --border:       rgba(255, 255, 255, 0.08);
    --border-soft:  rgba(255, 255, 255, 0.04);

    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary:  #64748b;

    --primary:        #3b82f6;
    --primary-dim:    #1e40af;
    --primary-glow:   rgba(59, 130, 246, 0.18);

    --success:        #22c55e;
    --success-bg:     rgba(34, 197, 94, 0.12);
    --warning:        #f59e0b;
    --warning-bg:     rgba(245, 158, 11, 0.12);
    --danger:         #ef4444;
    --danger-bg:      rgba(239, 68, 68, 0.12);

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 28px;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

#app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   BANDEAU HAUT
   ============================================================ */
.topbar {
    flex: 0 0 auto;
    height: 80px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dim) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.brand-logo svg {
    width: 32px;
    height: 32px;
    color: white;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-info {
    min-width: 0;
}

.brand-name {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.clock {
    font-size: 30px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--success-bg);
    color: var(--success);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.sync-status.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.sync-status.error {
    background: var(--danger-bg);
    color: var(--danger);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.sync-status.warning .sync-dot {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* ============================================================
   ÉCRANS (screens) — un seul affiché à la fois
   ============================================================ */
.screens {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    inset: 0;
    padding: 40px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* ============================================================
   ÉCRAN PAIRING (1er lancement)
   ============================================================ */
#screen-pairing .pairing-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
}

#screen-pairing h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 12px;
}

#screen-pairing .pairing-sub {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.pairing-code-input {
    font-size: 42px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 12px;
    padding: 20px 28px;
    text-align: center;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    width: 100%;
    outline: none;
    margin-bottom: 24px;
}

.pairing-code-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 18px 40px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 60px;
    min-width: 200px;
}

.btn-primary:hover:not(:disabled),
.btn-primary:active {
    background: var(--primary-dim);
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pairing-help {
    margin-top: 32px;
    font-size: 14px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

/* ============================================================
   ÉCRAN KEYPAD (saisie PIN 4 chiffres)
   ============================================================ */
#screen-keypad {
    padding: 32px;
}

.keypad-prompt {
    font-size: 24px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    text-align: center;
}

.pin-boxes {
    display: flex;
    gap: 16px;
    margin-bottom: 36px;
}

.pin-box {
    width: 64px;
    height: 80px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.pin-box.filled {
    border-color: var(--primary);
    background: var(--bg-elevated);
}

.pin-box-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.2s;
}

.pin-box.filled .pin-box-dot {
    opacity: 1;
    transform: scale(1);
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    gap: 18px;
    margin-bottom: 16px;
}

.key {
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 34px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    user-select: none;
}

.key:active {
    background: var(--bg-elevated);
    transform: scale(0.94);
    border-color: var(--primary);
}

.key.key-action {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-soft);
}

.key.key-action:active {
    color: var(--text-primary);
}

.key svg {
    width: 32px;
    height: 32px;
}

.key-error {
    color: var(--danger);
    font-size: 15px;
    height: 24px;
    margin-top: 4px;
    text-align: center;
    transition: opacity 0.2s;
    opacity: 0;
}

.key-error.show {
    opacity: 1;
}

/* ============================================================
   ÉCRAN CONFIRMATION (après pointage réussi)
   ============================================================ */
#screen-confirmation {
    background: var(--bg-deep);
}

.confirmation-content {
    text-align: center;
    animation: confirmation-in 0.35s ease-out;
}

@keyframes confirmation-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.confirmation-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 28px;
}

.confirmation-icon.out {
    background: var(--primary-glow);
    color: var(--primary);
}

.confirmation-icon svg {
    width: 64px;
    height: 64px;
}

.confirmation-hello {
    font-size: 28px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.confirmation-name {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 24px;
}

.confirmation-action {
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.confirmation-time {
    font-size: 22px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.confirmation-extra {
    margin-top: 28px;
    font-size: 16px;
    color: var(--text-tertiary);
}

/* ============================================================
   PROMPT ADMIN (long-press logo → ouvre /admin/)
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.modal-overlay.show {
    display: flex;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.modal-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.modal-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-secondary {
    flex: 1;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary:active {
    background: var(--bg-elevated);
}

.modal-buttons .btn-primary {
    flex: 1;
    min-width: 0;
    padding: 14px;
    font-size: 16px;
}

/* ============================================================
   ADAPTATIONS ÉCRANS
   ============================================================ */
@media (max-height: 720px) {
    .topbar { height: 64px; padding: 0 24px; }
    .clock { font-size: 24px; }
    .brand-name { font-size: 18px; }
    .keypad { grid-template-columns: repeat(3, 88px); gap: 14px; }
    .key { font-size: 30px; }
    .pin-box { width: 56px; height: 72px; }
    .keypad-prompt { font-size: 20px; margin-bottom: 20px; }
}

@media (orientation: landscape) and (min-width: 900px) {
    /* Mode paysage : keypad à droite, infos à gauche */
    .keypad-prompt { font-size: 28px; }
    .keypad { grid-template-columns: repeat(3, 110px); gap: 22px; }
    .key { font-size: 38px; }
    .pin-box { width: 72px; height: 88px; }
}

@media (max-width: 500px) {
    .topbar { padding: 0 16px; gap: 12px; height: 64px; }
    .brand-logo { width: 44px; height: 44px; }
    .brand-name { font-size: 16px; }
    .clock { font-size: 22px; }
    .sync-status { padding: 6px 10px; font-size: 12px; }
    .sync-status .sync-label { display: none; }
    .keypad { grid-template-columns: repeat(3, 80px); gap: 12px; }
    .key { font-size: 28px; }
}
