from django.shortcuts import render,redirect
from django.core.mail import send_mail
from django.conf import settings

def home(request):
    rooms = [
        {
            "title": "Suite Room",
            "desc": "A cozy room with modern amenities...",
            "price": 7000,
            "images": ["img/room/suite1.jpg", "img/room/suite3.jpg"],
            "features": [
                {"icon": "flaticon-019-television", "name": "Smart TV"},
                {"icon": "flaticon-029-wifi", "name": "Wi-Fi"},
                {"icon": "flaticon-036-parking", "name": "Parking"},

            ],
            "link": "#"
        },
        {
            "title": "Deluxe Room",
            "desc": "A spacious room with elegant design...",
            "price": 5000,
            "images": ["img/room/suite2.jpg", "img/room/deluxe2.jpg"],
            "features": [
                {"icon": "flaticon-019-television", "name": "Smart TV"},
                {"icon": "flaticon-029-wifi", "name": " Wi-Fi"},
                {"icon": "flaticon-036-parking", "name": " Parking"},
            ],
            "link": "#"
        },
        
    ]

    return render(request, 'index.html', {'rooms': rooms})


def about(request):
    return render(request, 'about.html')



def rooms(request): 
    rooms = [
        {
            "title": "Suite Room",
            "desc": "A cozy room with modern amenities...",
            "price": 7000,
            "images": ["img/room/suite1.jpg", "img/room/suite3.jpg"],
            # "features": [
            #     {"icon": "flaticon-019-television", "name": "Smart TV"},
            #     {"icon": "flaticon-029-wifi", "name": "Wi-Fi"},
            #     {"icon": "flaticon-003-air-conditioner", "name": "AC"},
            #     {"icon": "flaticon-036-parking", "name": "Parking"},
            # ],
            "link": "#"
        },
        {
            "title": "Deluxe Room",
            "desc": "Spacious room with deluxe features...",
            "price": 5000,
            "images": ["img/room/suite2.jpg", "img/room/deluxe2.jpg"],
            # "features": [
            #     # {"icon": "flaticon-019-television", "name": "Smart TV"},
            #     # {"icon": "flaticon-029-wifi", "name": "Wi-Fi"},
            #     # {"icon": "flaticon-003-air-conditioner", "name": "AC"},
            #     # {"icon": "flaticon-036-parking", "name": "Parking"},
            # ],
            "link": "#"
        },

        
    ]

    return render(request, 'rooms.html', {'rooms': rooms})


def news(request):
    return render(request, 'news.html')

def contact(request):
    return render(request, 'contact.html')

def delux(request):
    return render(request, 'delux.html')

def suite(request):
    return render(request, 'suite.html')



# def blog_search(request):
#     query = request.GET.get('q', '')
#     results = BlogPost.objects.filter(title__icontains=query) if query else []
#     return render(request, 'search_results.html', {'results': results, 'query': query})

def nearest_attraction(request):
    attractions = [
        {
            "title": "Vagamon Pine Forest",
            "img": "img/1.jpeg",
            "desc": "A serene and dense forest of pine trees offering peaceful walks and photography.",
            "map": "https://www.google.com/maps?q=9.8256,76.9474&z=17",
            "dist": "1.5 km"
        },
        {
            "title": "Vagamon Meadows",
            "img": "img/2.jpeg",
            "desc": "Rolling green hills and perfect picnic spots with breathtaking views.",
            "map": "https://www.google.com/maps?q=9.8301,76.9385&z=17",
            "dist": "3 km"
        },
        {
            "title": "Thangal Para",
            "img": "img/3.jpeg",
            "desc": "A sacred Muslim pilgrimage site situated on top of a hill with panoramic views.",
            "map": "https://www.google.com/maps?q=9.8415,76.9448&z=17",
            "dist": "4 km"
        },
        {
            "title": "Kurisumala",
            "img": "img/4.jpeg",
            "desc": "A famous Christian pilgrimage hill with 14 crosses and spiritual walking path.",
            "map": "https://www.google.com/maps?q=9.8420,76.9471&z=17",
            "dist": "2.5 km"
        },
        {
            "title": "Paragliding Point",
            "img": "img/5.jpeg",
            "desc": "Fly over the hills of Vagamon with certified instructors. A must-try for adventure seekers!",
            "map": "https://www.google.com/maps?q=9.8323,76.9392&z=17",
            "dist": "5 km"
        },
        {
            "title": "Off-road Trails",
            "img": "img/6.jpeg",
            "desc": "Thrilling off-road jeep rides through the rugged terrains and hills of Vagamon.",
            "map": "https://www.google.com/maps?q=9.8372,76.9433&z=17",
            "dist": "3.8 km"
        }
    ]
    return render(request, 'attractions.html', {'attractions': attractions})



def terms_conditions(request):
    return render(request,"terms_conditions.html")


def privacy_policy(request):
    return render(request,"privacy_policy.html")

def refund_policy(request):
    return render(request,"refund_policy.html")

def send_message(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        email = request.POST.get('email')
        phone = request.POST.get('phone')
        message = request.POST.get('message')

        full_message = f"Name: {name}\nEmail: {email}\nPhone: {phone}\n\nMessage:\n{message}"

        send_mail(
            subject=f"New Contact Message from {name}",
            message=full_message,
            from_email=settings.DEFAULT_FROM_EMAIL,
            recipient_list=['info@vagavista.com'],
        )
        return redirect('thank_you') 

    return redirect('contact')

