/**
 * HERMES v4.0 - Portail Citoyen
 * CSS Mobile-First Responsive
 */

:root {
    --hermes-primary: #667eea;
    --hermes-secondary: #764ba2;
    --hermes-gradient: linear-gradient(135deg, var(--hermes-primary), var(--hermes-secondary));
    --hermes-success: #10b981;
    --hermes-danger: #ef4444;
    --hermes-warning: #f59e0b;
    --hermes-info: #3b82f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.2s ease;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ======================================
   AUTHENTIFICATION (Login / Inscription)
   ====================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--hermes-gradient);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 72px;
    height: 72px;
    background: var(--hermes-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: white;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

.auth-footer {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.auth-footer p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 14px;
}

/* Success Screen */
.success-screen {
    text-align: center;
    padding: 20px 0;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 40px;
    color: white;
}

.success-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.success-message {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ======================================
   FORMULAIRES
   ====================================== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--hermes-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

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

.form-control.is-invalid {
    border-color: var(--hermes-danger);
}

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ======================================
   BOUTONS
   ====================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn i {
    font-size: 18px;
}

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

.btn-primary:hover, .btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--hermes-primary);
    color: var(--hermes-primary);
}

.btn-success {
    background: var(--hermes-success);
    color: white;
}

.btn-danger {
    background: var(--hermes-danger);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 16px 28px;
    font-size: 17px;
}

.btn-sm {
    padding: 10px 16px;
    font-size: 14px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ======================================
   ALERTES
   ====================================== */

.alert {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert i {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ======================================
   LAYOUT PRINCIPAL
   ====================================== */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

/* Header */
.app-header {
    background: var(--hermes-gradient);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    text-decoration: none;
}

.header-brand i {
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* Bottom Nav */
.app-nav {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-items {
    display: flex;
    justify-content: space-around;
    max-width: 600px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

.nav-item i {
    font-size: 22px;
}

.nav-item.active {
    color: var(--hermes-primary);
}

.nav-item:hover {
    color: var(--hermes-primary);
}

/* Espaceur pour le nav fixe */
.nav-spacer {
    height: 80px;
}

/* ======================================
   CARTES & COMPOSANTS
   ====================================== */

.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 16px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

/* QR Code */
.qr-container {
    text-align: center;
    padding: 24px 16px;
}

.qr-wrapper {
    display: inline-block;
    padding: 16px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.qr-wrapper img {
    width: 180px;
    height: 180px;
    display: block;
}

.qr-card-number {
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 16px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-top: 16px;
}

.qr-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
}

.qr-status.valid {
    background: #d1fae5;
    color: #065f46;
}

.qr-status.trial {
    background: #dbeafe;
    color: #1e40af;
}

.qr-status.expired {
    background: #fee2e2;
    color: #991b1b;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--hermes-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Liste */
.list-group {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

.list-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:active {
    background: var(--bg-secondary);
}

.list-item-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--hermes-primary);
    margin-right: 14px;
    flex-shrink: 0;
}

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

.list-item-title {
    font-weight: 600;
    font-size: 15px;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.list-item-value {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.list-item-arrow {
    color: var(--text-muted);
    font-size: 20px;
    margin-left: 8px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ======================================
   PRODUITS / BOUTIQUE
   ====================================== */

.products-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.product-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.product-type {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.product-type.unit {
    background: #dbeafe;
    color: #1e40af;
}

.product-type.carnet {
    background: #f3e8ff;
    color: #7c3aed;
}

.product-type.subscription {
    background: #d1fae5;
    color: #065f46;
}

.product-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--hermes-primary);
}

.product-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.product-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.product-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.product-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ======================================
   FACTURES
   ====================================== */

.invoice-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invoice-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-primary);
}

.invoice-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-right: 14px;
    flex-shrink: 0;
}

.invoice-icon.paid {
    background: #d1fae5;
    color: #059669;
}

.invoice-icon.pending {
    background: #fef3c7;
    color: #d97706;
}

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

.invoice-number {
    font-weight: 600;
    font-size: 15px;
}

.invoice-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.invoice-amount {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}

/* ======================================
   SECTION TITRE
   ====================================== */

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ======================================
   EMPTY STATE
   ====================================== */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ======================================
   PROFILE / SETTINGS
   ====================================== */

.profile-header {
    text-align: center;
    padding: 24px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--hermes-gradient);
    color: white;
    font-size: 32px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
}

.profile-email {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ======================================
   UTILITAIRES
   ====================================== */

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--hermes-success); }
.text-danger { color: var(--hermes-danger); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.p-0 { padding: 0; }
.hidden { display: none !important; }

/* ======================================
   LOADING
   ====================================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--hermes-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Safe areas iOS */
@supports (padding: max(0px)) {
    .app-header {
        padding-top: max(16px, env(safe-area-inset-top));
    }
    
    .auth-page {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Focus visible */
:focus-visible {
    outline: 3px solid var(--hermes-primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--hermes-primary);
    color: white;
}

/* ======================================
   FORMULAIRES AMÉLIORÉS
   ====================================== */

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.form-section-title:first-of-type {
    margin-top: 0;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin: 16px 0;
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--hermes-primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    cursor: pointer;
}

.form-check-label strong {
    color: var(--text-primary);
}

.form-link {
    font-size: 13px;
    color: var(--hermes-primary);
    text-decoration: none;
    transition: var(--transition);
}

.form-link:hover {
    text-decoration: underline;
}

/* ======================================
   HEADER AVEC RETOUR
   ====================================== */

.header-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    font-size: 20px;
    border-radius: 50%;
    transition: var(--transition);
}

.header-back:hover {
    background: rgba(255,255,255,0.15);
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

/* ======================================
   TEXTE UTILITAIRES
   ====================================== */

.text-end {
    text-align: right;
}

.text-center {
    text-align: center;
}

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

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }

/* ======================================
   BOUTONS ACTION TITRE
   ====================================== */

.ticket-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.ticket-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.ticket-action-btn i {
    font-size: 20px;
    color: var(--hermes-primary);
}

.ticket-action-btn:hover {
    background: var(--hermes-primary);
    color: white;
}

.ticket-action-btn:hover i {
    color: white;
}
