@extends('layouts.app')

@section('content')
<div class="container mt-4">
    @if(session('success'))
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            {{ session('success') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    @endif

    <h4 class="mb-4">Faculty Profile</h4>

    <div class="card shadow-sm p-4">
        <div class="row align-items-center mb-3">
            <div class="col-md-2 text-center">
                @if($profile->profile_photo_path)
                    <img src="{{ Storage::url($profile->profile_photo_path) }}"
                         alt="Profile Photo"
                         class="rounded-circle shadow-sm"
                         width="120" height="120">
                @else
                    <img src="{{ asset('assets/frontend/images/default-avatar.png') }}"
                         alt="Default Photo"
                         class="rounded-circle shadow-sm"
                         width="120" height="120">
                @endif
            </div>
            <div class="col-md-10">
                <h5 class="fw-bold mb-1">{{ $profile->salutation }} {{ $profile->name }}</h5>
                <p class="mb-0"><strong>{{ $profile->designation }}</strong></p>
                <p class="text-muted mb-0">{{ $profile->department_name }} — {{ $profile->programme_name }}</p>

                {{-- Compact links row --}}
                <div class="mt-2 text-md-start text-center">
                    @if($profile->google_scholar_id)
                        <a href="{{ $profile->google_scholar_id }}" target="_blank" rel="noopener noreferrer"
                           class="btn btn-outline-primary btn-sm me-2">
                            <i class="fa fa-graduation-cap me-1"></i> Scholar
                        </a>
                    @endif

                    @if($profile->vidhwan_id)
                        <a href="https://vidwan.inflibnet.ac.in/profile/{{ $profile->vidhwan_id }}"
                           target="_blank" rel="noopener noreferrer"
                           class="btn btn-outline-secondary btn-sm me-2">
                            <i class="fa fa-id-card me-1"></i> Vidhwan
                        </a>
                    @endif

                    @if($profile->linkedin_id)
                        <a href="{{ $profile->linkedin_id }}" target="_blank" rel="noopener noreferrer"
                           class="btn btn-outline-info btn-sm">
                            <i class="fa fa-linkedin"></i> LinkedIn
                        </a>
                    @endif
                </div>
            </div>
        </div>

        <hr>

        <div class="row">
            <div class="col-md-6">
                <p><strong>Email:</strong> {{ $profile->email }}</p>
                <p><strong>Phone:</strong> {{ $profile->phone_number ?: 'N/A' }}</p>
                <p><strong>Employee ID:</strong> {{ $profile->employee_id ?: 'N/A' }}</p>
                <p><strong>Date of Joining:</strong>
                    {{ $profile->date_of_joining ? $profile->date_of_joining->format('d M Y') : 'N/A' }}
                </p>
            </div>

            <div class="col-md-6">
                <p><strong>Qualification:</strong>
                    {{ is_array($profile->qualification) ? implode(', ', $profile->qualification) : ($profile->qualification ?: 'N/A') }}
                </p>
                <p><strong>Address:</strong> {{ $profile->address ?: 'N/A' }}</p>
                <p><strong>Vidhwan ID:</strong> {{ $profile->vidhwan_id ?: 'N/A' }}</p>
            </div>
        </div>

        <div class="text-end mt-3">
            <a href="{{ route('faculty.profile.edit') }}" class="btn btn-primary">
                <i class="fa fa-pen me-1"></i> Edit Profile
            </a>
        </div>
    </div>
</div>
@endsection
