/* ===================================
   Krypton Swap - Responsive CSS
   Compatible Desktop & Mobile
   =================================== */

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

/* Variables CSS pour cohérence */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-bg: #d4edda;
    --success-color: #155724;
    --success-border: #c3e6cb;
    --error-bg: #f8d7da;
    --error-color: #721c24;
    --error-border: #f5c6cb;
    --warning-bg: #fff3cd;
    --warning-color: #856404;
    --warning-border: #ffeeba;
    --gray-light: #f7f7f7;
    --gray-medium: #e0e0e0;
    --gray-dark: #333;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #888;
    --border-radius: 8px;
    --border-radius-lg: 20px;
    --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-heavy: 0 20px 40px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* Base styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 20px;
    
    /* Amélioration pour mobile */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* Container principal */
.container {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* Carte principale */
.card {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-heavy);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Titres */
h1 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 2rem;
    font-weight: 700;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Grille des statistiques */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat {
    background: var(--gray-light);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    transition: var(--transition);
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--text-primary);
    word-break: break-all;
}

.price-dynamic {
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 2px;
}

/* Groupes de formulaire */
.form-group {
    margin-bottom: 20px;
}

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

/* Champs de saisie */
input, select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-medium);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: white;
    color: var(--text-primary);
    
    /* Amélioration mobile */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="number"] {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

/* Direction du swap */
.swap-direction {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.swap-direction > div {
    flex: 1;
}

.swap-arrow {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: bold;
    flex-shrink: 0;
    text-align: center;
    min-width: 30px;
}

/* Boutons */
.btn {
    width: 100%;
    padding: 15px 20px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    
    /* Amélioration mobile */
    touch-action: manipulation;
    min-height: 48px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.btn:active {
    transform: translateY(0);
}

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

/* Messages d'alerte */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    white-space: pre-line;
    line-height: 1.5;
    font-size: 0.9rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-color);
    border: 1px solid var(--success-border);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-color);
    border: 1px solid var(--error-border);
}

/* Informations de sécurité */
.security-info {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin: 15px 0;
}

.security-info h4 {
    color: #2e7d32;
    margin-bottom: 12px;
    font-size: 1rem;
}

.security-item {
    display: flex;
    align-items: center;
    margin: 8px 0;
    color: #2e7d32;
    font-size: 0.85rem;
    line-height: 1.4;
}

.security-item::before {
    content: "✓";
    margin-right: 10px;
    font-weight: bold;
    color: #4caf50;
    flex-shrink: 0;
}

/* Informations AMM */
.amm-info {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin: 15px 0;
    font-size: 0.8rem;
    color: #1565c0;
    line-height: 1.5;
}

/* Informations du swap */
.swap-info {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-top: 25px;
}

.swap-info h3 {
    color: var(--warning-color);
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Adresse de dépôt */
.deposit-address {
    background: #f8f9fa;
    padding: 15px;
    border-radius: var(--border-radius);
    word-break: break-all;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 0.85rem;
    margin: 15px 0;
    border: 1px solid #dee2e6;
    line-height: 1.4;
}

/* Lignes d'information */
.info-row {
    display: flex;
    justify-content: space-between;
    margin: 12px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    align-items: flex-start;
    gap: 15px;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: fit-content;
    flex-shrink: 0;
}

.info-row span:last-child {
    text-align: right;
    word-break: break-all;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9rem;
}

/* Timer */
.timer {
    text-align: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: #dc3545;
    margin: 20px 0;
    font-family: 'SF Mono', Monaco, monospace;
    padding: 15px;
    background: rgba(220, 53, 69, 0.1);
    border-radius: var(--border-radius);
}

/* Status */
.status {
    text-align: center;
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    font-weight: 600;
    font-size: 0.95rem;
}

.status-pending { 
    background: var(--warning-bg); 
    color: var(--warning-color);
    border: 1px solid var(--warning-border);
}
.status-confirming { 
    background: #cce5ff; 
    color: #004085;
    border: 1px solid #99d6ff;
}
.status-confirmed { 
    background: #d1ecf1; 
    color: #0c5460;
    border: 1px solid #bee5eb;
}
.status-completed { 
    background: var(--success-bg); 
    color: var(--success-color);
    border: 1px solid var(--success-border);
}
.status-expired, .status-failed { 
    background: var(--error-bg); 
    color: var(--error-color);
    border: 1px solid var(--error-border);
}

/* Prévisualisation du montant */
#amount-preview {
    margin-top: 15px;
    padding: 15px;
    background: #f0f0f0;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.6;
    border: 1px solid #ddd;
}

/* Impact sur le prix */
.price-impact {
    margin: 15px 0;
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
}

.impact-low { 
    background: #e8f5e8; 
    color: #2e7d32;
    border: 1px solid #4caf50;
}
.impact-medium { 
    background: var(--warning-bg); 
    color: var(--warning-color);
    border: 1px solid var(--warning-border);
}
.impact-high { 
    background: var(--error-bg); 
    color: var(--error-color);
    border: 1px solid var(--error-border);
}

/* ===================================
   RESPONSIVE DESIGN - MOBILE
   =================================== */

/* Tablettes */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .card {
        padding: 25px 20px;
        border-radius: 15px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .stats {
        gap: 12px;
    }
    
    .stat {
        padding: 12px 10px;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .swap-direction {
        gap: 10px;
    }
    
    .swap-arrow {
        font-size: 1.25rem;
        min-width: 25px;
    }
}

/* Smartphones */
@media (max-width: 480px) {
    body {
        padding: 10px;
        font-size: 14px;
    }
    
    .container {
        max-width: 100%;
    }
    
    .card {
        padding: 20px 15px;
        border-radius: 12px;
        margin: 0;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .subtitle {
        font-size: 0.8rem;
        margin-bottom: 25px;
    }
    
    /* Stats en colonne simple sur très petits écrans */
    .stats {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 25px;
    }
    
    .stat {
        padding: 15px 12px;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 0.95rem;
    }
    
    /* Direction du swap verticale sur mobile */
    .swap-direction {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .swap-arrow {
        align-self: center;
        transform: rotate(90deg);
        font-size: 1.5rem;
        margin: 5px 0;
    }
    
    /* Champs plus grands pour mobile */
    input, select {
        padding: 14px;
        font-size: 16px; /* Empêche le zoom iOS */
        min-height: 48px;
    }
    
    .btn {
        padding: 16px;
        font-size: 1rem;
        min-height: 52px;
    }
    
    /* Lignes d'info empilées sur mobile */
    .info-row {
        flex-direction: column;
        gap: 8px;
        text-align: left;
    }
    
    .info-row span:last-child {
        text-align: left;
        font-size: 0.85rem;
    }
    
    /* Adresse plus lisible */
    .deposit-address {
        font-size: 0.75rem;
        padding: 12px;
        line-height: 1.3;
    }
    
    /* Timer plus compact */
    .timer {
        font-size: 1.5rem;
        padding: 12px;
    }
    
    /* Messages plus compacts */
    .alert, .security-info, .amm-info {
        padding: 12px 15px;
        margin: 12px 0;
        font-size: 0.85rem;
    }
    
    .security-item {
        font-size: 0.8rem;
    }
    
    #amount-preview {
        padding: 12px;
        font-size: 0.85rem;
    }
}

/* Très petits écrans */
@media (max-width: 360px) {
    .card {
        padding: 15px 12px;
    }
    
    h1 {
        font-size: 1.3rem;
    }
    
    .stat-value {
        font-size: 0.9rem;
        line-height: 1.2;
    }
    
    input, select {
        padding: 12px;
    }
    
    .deposit-address {
        font-size: 0.7rem;
        padding: 10px;
    }
}

/* Mode landscape sur mobile */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
    
    .card {
        padding: 20px;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
        margin-bottom: 20px;
    }
    
    .swap-direction {
        flex-direction: row;
    }
    
    .swap-arrow {
        transform: none;
    }
}

/* Améliorations pour les interactions tactiles */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .stat:hover {
        transform: none;
        box-shadow: none;
    }
    
    .btn:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Mode sombre automatique (optionnel) */
@media (prefers-color-scheme: dark) {
    /* Uncomment pour activer le mode sombre automatique
    :root {
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --gray-light: #2d3748;
        --gray-medium: #4a5568;
    }
    
    .card {
        background: #1a202c;
        color: var(--text-primary);
    }
    */
}

/* Scroll personnalisé pour WebKit */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Animation de chargement */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 2s ease-in-out infinite;
}

/* Amélioration de l'accessibilité */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}