/* ===================================
   Reset et Variables
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --success: #10B981;
    --success-dark: #059669;
    --secondary: #6B7280;
    --danger: #EF4444;
    --bg: #F9FAFB;
    --card: #FFFFFF;
    --text: #111827;
    --text-light: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===================================
   Layout général
   =================================== */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

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

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

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--text);
}

.subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: -0.5rem 0 0.5rem 0;
}

.create-fournisseur-zone.hidden,
.create-produit-zone.hidden {
    display: none;
}

/* ===================================
   Zone glisser-déposer + aperçu
   =================================== */
.drop-zone {
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    outline: none;
}

.drop-zone:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

.drop-zone.drop-zone-active {
    border-color: var(--primary);
    background: #eef2ff;
    box-shadow: var(--shadow-lg);
}

.drop-zone-prompt {
    padding: 1.25rem 0.5rem;
}

.drop-zone-prompt.hidden {
    display: none;
}

.drop-zone-icon {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.drop-zone-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0 0 0.35rem;
    color: var(--text);
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0;
    line-height: 1.4;
}

.preview-zone {
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.preview-zone.hidden {
    display: none;
}

.preview-zone img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* Overlay plein écran — dépôt depuis Google Drive / autre onglet */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(79, 70, 229, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: all;
}

.drop-overlay.hidden {
    display: none !important;
}

.drop-overlay-inner {
    text-align: center;
    color: #fff;
    max-width: 420px;
    border: 3px dashed rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    padding: 2.5rem 1.5rem;
    background: rgba(255, 255, 255, 0.08);
}

.drop-overlay-icon {
    display: block;
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.drop-overlay-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.drop-overlay-hint {
    font-size: 0.95rem;
    margin: 0;
    opacity: 0.92;
    line-height: 1.45;
}

/* ===================================
   Boutons
   =================================== */
.buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    width: 100%;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-success:hover {
    background-color: var(--success-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover {
    background-color: #4B5563;
}

.btn-drive {
    background-color: #4285F4;
    color: white;
}

.btn-drive:hover {
    background-color: #3367D6;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

/* ===================================
   Formulaire
   =================================== */
.form {
    background: var(--card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input[readonly] {
    background-color: var(--bg);
    cursor: not-allowed;
}

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

/* ===================================
   Lignes de détail
   =================================== */
.lignes-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
}

.ligne-item {
    background: var(--card);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow);
}

.ligne-item p {
    margin: 4px 0;
    font-size: 0.9rem;
}

.ligne-item strong {
    color: var(--text);
}

/* ===================================
   Écran succès
   =================================== */
.success-icon {
    font-size: 5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.success-message {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* ===================================
   Loader
   =================================== */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader p {
    color: white;
    font-size: 1.2rem;
    margin-top: 1rem;
}

/* ===================================
   Utilitaires
   =================================== */
.hidden {
    display: none !important;
}

/* Réception — panneau résultat */
.reception-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 0.9rem;
}

.reception-result.success {
    border-color: var(--success);
    background: #ecfdf5;
}

.reception-result.warning {
    border-color: #f59e0b;
    background: #fffbeb;
}

.reception-result.error {
    border-color: var(--danger);
    background: #fef2f2;
}

.reception-result-summary {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.reception-result-lines {
    list-style: none;
    margin: 0;
    padding: 0;
}

.reception-result-lines li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
}

.reception-result-lines li:last-child {
    border-bottom: none;
}

.reception-result-lines .status-ok { color: var(--success-dark); }
.reception-result-lines .status-error { color: #b91c1c; }
.reception-result-lines .status-skipped { color: var(--text-light); }

.reception-result-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Journal modal */
.journal-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.journal-modal.hidden {
    display: none !important;
}

.journal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.journal-modal-panel {
    position: relative;
    background: var(--card);
    border-radius: 12px;
    padding: 1.25rem;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.journal-content {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow: auto;
}

.journal-modal-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem;
    }
    
    .form {
        padding: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .btn {
        font-size: 1rem;
        padding: 14px 20px;
    }
}
