@extends('dashboard.user.layouts.app')
@section('content')
    <div class="page-container">

        <div class="page-title-head d-flex align-items-sm-center flex-sm-row flex-column gap-2">
            <div class="flex-grow-1">
                <h4 class="fs-18 fw-semibold mb-0">{{ $title }}</h4>
            </div>

            <div class="text-end">
                <x-dashboard.user.breadcrumbs :breadcrumbs="$breadcrumbs" />
            </div>
        </div>

        <div class="row">
            <div class="col-xl-12 col-lg-12">
                <x-dashboard.admin.card>

                    @slot('header')
                        User {{ $title }}
                    @endslot

                    {{-- ── DESKTOP TABLE (lg and above) ── --}}
                    <div class="table-responsive d-none d-lg-block">
                        <table id="myTable" class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Title</th>
                                    <th>Priority</th>
                                    <th>Description</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($supports as $support)
                                    <tr>
                                        <td>{{ $loop->iteration }}</td>
                                        <td>{{ $support->title }}</td>
                                        <td>{{ $support->priority }}</td>
                                        <td>{{ $support->description }}</td>
                                        <td>{{ $support->status }}</td>
                                        <td>
                                            <a href="{{ route('user.support.show', $support->uuid) }}"
                                                class="btn btn-warning btn-sm">
                                                <i class="ti ti-eye me-1"></i> View
                                            </a>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>

                    {{-- ── MOBILE / TABLET CARDS (below lg) ── --}}
                    <div class="d-lg-none">
                        @foreach ($supports as $support)
                            <div class="spt-card border rounded-3 p-3 mb-3 spt-card--{{ strtolower($support->priority) }}">

                                {{-- Top row: index + status --}}
                                <div class="d-flex justify-content-between align-items-center mb-2">
                                    <span class="txn-index-badge">#{{ $loop->iteration }}</span>
                                    <span class="badge rounded-pill px-3 py-1 spt-status" style="font-size:.7rem;">
                                        {{ $support->status }}
                                    </span>
                                </div>

                                {{-- Title --}}
                                <p class="fw-semibold mb-1" style="font-size:.9rem;">{{ $support->title }}</p>

                                {{-- Priority --}}
                                <div class="mb-2">
                                    <span class="spt-priority-chip spt-priority--{{ strtolower($support->priority) }}">
                                        <span class="spt-priority-dot"></span>
                                        {{ $support->priority }} Priority
                                    </span>
                                </div>

                                {{-- Description --}}
                                <p class="text-muted mb-3" style="font-size:.82rem;line-height:1.6;">
                                    {{ $support->description }}
                                </p>

                                {{-- Action --}}
                                <a href="{{ route('user.support.show', $support->uuid) }}"
                                    class="btn btn-warning btn-sm w-100 d-inline-flex align-items-center justify-content-center gap-1">
                                    <i class="ti ti-eye"></i> View Ticket
                                </a>

                            </div>
                        @endforeach
                    </div>

                </x-dashboard.admin.card>

                <style>
                    .spt-card {
                        /* background: #fff; */
                        transition: box-shadow .15s;
                        border-left-width: 3px !important;
                    }

                    .spt-card:hover {
                        box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
                    }

                    /* Priority left-border accent */
                    .spt-card--high {
                        border-left-color: #dc3545 !important;
                    }

                    .spt-card--medium {
                        border-left-color: #ffc107 !important;
                    }

                    .spt-card--low {
                        border-left-color: #198754 !important;
                    }

                    /* Priority chip */
                    .spt-priority-chip {
                        display: inline-flex;
                        align-items: center;
                        gap: .35rem;
                        font-size: .7rem;
                        font-weight: 600;
                        letter-spacing: .04em;
                        text-transform: uppercase;
                        padding: .2rem .65rem;
                        border-radius: 20px;
                    }

                    .spt-priority-dot {
                        width: 6px;
                        height: 6px;
                        border-radius: 50%;
                        flex-shrink: 0;
                    }

                    .spt-priority--high .spt-priority-chip,
                    .spt-card--high .spt-priority-chip {
                        background: #fff1f2;
                        color: #dc3545;
                    }

                    .spt-card--high .spt-priority-dot {
                        background: #dc3545;
                    }

                    .spt-card--medium .spt-priority-chip {
                        background: #fffbea;
                        color: #b45309;
                    }

                    .spt-card--medium .spt-priority-dot {
                        background: #ffc107;
                    }

                    .spt-card--low .spt-priority-chip {
                        background: #f0faf4;
                        color: #198754;
                    }

                    .spt-card--low .spt-priority-dot {
                        background: #198754;
                    }

                    /* Status badge — neutral fallback; inherits whatever class the backend adds */
                    .spt-status {
                        background: #f1f3f5;
                        color: #495057;
                    }

                    .txn-index-badge {
                        font-size: .72rem;
                        font-weight: 700;
                        background: #f1f3f5;
                        color: #6c757d;
                        border-radius: 6px;
                        padding: 2px 7px;
                    }
                </style>
            </div>
        </div>
    </div>
@endsection
