@extends('layouts.yellow')
@section('content')
<style>
    :root {
        --azul-primario: #2A4E6D;
        --azul-secundario: #3B6EA5;
        --azul-destacado: #4A90E2;
        --azul-suave: #E3F2FD;
        --degradado-azul: linear-gradient(135deg, #4A90E2 0%, #2A4E6D 100%);
        --amarillo-primario: #FFD54F;
        --amarillo-secundario: #FFECB3;
        --naranja-destacado: #FF9800;
        --verde-exito: #4CAF50;
        --rojo-error: #F44336;
        --gris-claro: #F5F7FA;
        --gris-medio: #E1E5E9;
        --gris-oscuro: #6C757D;
        --borde-principal: #D0D7DE;
        --sombra-suave: 0 4px 12px rgba(0, 0, 0, 0.05);
        --sombra-media: 0 6px 16px rgba(0, 0, 0, 0.08);
        --sombra-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
        --transicion: all 0.3s ease;
        --fuente-principal: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .email-container {
        font-family: var(--fuente-principal);
        animation: fadeIn 0.5s ease-out;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .email-header {
        background: var(--degradado-azul);
        color: white;
        padding: 1.5rem 2rem;
        border-radius: 12px;
        box-shadow: var(--sombra-media);
        position: relative;
        overflow: hidden;
        margin-bottom: 1.5rem;
    }

    .email-header::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        width: 150px;
        height: 100%;
        background: rgba(255, 255, 255, 0.1);
        clip-path: polygon(100% 0, 0 0, 100% 100%);
    }

    .email-header h2 {
        margin: 0;
        font-weight: 600;
        display: flex;
        align-items: center;
    }

    .email-header h2:before {
        content: "\f0e0";
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        margin-right: 10px;
    }

    .email-table-container {
        background: white;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: var(--sombra-media);
    }

    .table-custom {
        background: var(--degradado-azul);
    }

    .table-custom th {
        color: white;
        font-weight: 600;
        padding: 1.2rem 1rem;
        border-bottom: none !important;
        font-size: 0.95rem;
        text-transform: uppercase;
    }

    .table-striped tbody tr:nth-of-type(odd) {
        background-color: var(--gris-claro);
    }

    .table-striped tbody tr {
        transition: var(--transicion);
    }

    .table-striped tbody tr:hover {
        background-color: var(--azul-suave);
        transform: translateY(-2px);
        box-shadow: var(--sombra-suave);
    }

    .table-striped td {
        padding: 1rem;
        vertical-align: middle;
        border-color: var(--borde-principal);
        color: var(--azul-primario);
    }

    .btn-primary {
        background: var(--degradado-azul);
        color: white !important;
        border: none;
        padding: 0.5rem 1.2rem;
        border-radius: 50px;
        transition: var(--transicion);
        font-weight: 500;
    }

    .btn-primary:hover {
        transform: translateY(-3px);
        box-shadow: var(--sombra-hover);
    }

    .pagination {
        margin-top: 1.5rem;
    }

    .pagination .page-link {
        color: var(--azul-primario);
        border: 1px solid var(--borde-principal);
        transition: var(--transicion);
    }

    .pagination .page-item.active .page-link {
        background: var(--degradado-azul);
        border-color: var(--azul-destacado);
        color: white;
    }

    .pagination .page-link:hover {
        background-color: var(--azul-suave);
        color: var(--azul-primario);
        transform: translateY(-2px);
        box-shadow: var(--sombra-suave);
    }

    @media (max-width: 768px) {
        .table-wrapper {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        
        .table-custom th,
        .table-striped td {
            padding: 0.75rem;
            font-size: 0.9rem;
        }
        
        .btn-primary {
            padding: 0.4rem 1rem;
            font-size: 0.85rem;
        }
    }
</style>

<div class="container-fluid email-container">
    <div class="row">
        <div class="col-12">
            <div class="email-header">
                <h2>{{ __('common-table.titleViewEmailOut') }}</h2>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-12">
            <div class="email-table-container">
                <div class="table-wrapper">
                    <table class="table table-striped">
                        <thead class="table-custom">
                            <tr>
                                <th scope="col">#</th>
                                <th scope="col">Asunto</th>
                                <th scope="col">Destinatario</th>
                                <th scope="col">Fecha</th>
                                <th scope="col">Acción</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($paginator as $index => $message)
                                <tr>
                                    <th scope="row">{{ $loop->iteration }}</th>
                                    <td>{{ imap_utf8($message->getSubject()) }}</td>
                                    <td>
                                        @if(is_array($message->getTo()))
                                            @foreach($message->getTo() as $sender)
                                                {{ $sender->mail }}<br>
                                            @endforeach
                                        @else
                                            {{ $message->getTo() }}
                                        @endif
                                    </td>
                                    <td>{{ $message->getDate() }}</td>
                                    <td>
                                        <a href="{{ route('/admin/check-email-out', ['id' => $message->getUid()]) }}" class="btn btn-primary">
                                            <i class="fas fa-eye me-1"></i> Ver
                                        </a>
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>

                <!-- Agregar paginación -->
                <div class="d-flex justify-content-center pagination-container">
                    {{ $paginator->links() }}
                </div>
            </div>
        </div>
    </div>
</div>

@push('styles')
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
@endpush
@endsection
