import 'package:flutter/material.dart';

/// Paleta institucional — Gobierno Municipal
/// ─────────────────────────────────────────
/// Vino principal   #9B1B4A
/// Rosa institucional #C9A8B2
/// Beige dorado     #C8A36A
/// Rosa claro fondo #E8D5DB
/// Verde acento     #1E7A46
/// Azul accesibilidad #004A7C
/// Texto oscuro     #1F1F1F
/// Fondo blanco     #F8F8F8
class AppTheme {
  // ── Primarios ──────────────────────────────────────────────────────────────
  static const Color primary      = Color(0xFF9B1B4A);
  static const Color primaryDark  = Color(0xFF6D1234);
  static const Color primaryLight = Color(0xFFE8D5DB);
  static const Color primaryMid   = Color(0xFFC9A8B2);

  // ── Azul accesibilidad ─────────────────────────────────────────────────────
  static const Color blue         = Color(0xFF004A7C);
  static const Color blueLight    = Color(0xFFDCEAF3);

  // ── Beige dorado (alertas / acento cálido) ─────────────────────────────────
  static const Color amber        = Color(0xFF8B6914);
  static const Color amberLight   = Color(0xFFF5EDD8);

  // ── Verde acento (éxito / estados activos) ─────────────────────────────────
  static const Color accent       = Color(0xFF1E7A46);
  static const Color accentLight  = Color(0xFFDFF0E8);

  // ── Peligro ────────────────────────────────────────────────────────────────
  static const Color danger       = Color(0xFFD93040);
  static const Color dangerLight  = Color(0xFFFCEBEB);

  // ── Texto ─────────────────────────────────────────────────────────────────
  static const Color textPrimary   = Color(0xFF1F1F1F);
  static const Color textSecondary = Color(0xFF6B7280);
  static const Color textHint      = Color(0xFFAAAAAA);

  // ── Superficies ────────────────────────────────────────────────────────────
  static const Color surface      = Color(0xFFFFFFFF);
  static const Color background   = Color(0xFFF8F8F8);
  static const Color border       = Color(0xFFE0D5D8);
  static const Color borderLight  = Color(0xFFF0ECF0);

  // ── Radios ────────────────────────────────────────────────────────────────
  static const double radiusSm   = 8.0;
  static const double radiusMd   = 12.0;
  static const double radiusLg   = 16.0;
  static const double radiusXl   = 24.0;
  static const double radiusFull = 100.0;

  // ── Sombras ───────────────────────────────────────────────────────────────
  static List<BoxShadow> get cardShadow => [
    BoxShadow(
      color: const Color(0xFF9B1B4A).withValues(alpha: 0.07),
      blurRadius: 12,
      offset: const Offset(0, 4),
    ),
  ];

  static List<BoxShadow> get softShadow => [
    BoxShadow(
      color: Colors.black.withValues(alpha: 0.04),
      blurRadius: 8,
      offset: const Offset(0, 2),
    ),
  ];

  // ── Tema global ───────────────────────────────────────────────────────────
  static ThemeData get lightTheme => ThemeData(
    useMaterial3: true,
    colorScheme: ColorScheme.fromSeed(
      seedColor: primary,
      primary: primary,
      secondary: accent,
      surface: surface,
    ),
    scaffoldBackgroundColor: background,
    appBarTheme: const AppBarTheme(
      backgroundColor: primary,
      foregroundColor: Colors.white,
      elevation: 0,
      centerTitle: false,
      titleTextStyle: TextStyle(
        inherit: false,
        fontSize: 17,
        fontWeight: FontWeight.w700,
        color: Colors.white,
        letterSpacing: 0.1,
      ),
      iconTheme: IconThemeData(color: Colors.white),
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        backgroundColor: primary,
        foregroundColor: Colors.white,
        elevation: 0,
        minimumSize: const Size(double.infinity, 52),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(radiusMd),
        ),
      ),
    ),
    filledButtonTheme: FilledButtonThemeData(
      style: FilledButton.styleFrom(
        backgroundColor: primary,
        foregroundColor: Colors.white,
        minimumSize: const Size(double.infinity, 52),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(radiusMd),
        ),
      ),
    ),
    outlinedButtonTheme: OutlinedButtonThemeData(
      style: OutlinedButton.styleFrom(
        foregroundColor: Colors.white,
        side: const BorderSide(color: Colors.white54, width: 1.5),
        minimumSize: const Size(double.infinity, 52),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(radiusMd),
        ),
      ),
    ),
    inputDecorationTheme: InputDecorationTheme(
      filled: true,
      fillColor: surface,
      contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radiusSm),
        borderSide: const BorderSide(color: border),
      ),
      enabledBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radiusSm),
        borderSide: const BorderSide(color: border),
      ),
      focusedBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radiusSm),
        borderSide: const BorderSide(color: primary, width: 1.5),
      ),
      errorBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radiusSm),
        borderSide: const BorderSide(color: danger),
      ),
      focusedErrorBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radiusSm),
        borderSide: const BorderSide(color: danger, width: 1.5),
      ),
      labelStyle: const TextStyle(color: textSecondary, fontSize: 13),
      hintStyle: const TextStyle(color: textHint, fontSize: 13),
    ),
    switchTheme: SwitchThemeData(
      thumbColor: WidgetStateProperty.resolveWith(
        (s) => s.contains(WidgetState.selected) ? primary : Colors.white,
      ),
      trackColor: WidgetStateProperty.resolveWith(
        (s) => s.contains(WidgetState.selected)
            ? primary.withValues(alpha: 0.5)
            : Colors.grey.shade300,
      ),
    ),
  );
}
