<%@ Page Title="Compartidos Con Otros" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="SharedByMe.aspx.cs" Inherits="PDI.Web.SharedByMePage" %>

<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;
            vertical-align: middle;
        }
        .shared-table tbody tr:hover {
            background-color: #faf5f8;
        }
        .empty-message {
            display: block;
            text-align: center;
            color: #999;
            padding: 1rem 0;
            font-size: 0.9rem;
        }
        .btn-unshare {
            background: transparent;
            border: 1px solid #d9534f;
            color: #d9534f;
            padding: 4px 12px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
        }
        .btn-unshare:hover {
            background: #d9534f;
            color: #fff;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <section id="page-shared-by-me" class="page">
        <h2>Compartidos Con Otros</h2>

        <!-- Shared Folders Section -->
        <div class="shared-section">
            <h3><i class="fas fa-folder-open"></i> Carpetas</h3>
            <asp:Repeater ID="rptSharedHierarchies" runat="server" OnItemCommand="rptSharedHierarchies_ItemCommand">
                <HeaderTemplate>
                    <table class="shared-table">
                        <thead>
                            <tr>
                                <th>Nombre de la Carpeta</th>
                                <th>Compartido Con</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("Users.FullName") %></td>
                        <td><%# Eval("Created", "{0:yyyy-MM-dd HH:mm}") %></td>
                        <td>
                            <asp:LinkButton ID="btnUnshareHierarchy" runat="server" CommandName="Unshare"
                                CommandArgument='<%# Eval("HierarchyId") + "|" + Eval("UserId") %>'
                                CssClass="btn-unshare"
                                OnClientClick="return confirm('¿Dejar de compartir esta carpeta?');">
                                <i class="fas fa-times"></i> Dejar de compartir
                            </asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                        </tbody>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Label ID="lblEmptyFolders" runat="server" Text="No has compartido carpetas." 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" OnItemCommand="rptSharedDocuments_ItemCommand">
                <HeaderTemplate>
                    <table class="shared-table">
                        <thead>
                            <tr>
                                <th>Nombre del Documento</th>
                                <th>Compartido Con</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("Users1.FullName") %></td>
                        <td><%# Eval("Created", "{0:yyyy-MM-dd HH:mm}") %></td>
                        <td>
                            <asp:LinkButton ID="btnUnshareDocument" runat="server" CommandName="Unshare"
                                CommandArgument='<%# Eval("DocumentId") + "|" + Eval("UserId") %>'
                                CssClass="btn-unshare"
                                OnClientClick="return confirm('¿Dejar de compartir este documento?');">
                                <i class="fas fa-times"></i> Dejar de compartir
                            </asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                        </tbody>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Label ID="lblEmptyDocs" runat="server" Text="No has compartido documentos." Visible="false" CssClass="empty-message" />
        </div>
    </section>
</asp:Content>
