@model QuestionnaireViewModel

@{
    ViewData["Title"] = "Questionnaire Details";
}

<style>
    /* Modern Design System */
    @@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

    :root {
        --primary-color: #6366f1;
        --primary-light: #8b5cf6;
        --primary-dark: #4338ca;
        --success-color: #10b981;
        --success-light: #34d399;
        --success-dark: #059669;
        --info-color: #06b6d4;
        --info-light: #22d3ee;
        --info-dark: #0891b2;
        --warning-color: #f59e0b;
        --warning-light: #fbbf24;
        --warning-dark: #d97706;
        --gray-50: #f8fafc;
        --gray-100: #f1f5f9;
        --gray-200: #e2e8f0;
        --gray-300: #cbd5e1;
        --gray-400: #94a3b8;
        --gray-500: #64748b;
        --gray-600: #475569;
        --gray-700: #334155;
        --gray-800: #1e293b;
        --gray-900: #0f172a;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
        --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
        --border-radius-sm: 8px;
        --border-radius-md: 12px;
        --border-radius-lg: 16px;
        --border-radius-xl: 24px;
    }

    * {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    }

    body {
        background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
        min-height: 100vh;
        padding: 2rem 0;
    }

    .container {
        max-width: 1200px;
    }

    /* Header Section */
    .page-header {
        background: white;
        border-radius: var(--border-radius-xl);
        box-shadow: var(--shadow-xl);
        padding: 2.5rem;
        margin-bottom: 2rem;
        position: relative;
        overflow: hidden;
    }

        .page-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--info-color));
        }

    .header-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .header-info {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }

    .header-icon {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
        color: white;
        width: 64px;
        height: 64px;
        border-radius: var(--border-radius-lg);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.75rem;
        box-shadow: var(--shadow-lg);
    }

    .header-text h1 {
        font-size: 2rem;
        font-weight: 800;
        color: var(--gray-800);
        margin: 0 0 0.5rem;
    }

    .header-subtitle {
        color: var(--gray-600);
        font-size: 1rem;
        font-weight: 500;
    }

    .back-button {
        background: linear-gradient(135deg, var(--gray-500) 0%, var(--gray-600) 100%);
        color: white;
        border: none;
        padding: 0.75rem 1.5rem;
        border-radius: var(--border-radius-md);
        font-weight: 600;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        transition: all 0.3s ease;
        box-shadow: var(--shadow-md);
    }

        .back-button:hover {
            background: linear-gradient(135deg, var(--gray-600) 0%, var(--gray-700) 100%);
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
            color: white;
            text-decoration: none;
        }

    /* Main Content */
    .main-content {
        background: white;
        border-radius: var(--border-radius-xl);
        box-shadow: var(--shadow-xl);
        overflow: hidden;
        margin-bottom: 2rem;
    }

    /* Overview Section */
    .overview-section {
        background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
        padding: 2.5rem;
        border-bottom: 1px solid var(--gray-200);
    }

    .overview-header {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .overview-icon {
        background: var(--info-color);
        color: white;
        width: 48px;
        height: 48px;
        border-radius: var(--border-radius-md);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }

    .overview-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--gray-800);
        margin: 0;
    }

    .overview-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }

    .overview-card {
        background: white;
        padding: 1.5rem;
        border-radius: var(--border-radius-lg);
        border: 1px solid var(--gray-200);
        box-shadow: var(--shadow-sm);
        transition: all 0.3s ease;
    }

        .overview-card:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

    .overview-card-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .overview-card-icon {
        width: 36px;
        height: 36px;
        border-radius: var(--border-radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        color: white;
    }

        .overview-card-icon.warning {
            background: var(--warning-color);
        }

        .overview-card-icon.primary {
            background: var(--primary-color);
        }

        .overview-card-icon.success {
            background: var(--success-color);
        }

        .overview-card-icon.info {
            background: var(--info-color);
        }

    .overview-card-label {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--gray-500);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .overview-card-value {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--gray-800);
        word-break: break-word;
        line-height: 1.3;
    }

    .description-card {
        grid-column: 1 / -1;
    }

    .description-content {
        color: var(--gray-700);
        line-height: 1.6;
        font-size: 1rem;
        margin-top: 0.5rem;
    }

    /* Questions Section */
    .questions-section {
        padding: 2.5rem;
    }

    .questions-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 2rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .questions-title {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .questions-icon {
        background: var(--success-color);
        color: white;
        width: 48px;
        height: 48px;
        border-radius: var(--border-radius-md);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }

    .questions-title h2 {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--gray-800);
        margin: 0;
    }

    .questions-count {
        background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: var(--border-radius-md);
        font-weight: 600;
        font-size: 0.875rem;
        box-shadow: var(--shadow-sm);
    }

    /* Question Cards */
    .questions-grid {
        display: grid;
        gap: 2rem;
    }

    .question-card {
        background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
        border-radius: var(--border-radius-lg);
        border: 1px solid var(--gray-200);
        box-shadow: var(--shadow-md);
        overflow: hidden;
        transition: all 0.3s ease;
    }

        .question-card:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-xl);
        }

    .question-header {
        background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
        color: white;
        padding: 1.5rem;
        position: relative;
        overflow: hidden;
    }

        .question-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><radialGradient id="a" cx="50%" cy="0%" r="100%"><stop offset="0%" stop-color="white" stop-opacity="0.1"/><stop offset="100%" stop-color="white" stop-opacity="0"/></radialGradient></defs><rect width="100" height="20" fill="url(%23a)"/></svg>');
            opacity: 0.3;
        }

    .question-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 1rem;
        position: relative;
        z-index: 1;
    }

    .question-id {
        background: rgba(255, 255, 255, 0.2);
        padding: 0.375rem 0.75rem;
        border-radius: var(--border-radius-sm);
        font-weight: 600;
        font-size: 0.875rem;
    }

    .question-type {
        background: rgba(255, 255, 255, 0.2);
        padding: 0.375rem 0.75rem;
        border-radius: var(--border-radius-sm);
        font-weight: 600;
        font-size: 0.875rem;
    }

    .question-text {
        font-size: 1.25rem;
        font-weight: 700;
        margin: 0;
        position: relative;
        z-index: 1;
        line-height: 1.4;
    }

    /* Answers Section */
    .answers-section {
        padding: 2rem;
    }

    .answers-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .answers-icon {
        background: var(--info-color);
        color: white;
        width: 32px;
        height: 32px;
        border-radius: var(--border-radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
    }

    .answers-title {
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--gray-800);
        margin: 0;
    }

    .answers-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }

    .answer-card {
        background: white;
        border: 2px solid var(--gray-200);
        border-radius: var(--border-radius-md);
        padding: 1rem;
        transition: all 0.3s ease;
        position: relative;
    }

        .answer-card:hover {
            border-color: var(--info-color);
            box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
            transform: translateY(-1px);
        }

        .answer-card.other-option {
            border-color: var(--warning-color);
            background: linear-gradient(135deg, #fef3c7 0%, #fde68a 20%, white 100%);
        }

            .answer-card.other-option::before {
                content: "OTHER";
                position: absolute;
                top: -8px;
                left: 12px;
                background: var(--warning-color);
                color: white;
                padding: 0.25rem 0.5rem;
                border-radius: var(--border-radius-sm);
                font-size: 0.625rem;
                font-weight: 700;
                letter-spacing: 0.5px;
            }

    .answer-meta {
        display: flex;
        align-items: center;
        justify-content: between;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .answer-id {
        background: linear-gradient(135deg, var(--info-color) 0%, var(--info-dark) 100%);
        color: white;
        padding: 0.25rem 0.5rem;
        border-radius: var(--border-radius-sm);
        font-weight: 600;
        font-size: 0.75rem;
    }

    .answer-text {
        font-size: 1rem;
        font-weight: 600;
        color: var(--gray-800);
        line-height: 1.4;
        word-break: break-word;
    }

    /* Empty State */
    .empty-state {
        text-align: center;
        padding: 3rem;
        color: var(--gray-500);
    }

        .empty-state i {
            font-size: 3rem;
            margin-bottom: 1rem;
            color: var(--gray-400);
        }

        .empty-state h3 {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
        }

    /* Stats Summary */
    .stats-summary {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
        color: white;
        padding: 2rem;
        margin-bottom: 2rem;
        border-radius: var(--border-radius-lg);
        box-shadow: var(--shadow-lg);
    }

    .stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 1.5rem;
        text-align: center;
    }

    .stat-item {
        padding: 1rem;
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--border-radius-md);
        backdrop-filter: blur(10px);
    }

    .stat-number {
        font-size: 2rem;
        font-weight: 800;
        display: block;
        margin-bottom: 0.25rem;
    }

    .stat-label {
        font-size: 0.875rem;
        font-weight: 500;
        opacity: 0.9;
    }

    /* Footer Actions */
    .footer-actions {
        text-align: center;
        margin-top: 2rem;
    }

    /* Responsive Design */
    @@media (max-width: 768px) {
        .container

    {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }

    .questions-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .answers-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    }

    /* Animations */
    .fade-in {
        animation: fadeIn 0.6s ease-out;
    }

    @@keyframes fadeIn {
        from

    {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

    }

    .slide-in {
        animation: slideIn 0.4s ease-out;
    }

    @@keyframes slideIn {
        from

    {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }

    }
</style>

<div class="container">
    <!-- Page Header -->
    <div class="page-header fade-in">
        <div class="header-content">
            <div class="header-info">
                <div class="header-icon">
                    <i class="bi bi-file-text-fill"></i>
                </div>
                <div class="header-text">
                    <h1>Questionnaire Details</h1>
                    <p class="header-subtitle">Complete overview of questionnaire structure and content</p>
                </div>
            </div>
            <a asp-action="Index" class="back-button">
                <i class="bi bi-arrow-left"></i>
                Back to List
            </a>
        </div>
    </div>

    <!-- Stats Summary -->
    <div class="stats-summary fade-in">
        <div class="stats-grid">
            <div class="stat-item">
                <span class="stat-number">@Model.Questions.Count</span>
                <span class="stat-label">Questions</span>
            </div>
            <div class="stat-item">
                <span class="stat-number">@Model.Questions.Sum(q => q.Answers.Count)</span>
                <span class="stat-label">Total Answers</span>
            </div>
            <div class="stat-item">
                <span class="stat-number">@Model.Questions.Count(q => q.Answers.Any(a => a.IsOtherOption))</span>
                <span class="stat-label">Other Options</span>
            </div>
            <div class="stat-item">
                <span class="stat-number">@Model.Questions.Select(q => q.Type).Distinct().Count()</span>
                <span class="stat-label">Question Types</span>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="main-content fade-in">
        <!-- Overview Section -->
        <div class="overview-section">
            <div class="overview-header">
                <div class="overview-icon">
                    <i class="bi bi-info-circle-fill"></i>
                </div>
                <h2 class="overview-title">Overview</h2>
            </div>

            <div class="overview-grid">
                <div class="overview-card slide-in">
                    <div class="overview-card-header">
                        <div class="overview-card-icon warning">
                            <i class="bi bi-hash"></i>
                        </div>
                        <span class="overview-card-label">ID</span>
                    </div>
                    <div class="overview-card-value">#@Model.Id</div>
                </div>

                <div class="overview-card slide-in">
                    <div class="overview-card-header">
                        <div class="overview-card-icon primary">
                            <i class="bi bi-card-heading"></i>
                        </div>
                        <span class="overview-card-label">Title</span>
                    </div>
                    <div class="overview-card-value">@Model.Title</div>
                </div>

                <div class="overview-card description-card slide-in">
                    <div class="overview-card-header">
                        <div class="overview-card-icon info">
                            <i class="bi bi-card-text"></i>
                        </div>
                        <span class="overview-card-label">Description</span>
                    </div>
                    <div class="description-content">
                        @if (!string.IsNullOrEmpty(Model.Description))
                        {
                            @Html.Raw(Model.Description)
                        }
                        else
                        {
                            <em class="text-muted">No description provided</em>
                        }
                    </div>
                </div>
            </div>
        </div>

        <!-- Questions Section -->
        <div class="questions-section">
            <div class="questions-header">
                <div class="questions-title">
                    <div class="questions-icon">
                        <i class="bi bi-question-circle-fill"></i>
                    </div>
                    <h2>Questions</h2>
                </div>
                <div class="questions-count">
                    @Model.Questions.Count Question@(Model.Questions.Count != 1 ? "s" : "")
                </div>
            </div>

            @if (Model.Questions.Any())
            {
                <div class="questions-grid">
                    @foreach (var question in Model.Questions.Select((q, index) => new { Question = q, Index = index }))
                    {
                        <div class="question-card slide-in">
                            <div class="question-header">
                                <div class="question-meta">
                                    <span class="question-id">ID: @question.Question.Id</span>
                                    <span class="question-type">@question.Question.Type</span>
                                </div>
                                <h3 class="question-text">
                                    Question @(question.Index + 1): @question.Question.Text
                                </h3>
                            </div>

                            <div class="answers-section">
                                <div class="answers-header">
                                    <div class="answers-icon">
                                        <i class="bi bi-list-ul"></i>
                                    </div>
                                    <h4 class="answers-title">
                                        Answers (@question.Question.Answers.Count)
                                    </h4>
                                </div>

                                @if (question.Question.Answers.Any())
                                {
                                    <div class="answers-grid">
                                        @foreach (var answer in question.Question.Answers)
                                        {
                                            <div class="answer-card @(answer.IsOtherOption ? "other-option" : "")">
                                                <div class="answer-meta">
                                                    <span class="answer-id">ID: @answer.Id</span>
                                                </div>
                                                <div class="answer-text">@answer.Text</div>
                                            </div>
                                        }
                                    </div>
                                }
                                else
                                {
                                    <div class="empty-state">
                                        <i class="bi bi-inbox"></i>
                                        <h3>No Answers</h3>
                                        <p>This question doesn't have any answer options.</p>
                                    </div>
                                }
                            </div>
                        </div>
                    }
                </div>
            }
            else
            {
                <div class="empty-state">
                    <i class="bi bi-question-circle"></i>
                    <h3>No Questions</h3>
                    <p>This questionnaire doesn't contain any questions yet.</p>
                </div>
            }
        </div>
    </div>

    <!-- Footer Actions -->
    <div class="footer-actions">
        <a asp-action="Index" class="back-button">
            <i class="bi bi-arrow-left"></i>
            Back to List
        </a>
    </div>
</div>