<%@ Page Title="Compartidos Conmigo" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="SharedDocuments.aspx.cs" Inherits="PDI.Web.SharedDocumentsPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style>
        .shared-section { margin-bottom: 2rem; }
        .shared-section h3 {
            font-size: 1.05rem;
            color: #6D214F;
            margin: 0 0 0.75rem 0;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .shared-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.9rem;
        }
        .shared-table thead tr {
            background: var(--wine-dark, #5a1a3a);
            color: #fff;
        }
        .shared-table th {
            padding: 8px 12px;
            text-align: left;
            font-weight: 600;
        }
        .shared-table td {
            padding: 8px 12px;
            border-bottom: 1px solid #eee;
        }
        .shared-table tbody tr:hover {
            background-color: #faf5f8;
        }
        .shared-table .action-link {
            color: #6D214F;
            text-decoration: none;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
        }
        .shared-table .action-link:hover {
            text-decoration: underline;
        }
        .empty-message {
            display: block;
            text-align: center;
            color: #999;
            padding: 1rem 0;
            font-size: 0.9rem;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <section id="page-shared-documents" class="page">
        <h2>Compartidos Conmigo</h2>

        <!-- Shared Folders Section -->
        <div class="shared-section">
            <h3><i class="fas fa-folder-open"></i> Carpetas</h3>
            <asp:Repeater ID="rptSharedHierarchies" runat="server">
                <HeaderTemplate>
                    <table class="shared-table">
                        <thead>
                            <tr>
                                <th>Nombre de la Carpeta</th>
                                <th>Compartido Por</th>
                                <th>Fecha</th>
                                <th>Acciones</th>
                            </tr>
                        </thead>
                        <tbody>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td><i class="fas fa-folder" style="color:#6D214F; margin-right:6px;"></i><%# Eval("Hierarchies.Name") %></td>
                        <td><%# Eval("Users1.FullName") %></td>
                        <td><%# Eval("Created", "{0:yyyy-MM-dd HH:mm}") %></td>
                        <td>
                            <a href='<%# "SharedHierarchyViewer.aspx?ID=" + Eval("ShareLink") %>' target="_blank" class="action-link"><i class="fas fa-eye"></i> Ver</a>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                        </tbody>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Label ID="lblEmptyFolders" runat="server" Text="No hay carpetas compartidas." Visible="false" CssClass="empty-message" />
        </div>

        <!-- Shared Documents Section -->
        <div class="shared-section">
            <h3><i class="fas fa-file-alt"></i> Documentos</h3>
            <asp:Repeater ID="rptSharedDocuments" runat="server">
                <HeaderTemplate>
                    <table class="shared-table">
                        <thead>
                            <tr>
                                <th>Nombre del Documento</th>
                                <th>Compartido Por</th>
                                <th>Fecha</th>
                                <th>Acciones</th>
                            </tr>
                        </thead>
                        <tbody>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td><i class="fas fa-file-pdf" style="color:#c0392b; margin-right:6px;"></i><%# Eval("Documents.UserFilename") ?? Eval("Documents.Id").ToString() %></td>
                        <td><%# Eval("Users.FullName") %></td>
                        <td><%# Eval("Created", "{0:yyyy-MM-dd HH:mm}") %></td>
                        <td>
                            <a href='<%# "SharedDocumentViewer.aspx?ID=" + Eval("ShareLink") %>' target="_blank" class="action-link"><i class="fas fa-eye"></i> Ver</a>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                        </tbody>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Label ID="lblEmpty" runat="server" Text="No hay documentos compartidos." Visible="false" CssClass="empty-message" />
        </div>
    </section>
</asp:Content>
