@tailwind base;
@tailwind components;
@tailwind utilities;

/* ==========================================================================
   Configuration et Variables
   ========================================================================== */

@layer base {
    :root {
        --color-primary: #4F46E5;
        --color-primary-light: #6366F1;
        --color-primary-dark: #4338CA;
        --color-secondary: #10B981;
        --color-accent: #F59E0B;
        --color-dark: #1F2937;
        --color-gray-50: #F9FAFB;
        --color-gray-100: #F3F4F6;
        --color-gray-200: #E5E7EB;
        --color-gray-300: #D1D5DB;
        --color-gray-400: #9CA3AF;
        --color-gray-500: #6B7280;
        --color-gray-600: #4B5563;
        --color-gray-700: #374151;
        --color-gray-800: #1F2937;
        --color-gray-900: #111827;
    }

    * {
        box-sizing: border-box;
    }

    html {
        scroll-behavior: smooth;
    }

    body {
        font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        @apply text-gray-900 antialiased;
    }

    /* Selection */
    ::selection {
        @apply bg-primary-100 text-primary-900;
    }

    /* Scrollbar */
    ::-webkit-scrollbar {
        @apply w-2;
    }

    ::-webkit-scrollbar-track {
        @apply bg-gray-100;
    }

    ::-webkit-scrollbar-thumb {
        @apply bg-gray-300 rounded-full;
    }

    ::-webkit-scrollbar-thumb:hover {
        @apply bg-gray-400;
    }
}

/* ==========================================================================
   Composants UI
   ========================================================================== */

@layer components {
    /* Boutons */
    .btn {
        @apply inline-flex items-center justify-center px-4 py-2 text-sm font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2;
    }

    .btn-primary {
        @apply bg-primary text-white hover:bg-primary-600 focus:ring-primary;
    }

    .btn-submit {
        @apply bg-primary text-white hover:bg-primary-600 focus:ring-primary w-full mt-6;
    }

    .btn-secondary {
        @apply bg-gray-200 text-gray-800 hover:bg-gray-300 focus:ring-gray-500;
    }

    .btn-outline {
        @apply border-2 border-primary text-primary hover:bg-primary hover:text-white focus:ring-primary;
    }

    .btn-danger {
        @apply bg-red-600 text-white hover:bg-red-700 focus:ring-red-500;
    }

    .btn-success {
        @apply bg-green-600 text-white hover:bg-green-700 focus:ring-green-500;
    }

    .btn-sm {
        @apply px-3 py-1.5 text-xs;
    }

    .btn-lg {
        @apply px-6 py-3 text-base;
    }

    .btn-block {
        @apply w-full;
    }

    /* Cartes */
    .card {
        @apply bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden;
    }

    .card-header {
        @apply px-6 py-4 border-b border-gray-100;
    }

    .card-body {
        @apply p-6;
    }

    .card-footer {
        @apply px-6 py-4 bg-gray-50 border-t border-gray-100;
    }

    /* Inputs */
    .input {
        @apply block w-full px-4 py-2.5 border border-gray-300 rounded-lg text-gray-900 placeholder-gray-400 focus:ring-2 focus:ring-primary focus:border-transparent transition-colors;
    }

    .input-error {
        @apply border-red-300 text-red-900 focus:ring-red-500;
    }

    .label {
        @apply block text-sm font-medium text-gray-700 mb-1;
    }

    /* Badges */
    .badge {
        @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
    }

    .badge-primary {
        @apply bg-primary-100 text-primary-800;
    }

    .badge-success {
        @apply bg-green-100 text-green-800;
    }

    .badge-warning {
        @apply bg-amber-100 text-amber-800;
    }

    .badge-danger {
        @apply bg-red-100 text-red-800;
    }

    .badge-gray {
        @apply bg-gray-100 text-gray-800;
    }

    /* Alerts */
    .alert {
        @apply p-4 rounded-lg border;
    }

    .alert-success {
        @apply bg-green-50 border-green-200 text-green-800;
    }

    .alert-error {
        @apply bg-red-50 border-red-200 text-red-800;
    }

    .alert-warning {
        @apply bg-amber-50 border-amber-200 text-amber-800;
    }

    .alert-info {
        @apply bg-blue-50 border-blue-200 text-blue-800;
    }
}

/* ==========================================================================
   Utilitaires
   ========================================================================== */

@layer utilities {
    /* Textes */
    .text-gradient {
        @apply bg-clip-text text-transparent bg-gradient-to-r from-primary to-primary-light;
    }

    /* Ombres */
    .shadow-soft {
        box-shadow: 0 2px 15px -3px rgba(0, 0, 0, 0.07), 0 10px 20px -2px rgba(0, 0, 0, 0.04);
    }

    .shadow-glow {
        box-shadow: 0 0 20px rgba(79, 70, 229, 0.3);
    }

    /* Transitions */
    .transition-smooth {
        @apply transition-all duration-300 ease-in-out;
    }

    /* Layout */
    .page-container {
        @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8;
    }

    /* Focus visible */
    .focus-ring {
        @apply focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2;
    }
}

.whatsapp-float {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 999px;
    background: #25d366;
    color: #fff;
    box-shadow: 0 18px 40px rgba(37, 211, 102, 0.28);
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease;
}

.whatsapp-float:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 48px rgba(37, 211, 102, 0.34);
}

.whatsapp-float__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    padding: 6px;
}

.whatsapp-float__text {
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
}

.whatsapp-float__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

@media (max-width: 640px) {
    .whatsapp-float {
        right: 14px;
        bottom: 14px;
        padding: 12px;
    }

    .whatsapp-float__text {
        display: none;
    }
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes pulse-soft {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Classes d'animation */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

.animate-slide-down {
    animation: slideDown 0.3s ease-out;
}

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

/* ==========================================================================
   Styles spécifiques aux composants
   ========================================================================== */

/* Hero Section */
.hero {
    @apply relative py-20 lg:py-32 overflow-hidden;
}

.hero-bg {
    @apply absolute inset-0 bg-gradient-to-br from-primary-600 to-primary-900;
}

.hero-content {
    @apply relative z-10 max-w-4xl mx-auto text-center px-4;
}

/* Pricing Cards */
.pricing-card {
    @apply relative bg-white rounded-2xl shadow-lg border border-gray-200 p-8 transition-transform duration-300 hover:-translate-y-1;
}

.pricing-card.popular {
    @apply ring-2 ring-primary border-primary;
}

.pricing-card.popular::before {
    content: '';
    @apply absolute -top-px left-0 right-0 h-1 bg-gradient-to-r from-primary to-primary-light rounded-t-2xl;
}

/* Dashboard Stats */
.stat-card {
    @apply bg-white rounded-xl shadow-sm border border-gray-100 p-6;
}

.stat-value {
    @apply text-3xl font-bold text-gray-900;
}

.stat-label {
    @apply text-sm text-gray-500 mt-1;
}

.stat-change {
    @apply text-sm font-medium;
}

.stat-change.positive {
    @apply text-green-600;
}

.stat-change.negative {
    @apply text-red-600;
}

/* Sidebar */
.sidebar-link {
    @apply flex items-center gap-3 px-4 py-2.5 rounded-lg text-sm font-medium text-gray-600 hover:bg-gray-50 hover:text-gray-900 transition-colors;
}

.sidebar-link.active {
    @apply bg-primary-50 text-primary-700;
}

/* Form Groups */
.form-group {
    @apply mb-4;
}

.form-error {
    @apply mt-1 text-sm text-red-600;
}

.form-help {
    @apply mt-1 text-sm text-gray-500;
}

/* Tables */
.table-container {
    @apply overflow-x-auto rounded-lg border border-gray-200;
}

.table {
    @apply min-w-full divide-y divide-gray-200;
}

.table th {
    @apply px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50;
}

.table td {
    @apply px-6 py-4 whitespace-nowrap text-sm text-gray-900;
}

.table tbody tr {
    @apply hover:bg-gray-50 transition-colors;
}

/* Dropdown Menu */
.dropdown-menu {
    @apply absolute right-0 mt-2 w-56 bg-white rounded-xl shadow-lg border border-gray-200 py-2 z-50;
}

.dropdown-item {
    @apply flex items-center gap-3 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors;
}

/* Modal */
.modal-overlay {
    @apply fixed inset-0 bg-gray-900/50 transition-opacity;
}

.modal-content {
    @apply relative transform overflow-hidden rounded-xl bg-white text-left shadow-xl transition-all;
}

/* Loading Spinner */
.spinner {
    @apply animate-spin h-5 w-5 text-primary;
}

.spinner-lg {
    @apply h-8 w-8;
}

/* Skeleton Loading */
.skeleton {
    @apply bg-gray-200 rounded animate-pulse;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
    .hero {
        @apply py-16;
    }
    
    .page-container {
        @apply px-4;
    }
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ==========================================================================
   Public Market / Pricing
   ========================================================================== */

.market-hero {
    background:
        radial-gradient(900px 360px at 15% -5%, rgba(79, 70, 229, 0.14), transparent 55%),
        radial-gradient(680px 280px at 95% 5%, rgba(14, 165, 233, 0.12), transparent 50%),
        linear-gradient(180deg, #eef4ff 0%, #ffffff 100%);
}

.market-hero__inner {
    display: grid;
    gap: 24px;
    padding-top: 72px;
    padding-bottom: 72px;
}

.market-hero__copy {
    max-width: 760px;
}

.market-kicker {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

.market-title {
    margin: 10px 0 0;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.02;
    font-weight: 600;
    color: #0f172a;
}

.market-lead {
    margin-top: 16px;
    max-width: 720px;
    font-size: 18px;
    line-height: 1.7;
    color: #475569;
}

.market-hero__panel,
.market-card,
.market-note {
    border: 1px solid #dbe5f0;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.06);
}

.market-hero__panel {
    padding: 24px;
    max-width: 460px;
}

.market-hero__panel--grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-width: 100%;
}

.market-panel__title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
}

.market-panel__copy {
    margin: 12px 0 0;
    color: #334155;
    line-height: 1.7;
}

.market-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.market-actions--compact {
    margin-top: 20px;
}

.market-section {
    padding: 56px 0;
}

.market-section--white {
    background: #ffffff;
}

.market-section--tint {
    background: #f6f8fc;
}

.market-section__header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.market-section__title,
.market-zone__title {
    margin: 8px 0 0;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.1;
    font-weight: 600;
    color: #0f172a;
}

.market-grid {
    display: grid;
    gap: 16px;
}

.market-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.market-card {
    padding: 24px;
}

.market-card--best {
    position: relative;
    border-color: rgba(79, 70, 229, 0.24);
    box-shadow: 0 20px 60px rgba(79, 70, 229, 0.12);
}

.market-card__eyebrow {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.market-card__title {
    margin: 8px 0 0;
    font-size: 26px;
    line-height: 1.18;
    font-weight: 600;
    color: #0f172a;
}

.market-card__copy,
.market-zone__note {
    margin: 10px 0 0;
    color: #475569;
    line-height: 1.7;
}

.market-card__keywords,
.market-signal-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.market-card__keywords span,
.market-signal-row span,
.market-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    background: #eef2ff;
    color: #3730a3;
}

.market-badge {
    margin-bottom: 16px;
    background: #111827;
    color: #ffffff;
}

.market-country-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.market-country-head--hero {
    align-items: start;
    gap: 18px;
}

.market-country-head__badge {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    flex: 0 0 auto;
}

.market-country-head__badge--large {
    width: 72px;
    height: 72px;
    border-radius: 22px;
}

.market-country-head__badge--emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
    border: 1px solid #dbe5f0;
    font-size: 28px;
}

.market-list {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
    padding-left: 18px;
    color: #334155;
}

.market-list li strong {
    display: block;
    color: #0f172a;
}

.market-list--inline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.market-list--inline li {
    list-style: disc;
}

.market-package__price {
    margin: 10px 0 0;
    font-size: 42px;
    line-height: 1;
    font-weight: 600;
    color: #0f172a;
}

.market-package__annual {
    margin: 8px 0 0;
    font-size: 14px;
    font-weight: 600;
    color: #6366f1;
}

.market-zone + .market-zone {
    margin-top: 40px;
}

.market-zone__header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.market-note {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    padding: 18px 20px;
    color: #334155;
}

.market-faq {
    display: grid;
    gap: 16px;
}

.market-stat {
    border-radius: 16px;
    padding: 18px;
    background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
}

.market-stat strong {
    display: block;
    font-size: 28px;
    line-height: 1;
    color: #0f172a;
}

.market-stat span {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: #475569;
}

@media (max-width: 1023px) {
    .market-grid--three,
    .market-list--inline,
    .market-hero__panel--grid {
        grid-template-columns: 1fr;
    }

    .market-zone__header,
    .market-section__header {
        align-items: start;
        flex-direction: column;
    }
}
