<?php

namespace App\Http\Controllers\Mail;

use App\Http\Controllers\Controller;

use DB;
use Illuminate\Http\Request;
use Illuminate\Support\Str;


class c_Mail_Body extends Controller
{
    private $Style_Base         = "display: block; height: auto; width: 100%; box-sizing: border-box; margin: 0px; padding: 5px 0px;";

    private $Style_Base_2       = "height: auto; border-box; margin: 0px; padding: 5px 0px;";
    private $Font_Family        = "Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, 'sans-serif'";

    private $Color_Primary      = "#f56a2a";
    private $Color_Secondary    = "#f56a2a";

    private $Color_White        = "#FCFCFC";
    private $Color_White_Light  = "#FFFFFF";
    private $Color_White_Dark   = "#F3F3F3";

    public $Color_Black     = "#777777";
    private $Color_Black_Light  = "#999999";
    private $Color_Black_Dark   = "#222222";

    private $Color_Blue         = "#007aff";
    private $Color_Green        = "#34c759";
    private $Color_Indigo       = "#5856d6";
    private $Color_Orange       = "#ff9500";
    private $Color_Pink         = "#ff2d55";
    private $Color_Purple       = "#af52de";
    private $Color_Red          = "#ff3b30";
    private $Color_Teal         = "#5ac8fa";
    private $Color_Yellow       = "#ffcc00";

    private $Padding            = "5px 20px";
    private $Margin             = "10px 0";


    public function Get_Body()
    {
        $Body = "
        <!doctype html>
        <html lang=\"es\">
        <head>
            <meta charset=\"UTF-8\">
            <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1.0\">
        </head> 
        <body style=\"background: $this->Color_White_Dark; padding: 30px 0;\">

            <table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"width=100%; max-width=600px\">
                <tbody>
                    <tr style=\"background: $this->Color_White\">
                        <td>
                            <img src=\"[[MEDIA_HEADER]]\" style=\"width: 100px; height: auto; \"/>
                        </td>
                    </tr>
                    <tr style=\"background: $this->Color_White\">
                        <td style=\"padding: 0;\">
                            [[CONTENT]]
                        </td>
                    </tr>
                    <tr>
                        <td>
                            
                        </td>
                    </tr>
                    <tr style=\"background: $this->Color_White_Dark;\">
                        <td>
                            <p style=\"$this->Style_Base padding: $this->Padding; font-family: $this->Font_Family; font-size: 12px; color: $this->Color_Black_Light; text-align: center;\">
                                © Salkantay Trekking.
                            </p>
                        </td>
                    </tr>
                </tbody>
            </table>

        </body>
        </html>
        ";

        return $Body;
    }
    // ----------para el booking----------------adjunto19/06/2025
    public function Get_Styles()
    {
        $Styles = "
        <style>
            .header-container{
                margin-bottom: 20px;
                width: 100%;
                background: #ffffff;
            }
            .header-container-first{
            }                
            .header-container-second{
    
                width: 200px;
            }
            .header-container-first-table{
            }
            .header-container-second-table{
                width: 100%;
            }
            .img-logo-table-header{
                width: 100px;
                height: auto;
            }
            .text-bookig-number-container{
                text-align: left;
                font-size: 16px;
            }
            .bookig-code{
                font-size: 24px;
                weight: bold;
                color: #F46E30;
                font-family: 'Roboto', sans-serif;
            }
            .bookig-code-text{
                color: #333333;
                font-size: 12px;
                font-family: 'Roboto', sans-serif;
                font-weight: 400;
            }
            .img-contact{
                width: 50px;
                height: auto;
            }
            .span-table-header{
                font-size: 16px;
                color: #333333;
                font-family: 'Roboto', sans-serif;
                font-weight: 900;
            }
            .img-passport{
                width: auto;
                height: 15px;
            }
            .img-passport-container{
                padding-top: 4px;
                padding-left: 16px;
            }
        </style>
        ";
        return $Styles;
    }
    public function Get_Booking_Body($reduce = 1)
    {
        $Body = "
        <!doctype html>
        <html lang=\"es\">
        <head>
            <meta charset=\"UTF-8\">
            <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1.0\">
            [[STYLES]]
        </head> 
        <body style=\"background: $this->Color_White; padding: 0px 0px;\">  

            <table class='header-container'  cellpadding='0' cellspacing='0' border='0'>
                <tr >
                    <!-- Elemento Izquierdo -->
                    <td align='left' class='header-container-first'>
                        <table class='header-container-first-table' >
                            <tr >
                                <!-- Elemento Izquierdo Logo-->
                                <td align='left' >
                                <img   class='img-logo-table-header' src='[[MEDIA_HEADER]]'  alt='Logo' style='display: block;'>
                                </td>

                                <!-- Elemento Derecho -->
                                <td align='left >
                                <span class='span-table-header'>[[BOOKING_CONFIRMATION]]</span>
                                </td>
                            </tr>
                        </table>
                    </td>

                    <!-- Elemento Derecho -->
                    <td align='right' class='header-container-second' >
                        <table class='header-container-second-table' >
                            <tr >
                                <!-- Elemento Izquierdo -->
                                <td align='left'>
                                <img   class='img-contact' src='[[MEDIA_HEADER_CONTACT]]'  alt='Logo' style='display: block;'>
                                </td>

                                <!-- Elemento Derecho -->
                                <td align='right' class='text-bookig-number-container'>
                                    <span class='bookig-code-text'>[[BOOKING_NUMBER]]</span>
                                    <div class='bookig-code' >[[BOOKING_CODE]]</div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <div style=\"" . ($reduce == 1 ? 'max-width: 600px; ' : '') . "margin: 0px auto;\">
            [[CONTENT]]
            </div>
        </body>
        </html>
        ";

        return $Body;
    }

    public function Get_H1($Text, $reduce = 1)
    {
        $Content = "
        <h1 style=\"$this->Style_Base padding: $this->Padding; font-family: $this->Font_Family; font-size: " . ($reduce * 22) .
            "px; font-weight: 600; color: $this->Color_Primary; text-align: center;\">
            $Text
        </h1>
        ";

        return $Content;
    }
    public function Get_H2($Text)
    {
        $Content = "
        <h2 style=\"$this->Style_Base padding: $this->Padding; font-family: $this->Font_Family; font-size: 18px; font-weight: 600; color: $this->Color_Primary; text-align: center;\">
            $Text
        </h2>
        ";

        return $Content;
    }
    public function Get_H3($Text)
    {
        $Content = "
        <h3 style=\"$this->Style_Base padding: $this->Padding; font-family: $this->Font_Family; font-size: 16px; font-weight: 600; color: $this->Color_Black_Dark; text-align: left;\">
            $Text
        </h3>
        ";

        return $Content;
    }
    public function Get_H4($Text)
    {
        $Content = "
        <h4 style=\"$this->Style_Base padding: $this->Padding; font-family: $this->Font_Family; font-size: 16px; font-weight: 600; color: $this->Color_Black_Dark; text-align: left;\">
            $Text
        </h4>
        ";

        return $Content;
    }
    public function Get_H4_2($Text)
    {
        $Content = "
        <span style=\"$this->Style_Base_2 padding: $this->Padding; font-family: $this->Font_Family; font-size: 16px; font-weight: 600; color: $this->Color_Black_Dark; text-align: left;\">
            $Text
        </span>
        ";

        return $Content;
    }
    public function Get_P($Text, $Align, $reduce = 1)
    {
        switch ($Align) {
            case "RIGHT":
                $Content_Align = "text-align: right";
                break;
            case "LEFT":
                $Content_Align = "text-align: left";
                break;
            case "CENTER":
                $Content_Align = "text-align: center";
                break;
            case "JUSTIFY":
                $Content_Align = "text-align: justify";
                break;
            default:
                $Content_Align = "text-align: left";
                break;
        }

        $Content = "
        <p style=\"$this->Style_Base line-height: 1.5; padding: $this->Padding; font-family: $this->Font_Family; font-size: " .
            ($reduce * 13) . "px; color: $this->Color_Black; $Content_Align\">
            $Text
        </p>
        ";

        return $Content;
    }

    public function Get_Cell($Text)
    {
        $Content = "
        <td style=\"border: 1px solid black; line-height: 1.5; padding: 5px 10px; font-size: 13px; color: $this->Color_Black_Dark;\">
            $Text
        </td>
        ";

        return $Content;
    }

    public function Get_Head($Text)
    {
        $Content = "
        <th style=\"border: 1px solid black; line-height: 1.5; padding: 5px 10px; font-family: $this->Font_Family; font-size: 16px; color: $this->Color_Black_Dark;\">
            $Text
        </th>
        ";

        return $Content;
    }

    public function Get_Br()
    {
        return '<br />';
    }

    public function Get_Table($heads, $headFunction, $rows, $rowFunction, $colFunction)
    {

        $heads = '<tr >' . implode(
            '',
            array_map(
                function ($head) use ($headFunction) {
                    return $headFunction($head);
                },
                $heads
            )
        ) . '</tr>';

        $rows = implode(
            '',
            array_map(
                function ($row) use ($rowFunction, $colFunction) {
                    return '<tr>' . implode(' ', array_map($colFunction, $rowFunction($row))) . '</tr>';
                },
                $rows
            )
        );

        return "<table style=\"border: 1px solid black; width: 100%; border-collapse: collapse; $this->Style_Base 
                font-family: $this->Font_Family;
                font-size: 16px; font-weight: 600; color: $this->Color_Black_Dark; text-align: left;padding: 0px 40px; display: table; \">$heads $rows</table>";
    }

    public function Get_List($elements, $function)
    {

        $elements = array_map($function, $elements);
        $elements = implode(
            ' ',
            array_map(
                function ($ele) {
                    return "<li style=\"$this->Style_Base list-style:none\">$ele</li>";
                },
                $elements
            )
        );

        $Content = "<ul>$elements</ul>";
        return $Content;
    }
}
