/**
 * CIVISTROM ID — Styles principaux
 *
 * Variables, reset, splash, PIN, comptes, codes live, timer, FAB.
 */

/* ═══════════════════════════════════════════
   Variables CSS
   ═══════════════════════════════════════════ */

:root {
    --id-primary: #6366F1;
    --id-primary-light: #818CF8;
    --id-primary-dark: #4F46E5;
    --id-primary-glow: rgba(99, 102, 241, 0.3);
    --id-primary-10: rgba(99, 102, 241, 0.1);
    --id-primary-20: rgba(99, 102, 241, 0.2);

    --id-bg: #0a0a0f;
    --id-bg-card: rgba(255, 255, 255, 0.05);
    --id-bg-card-hover: rgba(255, 255, 255, 0.08);
    --id-bg-input: rgba(255, 255, 255, 0.08);
    --id-bg-overlay: rgba(0, 0, 0, 0.6);

    --id-text: #e2e8f0;
    --id-text-muted: #94a3b8;
    --id-text-dim: #64748b;

    --id-border: rgba(255, 255, 255, 0.1);
    --id-border-focus: rgba(99, 102, 241, 0.5);

    --id-success: #22C55E;
    --id-error: #EF4444;
    --id-warning: #F59E0B;

    --id-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --id-font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

    --id-radius: 12px;
    --id-radius-sm: 8px;
    --id-radius-lg: 16px;
    --id-radius-xl: 20px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ═══════════════════════════════════════════
   Reset
   ═══════════════════════════════════════════ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--id-font);
    background: var(--id-bg);
    color: var(--id-text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

/* ═══════════════════════════════════════════
   App container
   ═══════════════════════════════════════════ */

.app {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    position: relative;
}

/* ═══════════════════════════════════════════
   Screens (show/hide)
   ═══════════════════════════════════════════ */

.screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem 1.5rem;
}

.screen--center {
    align-items: center;
    justify-content: center;
}

.screen[hidden] {
    display: none !important;
}

/* ═══════════════════════════════════════════
   Splash / Loading
   ═══════════════════════════════════════════ */

.splash {
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.splash-logo {
    margin-bottom: 1.5rem;
}

.splash-logo svg {
    filter: drop-shadow(0 0 20px var(--id-primary-glow));
}

.splash-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--id-text);
}

.splash-subtitle {
    font-size: 0.875rem;
    color: var(--id-text-muted);
    margin-top: 0.25rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════
   Header
   ═══════════════════════════════════════════ */

.header {
    text-align: center;
    padding: 2rem 0 1.5rem;
}

.header-icon {
    margin-bottom: 1rem;
}

.header-icon svg {
    filter: drop-shadow(0 0 12px var(--id-primary-glow));
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-subtitle {
    font-size: 0.875rem;
    color: var(--id-text-muted);
    margin-top: 0.25rem;
}

/* ═══════════════════════════════════════════
   PIN Inputs
   ═══════════════════════════════════════════ */

.pin-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 2rem 0;
}

.pin-input {
    width: 56px;
    height: 64px;
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--id-font-mono);
    background: var(--id-bg-input);
    border: 2px solid var(--id-border);
    border-radius: var(--id-radius);
    color: var(--id-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.pin-input:focus {
    border-color: var(--id-primary);
    box-shadow: 0 0 0 3px var(--id-primary-20);
}

.pin-input.error {
    border-color: var(--id-error);
    animation: shake 0.4s ease-in-out;
}

.pin-input.success {
    border-color: var(--id-success);
}

.pin-input::-webkit-outer-spin-button,
.pin-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pin-label {
    text-align: center;
    font-size: 0.875rem;
    color: var(--id-text-muted);
    margin-bottom: 0.5rem;
}

.pin-error {
    text-align: center;
    font-size: 0.8rem;
    color: var(--id-error);
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: var(--id-radius);
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.2s;
    min-height: 48px;
}

.btn-primary {
    background: var(--id-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--id-primary-dark);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

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

.btn-ghost:hover {
    color: var(--id-text);
}

.btn-danger {
    color: var(--id-error);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-full {
    width: 100%;
}

/* ═══════════════════════════════════════════
   Empty state
   ═══════════════════════════════════════════ */

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.empty-icon {
    margin-bottom: 1.5rem;
    opacity: 0.4;
}

.empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-text {
    font-size: 0.875rem;
    color: var(--id-text-muted);
    margin-bottom: 2rem;
    max-width: 280px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════
   Account Cards
   ═══════════════════════════════════════════ */

.accounts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0 1rem;
}

.accounts-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.accounts-count {
    font-size: 0.8rem;
    color: var(--id-text-dim);
    background: var(--id-bg-card);
    padding: 0.25rem 0.625rem;
    border-radius: 100px;
}

.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 100px;
}

.account-card {
    background: var(--id-bg-card);
    border: 1px solid var(--id-border);
    border-radius: var(--id-radius-lg);
    padding: 1.125rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
}

.account-card:active {
    transform: scale(0.98);
    background: var(--id-bg-card-hover);
}

.account-card.copied {
    border-color: var(--id-success);
}

.account-id {
    font-size: 0.75rem;
    font-family: var(--id-font-mono);
    color: var(--id-primary-light);
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.account-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.account-code {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--id-font-mono);
    letter-spacing: 0.15em;
    color: var(--id-text);
}

.account-code .code-separator {
    color: var(--id-text-dim);
    margin: 0 2px;
}

.account-copied {
    font-size: 0.75rem;
    color: var(--id-success);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
}

.account-copied.visible {
    opacity: 1;
}

/* ═══════════════════════════════════════════
   Timer (circular SVG)
   ═══════════════════════════════════════════ */

.timer-container {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.timer-svg {
    width: 40px;
    height: 40px;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: var(--id-border);
    stroke-width: 3;
}

.timer-progress {
    fill: none;
    stroke: var(--id-primary);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.timer-progress.warning {
    stroke: var(--id-warning);
}

.timer-progress.danger {
    stroke: var(--id-error);
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--id-font-mono);
    color: var(--id-text-muted);
}

/* ═══════════════════════════════════════════
   FAB (Floating Action Button)
   ═══════════════════════════════════════════ */

.fab {
    position: fixed;
    bottom: calc(2rem + var(--safe-bottom));
    right: calc(50% - 180px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--id-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--id-primary-glow);
    transition: all 0.2s;
    z-index: 100;
}

.fab:hover {
    background: var(--id-primary-dark);
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 420px) {
    .fab {
        right: 1.5rem;
    }
}

/* ═══════════════════════════════════════════
   Scanner (Sprint 3)
   ═══════════════════════════════════════════ */

.scanner-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 300px;
    margin: 0 auto;
    border-radius: var(--id-radius-lg);
    overflow: hidden;
    background: #000;
}

.scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-canvas {
    display: none;
}

.scanner-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--id-text-muted);
    margin-top: 1.5rem;
}

/* ═══════════════════════════════════════════
   Confirm card (Sprint 3)
   ═══════════════════════════════════════════ */

.confirm-card {
    background: var(--id-bg-card);
    border: 1px solid var(--id-border);
    border-radius: var(--id-radius-lg);
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: center;
}

.confirm-id {
    font-family: var(--id-font-mono);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--id-primary-light);
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.confirm-issuer {
    font-size: 0.8rem;
    color: var(--id-text-dim);
}

.confirm-actions {
    display: flex;
    gap: 12px;
    margin-top: 1rem;
}

.confirm-actions .btn {
    flex: 1;
}

/* ═══════════════════════════════════════════
   Delete modal
   ═══════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--id-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
    animation: fadeIn 0.15s ease-out;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal {
    background: #1a1a2e;
    border: 1px solid var(--id-border);
    border-radius: var(--id-radius-xl);
    padding: 1.75rem;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-text {
    font-size: 0.875rem;
    color: var(--id-text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-id {
    font-family: var(--id-font-mono);
    color: var(--id-primary-light);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions .btn {
    flex: 1;
}

/* ═══════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-8px); }
    50%      { transform: translateX(8px); }
    75%      { transform: translateX(-4px); }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   Reduced motion
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
