import sys
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QPushButton
from PyQt6.QtCore import Qt, QPropertyAnimation, QEasingCurve, pyqtProperty
from PyQt6.QtGui import QFont, QColor, QPalette

GREETINGS = [
    "Hello, World.", "Hey there!", "Howdy 🤠", "Bonjour!", "Ciao!",
    "¡Hola!", "Konnichiwa!", "Hallo!", "Olá!", "Salut!",
    "Ahoy! 🏴‍☠️", "Greetings!", "Yo! 👋", "Sup?", "Hi, friend."
]


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.count = 0
        self.setWindowTitle("Hello World")
        self.setFixedSize(480, 300)
        self._setup_ui()
        self._apply_dark_theme()

    def _setup_ui(self):
        central = QWidget()
        self.setCentralWidget(central)

        layout = QVBoxLayout(central)
        layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
        layout.setSpacing(24)
        layout.setContentsMargins(48, 48, 48, 48)

        # Greeting label
        self.label = QLabel("Hello, World.")
        self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.label.setFont(QFont("Georgia", 36, QFont.Weight.Bold))
        self.label.setStyleSheet("color: #e8d5a3; letter-spacing: 1px;")

        # Click button
        self.button = QPushButton("Click me")
        self.button.setFixedSize(160, 44)
        self.button.setFont(QFont("Menlo", 12))
        self.button.setCursor(Qt.CursorShape.PointingHandCursor)
        self.button.setStyleSheet("""
            QPushButton {
                background: transparent;
                color: #c9a96e;
                border: 1px solid #c9a96e;
                border-radius: 4px;
                letter-spacing: 2px;
            }
            QPushButton:hover {
                background: #c9a96e;
                color: #0d0d0d;
            }
            QPushButton:pressed {
                background: #a8893e;
                border-color: #a8893e;
                color: #0d0d0d;
            }
        """)
        self.button.clicked.connect(self.handle_click)

        # Counter label
        self.counter = QLabel("0 clicks")
        self.counter.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.counter.setFont(QFont("Menlo", 11))
        self.counter.setStyleSheet("color: #555;")

        layout.addWidget(self.label)
        layout.addWidget(self.button, alignment=Qt.AlignmentFlag.AlignCenter)
        layout.addWidget(self.counter)

    def _apply_dark_theme(self):
        self.setStyleSheet("""
            QMainWindow, QWidget {
                background-color: #0d0d0d;
            }
        """)

    def handle_click(self):
        self.count += 1
        self.label.setText(GREETINGS[self.count % len(GREETINGS)])
        self.counter.setText(f"{self.count} click{'s' if self.count != 1 else ''}")

        # Quick pulse animation via stylesheet swap
        self.label.setStyleSheet("color: #ffffff; letter-spacing: 1px;")
        QApplication.processEvents()
        self.label.setStyleSheet("color: #e8d5a3; letter-spacing: 1px;")


if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setStyle("macos")
    window = MainWindow()
    window.show()
    sys.exit(app.exec())
