@extends('layouts.yellow')
@section('content')
<style>
    .recurring-details-container {
        padding: 1.5rem;
    }
    
    .page-header {
        background: linear-gradient(135deg, #4A90E2 0%, #2A4E6D 100%);
        border-radius: 12px;
        padding: 1.5rem;
        margin-bottom: 1.5rem;
        color: white;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    
    .page-header h2 {
        margin: 0;
        font-weight: 600;
    }
    
    .details-card {
        background: white;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
        margin-bottom: 1.5rem;
    }
    
    .card-header {
        background-color: #f8fafc;
        padding: 1.25rem;
        border-bottom: 1px solid #edf2f7;
    }
    
    .card-header h4 {
        margin: 0;
        color: #2d3748;
        font-weight: 600;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    .info-item {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
        border-bottom: 1px solid #edf2f7;
    }
    
    .info-item:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }
    
    .info-label {
        color: #718096;
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
    }
    
    .info-value {
        color: #2d3748;
        font-weight: 600;
        font-size: 1.05rem;
    }
    
    .badge-custom {
        padding: 0.35rem 0.75rem;
        border-radius: 50px;
        font-weight: 500;
        font-size: 0.85rem;
    }
    
    .badge-success {
        background-color: rgba(46, 182, 125, 0.15);
        color: #2eb67d;
    }
    
    .badge-secondary {
        background-color: rgba(160, 174, 192, 0.15);
        color: #718096;
    }
    
    .badge-primary {
        background-color: rgba(74, 144, 226, 0.15);
        color: #4A90E2;
    }
    
    .badge-danger {
        background-color: rgba(227, 52, 47, 0.15);
        color: #e3342f;
    }
    
    .badge-warning {
        background-color: rgba(255, 193, 7, 0.15);
        color: #ffc107;
    }
    
    .appointment-date {
        display: inline-block;
        background-color: rgba(74, 144, 226, 0.1);
        padding: 0.75rem 1rem;
        border-radius: 8px;
        color: #4A90E2;
        font-weight: 600;
        margin-top: 0.5rem;
    }
    
    .actions-container {
        display: flex;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .btn-custom {
        padding: 0.65rem 1.5rem;
        border-radius: 8px;
        font-weight: 500;
        transition: all 0.2s;
    }
    
    .btn-custom:hover {
        transform: translateY(-3px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    
    .btn-primary-custom {
        background: linear-gradient(135deg, #4A90E2 0%, #3B6EA5 100%);
        border: none;
        color: white;
    }
    
    .btn-secondary-custom {
        background-color: #f7fafc;
        border: 1px solid #edf2f7;
        color: #4a5568;
    }
    
    .btn-danger-custom {
        background-color: rgba(227, 52, 47, 0.1);
        border: none;
        color: #e3342f;
    }
    
    .btn-danger-custom:hover {
        background-color: #e3342f;
        color: white;
    }
    
    .description-box {
        background-color: #f7fafc;
        border-radius: 8px;
        padding: 1rem;
        border-left: 3px solid #4A90E2;
    }
    
    .icon-circle {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: rgba(74, 144, 226, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #4A90E2;
        margin-right: 1rem;
    }
</style>

<div class="container-fluid recurring-details-container">
    <div class="row">
        <div class="col-12">
            <div class="page-header d-flex justify-content-between align-items-center">
                <div class="d-flex align-items-center">
                    <i class="bi bi-calendar-check me-3 fs-3"></i>
                    <h2>{{ __('recurring-appointments.titleShow') }}</h2>
                </div>
            </div>
        </div>
    </div>

    @if(session('success'))
    <div class="row mb-3">
        <div class="col-12">
            <div class="alert alert-success alert-dismissible fade show">
                <i class="bi bi-check-circle me-2"></i>
                {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        </div>
    </div>
    @endif

    <div class="row">
        <div class="col-md-6">
            <div class="details-card">
                <div class="card-header d-flex align-items-center">
                    <div class="icon-circle">
                        <i class="bi bi-person"></i>
                    </div>
                    <h4>{{ __('recurring-appointments.patient') }} & {{ __('recurring-appointments.doctor') }}</h4>
                </div>
                <div class="card-body">
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-person me-2"></i>
                            {{ __('recurring-appointments.patient') }}
                        </div>
                        <div class="info-value">
                            {{ $recurringAppointment->patient->firstname }} {{ $recurringAppointment->patient->lastname }}
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-person-badge me-2"></i>
                            {{ __('recurring-appointments.doctor') }}
                        </div>
                        <div class="info-value">
                            {{ $recurringAppointment->doctor->name }}
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-clipboard-pulse me-2"></i>
                            {{ __('recurring-appointments.especiality') }}
                        </div>
                        <div class="info-value">
                            {{ $recurringAppointment->especialityRelation->name }}
                        </div>
                    </div>
                </div>
            </div>

            <div class="details-card">
                <div class="card-header d-flex align-items-center">
                    <div class="icon-circle">
                        <i class="bi bi-calendar-range"></i>
                    </div>
                    <h4>{{ __('recurring-appointments.scheduleSettings') }}</h4>
                </div>
                <div class="card-body">
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-calendar-plus me-2"></i>
                            {{ __('recurring-appointments.daysInterval') }}
                        </div>
                        <div class="info-value">
                            <span class="badge badge-primary">
                                {{ $recurringAppointment->days_interval }} {{ __('recurring-appointments.days') }}
                            </span>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-bell me-2"></i>
                            {{ __('recurring-appointments.reminderDays') }}
                        </div>
                        <div class="info-value">
                            <span class="badge badge-primary">
                                {{ $recurringAppointment->reminder_days }} {{ __('recurring-appointments.days') }}
                            </span>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-toggles me-2"></i>
                            {{ __('recurring-appointments.autoSchedule') }}
                        </div>
                        <div class="info-value">
                            <span class="badge {{ $recurringAppointment->auto_schedule ? 'badge-success' : 'badge-secondary' }}">
                                <i class="bi {{ $recurringAppointment->auto_schedule ? 'bi-check-circle' : 'bi-x-circle' }} me-1"></i>
                                {{ $recurringAppointment->auto_schedule ? __('recurring-appointments.yes') : __('recurring-appointments.no') }}
                            </span>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-power me-2"></i>
                            {{ __('recurring-appointments.status') }}
                        </div>
                        <div class="info-value">
                            <span class="badge {{ $recurringAppointment->is_active ? 'badge-success' : 'badge-danger' }}">
                                <i class="bi {{ $recurringAppointment->is_active ? 'bi-check-circle' : 'bi-x-circle' }} me-1"></i>
                                {{ $recurringAppointment->is_active ? __('recurring-appointments.active') : __('recurring-appointments.inactive') }}
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="col-md-6">
            <div class="details-card">
                <div class="card-header d-flex align-items-center">
                    <div class="icon-circle">
                        <i class="bi bi-calendar-event"></i>
                    </div>
                    <h4>{{ __('recurring-appointments.nextAppointment') }}</h4>
                </div>
                <div class="card-body">
                    @php
                        $daysUntil = \Carbon\Carbon::now()->startOfDay()->diffInDays(\Carbon\Carbon::parse($recurringAppointment->next_appointment_date)->startOfDay(), false);
                        $isPast = \Carbon\Carbon::parse($recurringAppointment->next_appointment_date)->isPast();
                        $isClose = $daysUntil <= $recurringAppointment->reminder_days && !$isPast;
                    @endphp
                    
                    <div class="text-center mb-3">
                        <div class="appointment-date">
                            <i class="bi bi-calendar3 me-2"></i>
                            {{ \Carbon\Carbon::parse($recurringAppointment->next_appointment_date)->format('d/m/Y') }}
                        </div>
                    </div>
                    
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-clock-history me-2"></i>
                            {{ __('recurring-appointments.timeRemaining') }}
                        </div>
                        <div class="info-value">
                            <span class="badge {{ $isPast ? 'badge-danger' : ($isClose ? 'badge-warning' : 'badge-success') }}">
                                <i class="bi {{ $isPast ? 'bi-exclamation-circle' : 'bi-clock' }} me-1"></i>
                                {{ \Carbon\Carbon::parse($recurringAppointment->next_appointment_date)->diffForHumans() }}
                                @if(!$isPast)
                                ({{ $daysUntil }} {{ __('recurring-appointments.days') }})
                                @endif
                            </span>
                        </div>
                    </div>
                    
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-envelope me-2"></i>
                            {{ __('recurring-appointments.notificationStatus') }}
                        </div>
                        <div class="info-value">
                            <span class="badge {{ $recurringAppointment->notification_sent ? 'badge-success' : 'badge-secondary' }}">
                                <i class="bi {{ $recurringAppointment->notification_sent ? 'bi-check-circle' : 'bi-clock' }} me-1"></i>
                                {{ $recurringAppointment->notification_sent ? __('recurring-appointments.notificationSent') : __('recurring-appointments.notificationPending') }}
                            </span>
                        </div>
                    </div>
                    
                    <div class="info-item">
                        <div class="info-label">
                            <i class="bi bi-calendar-week me-2"></i>
                            {{ __('recurring-appointments.originalDate') }}
                        </div>
                        <div class="info-value">
                            {{ \Carbon\Carbon::parse($recurringAppointment->originalAppointment->date)->format('d/m/Y H:i') }}
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="details-card">
                <div class="card-header d-flex align-items-center">
                    <div class="icon-circle">
                        <i class="bi bi-pencil"></i>
                    </div>
                    <h4>{{ __('recurring-appointments.description') }}</h4>
                </div>
                <div class="card-body">
                    @if($recurringAppointment->description)
                    <div class="description-box">
                        {{ $recurringAppointment->description }}
                    </div>
                    @else
                    <p class="text-muted fst-italic">{{ __('recurring-appointments.noDescription') }}</p>
                    @endif
                </div>
            </div>
        </div>
    </div>
    
    <div class="actions-container">
        <a href="{{ route('recurring-appointments.index') }}" class="btn btn-secondary-custom btn-custom">
            <i class="bi bi-arrow-left me-2"></i>
            {{ __('recurring-appointments.back') }}
        </a>
        <a href="{{ route('recurring-appointments.edit', $recurringAppointment->id) }}" class="btn btn-primary-custom btn-custom">
            <i class="bi bi-pencil me-2"></i>
            {{ __('recurring-appointments.edit') }}
        </a>
        <form action="{{ route('recurring-appointments.cancel', $recurringAppointment->id) }}" method="POST" class="d-inline" onsubmit="return confirm('{{ __('recurring-appointments.confirmCancel') }}');">
            @csrf
            @method('DELETE')
            <button type="submit" class="btn btn-danger-custom btn-custom">
                <i class="bi bi-x-circle me-2"></i>
                {{ __('recurring-appointments.delete') }}
            </button>
        </form>
    </div>
</div>
@endsection 