---
interface Props {
    id: string;
    title: string;
    description: string;
    fileSize: string;
    fileType: 'pdf' | 'docx' | 'xlsx' | 'zip';
    downloadUrl: string;
    category: string;
}

const {
    id,
    title,
    description,
    fileSize,
    fileType,
    downloadUrl,
    category
} = Astro.props as Props;

const fileTypeIcons: Record<string, string> = {
    pdf: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" fill="#ef4444" stroke="#dc2626" stroke-width="1.5"/>
        <path d="M14 2v6h6M9 13h6M9 17h6M9 9h2" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round"/>
    </svg>`,
    docx: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" fill="#3b82f6" stroke="#2563eb" stroke-width="1.5"/>
        <path d="M14 2v6h6M9 13h6M9 17h4" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round"/>
    </svg>`,
    xlsx: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" fill="#10b981" stroke="#059669" stroke-width="1.5"/>
        <path d="M14 2v6h6M10 12l4 4M14 12l-4 4" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round"/>
    </svg>`,
    zip: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" fill="#f59e0b" stroke="#d97706" stroke-width="1.5"/>
        <path d="M14 2v6h6M12 10v4M10 14h4M12 14v4" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round"/>
    </svg>`
};
---

<article class="doc-card" data-category={category} data-doc-id={id}>
    <div class="doc-card-header">
        <div class="file-icon" set:html={fileTypeIcons[fileType]} />
        <div class="doc-info">
            <h3 class="doc-title">{title}</h3>
            <p class="doc-description">{description}</p>
        </div>
    </div>
    <div class="doc-card-footer">
        <div class="doc-meta">
            <span class="doc-category">{category}</span>
            <span class="doc-type">{fileType.toUpperCase()}</span>
            <span class="doc-size">{fileSize}</span>
        </div>
        <a
            href={downloadUrl}
            class="download-btn"
            download
            target="_blank"
            rel="noopener noreferrer"
        >
            <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4v12m0 0l-4-4m4 4l4-4M4 18h16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
            </svg>
            <span>Скачать</span>
        </a>
    </div>
</article>

<style>
    .doc-card {
        background: rgba(255, 255, 255, 0.04);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 16px;
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .doc-card:hover {
        border-color: rgba(234, 194, 110, 0.3);
        box-shadow: 0 0 30px rgba(234, 194, 110, 0.15);
        transform: translateY(-4px);
    }

    .doc-card-header {
        display: flex;
        gap: 1rem;
        align-items: flex-start;
    }

    .file-icon {
        flex-shrink: 0;
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.05);
    }

    .file-icon svg {
        width: 100%;
        height: 100%;
    }

    .doc-info {
        flex: 1;
    }

    .doc-title {
        color: #ffffff;
        font-size: 1.05rem;
        font-weight: 600;
        margin: 0 0 0.5rem 0;
        line-height: 1.4;
    }

    .doc-description {
        color: #94a3b8;
        font-size: 0.85rem;
        line-height: 1.5;
        margin: 0;
    }

    .doc-card-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .doc-meta {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .doc-category {
        color: #eac26e;
        font-size: 0.7rem;
        font-weight: 600;
        padding: 0.2rem 0.5rem;
        background: rgba(234, 194, 110, 0.1);
        border-radius: 4px;
    }

    .doc-type {
        color: #94a3b8;
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .doc-size {
        color: #64748b;
        font-size: 0.8rem;
    }

    .download-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.625rem 1.25rem;
        background: linear-gradient(135deg, #eac26e 0%, #ce9f40 100%);
        color: #0f172a;
        font-size: 0.85rem;
        font-weight: 600;
        text-decoration: none;
        border-radius: 8px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        white-space: nowrap;
    }

    .download-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(234, 194, 110, 0.4);
    }

    .download-btn svg {
        width: 16px;
        height: 16px;
    }

    @media (max-width: 768px) {
        .doc-card {
            padding: 1.25rem;
        }

        .doc-card-header {
            flex-direction: column;
            align-items: center;
            text-align: center;
        }

        .doc-card-footer {
            flex-direction: column;
            gap: 1rem;
        }

        .download-btn {
            width: 100%;
            justify-content: center;
        }

        .doc-meta {
            justify-content: center;
        }
    }
</style>
