# FlightMonitor/data/config.py

from typing import Optional, Dict

"""
Global configurations for the FlightMonitor application.

This file centralizes constants and settings used across different modules,
making them easier to manage and modify. Each configuration option should
be clearly documented.
"""

# --- API Configuration ---

# Base URL for the OpenSky Network API's 'states/all' endpoint.
# This endpoint provides current flight states (position, velocity, etc.).
# Documentation: https://opensky-network.org/apidoc/rest.html#all-state-vectors
OPENSKY_API_URL: str = "https://opensky-network.org/api/states/all"

# Default timeout for API requests in seconds.
# This is the maximum time the application will wait for a response from the API
# before considering the request as timed out.
DEFAULT_API_TIMEOUT_SECONDS: int = 15

# ---  Flag per Mock API ---
# Set to True to use mock data instead of making real API calls to OpenSky.
# This is useful for development to avoid consuming API credits and for offline testing.
USE_MOCK_OPENSKY_API: bool = False  # Imposta a False per chiamate reali
MOCK_API_FLIGHT_COUNT: int = (
    50  # Numero di aerei finti da generare se USE_MOCK_OPENSKY_API è True
)
# MOCK_API_ERROR_SIMULATION: Optional[str] = None # Es: "RATE_LIMITED", "HTTP_ERROR", None per successo
MOCK_API_ERROR_SIMULATION: Optional[str] = (
    None  # MODIFIED: Moved error simulation example from comments. Example: "RATE_LIMITED", "HTTP_ERROR", None
)

# Polling interval in seconds for fetching live flight data.
# This determines how frequently the application requests updates from the API
# when live monitoring is active.
LIVE_POLLING_INTERVAL_SECONDS: int = 15  # Ad esempio, ogni 15 secondi


# --- GUI Configuration ---

# Default geographical bounding box coordinates.
# These values are used to pre-fill the input fields in the GUI for
# selecting the geographical area of interest for live flight tracking.
# The example values roughly cover Central Europe.
# Latitude values must be between -90 and 90.
# Longitude values must be between -180 and 180.
DEFAULT_BBOX_LAT_MIN: float = 44.986  # 45.0  # Minimum latitude
DEFAULT_BBOX_LON_MIN: float = 7.9341  # 5.0   # Minimum longitude
DEFAULT_BBOX_LAT_MAX: float = 46.9567  # 55.0  # Maximum latitude
DEFAULT_BBOX_LON_MAX: float = 10.5997  # 15.0  # Maximum longitude

# lamin=44&lomin=6&lamax=47&lomax=10

#
# questa zona si trova nei dintorni del lago di como
# https://boundingbox.klokantech.com/
# 7.9341,44.986,10.5997,46.9567

# Default dimensions (in pixels) for the flight map canvas in the GUI.
# These dimensions determine the initial size of the area where flights are displayed.
DEFAULT_CANVAS_WIDTH: int = 800
DEFAULT_CANVAS_HEIGHT: int = 600

# Directory for map tile caching.
# A service-specific subdirectory will be created inside this.
MAP_TILE_CACHE_DIR: str = "flightmonitor_tile_cache"


# --- Logging Configuration ---
# MODIFIED: Removed all logging-specific constants (LOG_LEVEL, LOG_FORMAT, LOG_DATE_FORMAT, LOG_COLOR_*)
# WHY: These configurations are now centralized in the new logging_config.py module.
# HOW: Deleted these lines.
# Global logging level for the application.
# Valid levels: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
# This sets the minimum severity of messages that will be processed.
# LOG_LEVEL: str = "DEBUG"

# Format string for log messages.
# LOG_FORMAT: str = "%(asctime)s [%(levelname)-8s] %(name)-20s : %(message)s"

# Format string for the date/time in log messages.
# LOG_DATE_FORMAT: str = "%Y-%m-%d %H:%M:%S"

# Colors for different log levels in the GUI log widget.
# LOG_COLOR_DEBUG: str = "RoyalBlue1"
# LOG_COLOR_INFO: str = "black"
# LOG_COLOR_WARNING: str = "dark orange"
# LOG_COLOR_ERROR: str = "red2"
# LOG_COLOR_CRITICAL: str = "red4"


# --- Data Storage Configuration ---

# Directory where daily SQLite database files will be stored.
# This path is relative to the main application directory or an absolute path.
# Ensure this directory is writable by the application.
DATABASE_DIRECTORY: str = "flight_data_history"

# Format string for the daily database filenames.
# Uses strftime format codes (YYYY, MM, DD, HH, etc.).
# Example for daily files: "flights_%Y-%m-%d.db"
DATABASE_FILENAME_FORMAT: str = "flights_%Y-%m-%d.db"

# Placeholder for future: Maximum number of records or days to retain in the history.
# DATA_RETENTION_DAYS: int = 30

# --- GUI Layout Configuration ---
# Questi valori definiscono le proporzioni iniziali e le dimensioni minime
# per i vari pannelli dell'interfaccia utente.
# I 'weights' sono usati dai PanedWindow per la distribuzione iniziale dello spazio.
# I 'min_sizes' sono in pixel.

# Divisione Principale (Orizzontale: Sinistra vs Destra)
LAYOUT_MAIN_HORIZONTAL_WEIGHTS: Dict[str, int] = {
    "left_column": 20,  # Peso per la colonna sinistra
    "right_column": 80,  # Peso per la colonna destra
}
LAYOUT_MAIN_HORIZONTAL_MIN_SIZES: Dict[str, int] = {
    "left_column": 100,  # Dimensione minima in pixel per la colonna sinistra
    "right_column": 400,  # Dimensione minima in pixel per la colonna destra
}

# Divisione Colonna Sinistra (Verticale: Funzioni vs Log/Status)
LAYOUT_LEFT_VERTICAL_WEIGHTS: Dict[str, int] = {
    "function_notebook": 70,  # Peso per l'area del function notebook
    "log_status_area": 30,  # Peso per l'area log e status bar
}
LAYOUT_LEFT_VERTICAL_MIN_SIZES: Dict[str, int] = {
    "function_notebook": 200,  # Dimensione minima per il function notebook
    "log_status_area": 100,  # Dimensione minima per l'area log/status
}

# Divisione Colonna Destra (Verticale: Viste vs Tools/Info)
LAYOUT_RIGHT_VERTICAL_WEIGHTS: Dict[str, int] = {
    "views_notebook": 80,  # Aumentato (es. 80 o 85)
    "map_tools_info": 20,  # Ridotto (es. 20 o 15)
}
LAYOUT_RIGHT_VERTICAL_MIN_SIZES: Dict[str, int] = {
    "views_notebook": 300,  # Dimensione minima per il views notebook
    "map_tools_info": 120,  # Dimensione minima per l'area tools/info
}

# Divisione Area Tools/Info Mappa (Orizzontale: Tool vs Info)
LAYOUT_TOOLS_INFO_HORIZONTAL_WEIGHTS: Dict[str, int] = {
    "map_tools": 20,  # Peso per il frame degli strumenti mappa
    "map_info": 80,  # Peso per il frame delle informazioni mappa
}
LAYOUT_TOOLS_INFO_HORIZONTAL_MIN_SIZES: Dict[str, int] = {
    "map_tools": 150,  # Dimensione minima per gli strumenti mappa
    "map_info": 200,  # Dimensione minima per le info mappa
}

LAYOUT_BOTTOM_PANELS_HORIZONTAL_WEIGHTS: Dict[str, int] = {
    "map_tools": 20,  # Peso per il frame degli strumenti mappa
    "map_info": 35,  # Peso per il frame delle informazioni mappa
    "flight_details": 45,  # Peso per il frame dei dettagli del volo selezionato
}

# Finestra Principale
# Se True, la finestra tenta di avviarsi massimizzata.
# Se False, userà le dimensioni specificate sotto (se presenti) o quelle di default di Tkinter.
LAYOUT_START_MAXIMIZED: bool = True
# Dimensioni minime globali per la finestra (usate da root.minsize())
# Queste dovrebbero essere calcolate o stimate in base alla somma dei min_sizes dei componenti.
# Per ora, le lasciamo come valori fissi, ma potremmo renderle più dinamiche.
LAYOUT_WINDOW_MIN_WIDTH: int = 700
LAYOUT_WINDOW_MIN_HEIGHT: int = 500
