{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{{ resume.title }}</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

  <style>
    /* Global Styling */
    body {
      background: #f4f7fa;
      font-family: "Roboto", sans-serif;
      line-height: 1.6;
      color: #333;
    }

    /* Resume Container */
    .resume-container {
      background: #fff;
      border-radius: 10px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      padding: 40px;
      margin: 30px auto;
      max-width: 960px;
    }

    /* Header Styling */
    .resume-header {
      border-bottom: 2px solid #1e90ff;
      margin-bottom: 30px;
      padding-bottom: 15px;
    }

    .resume-header h2 {
      font-size: 2rem;
      font-weight: 700;
      color: #1e90ff;
    }

    .resume-header p {
      margin: 5px 0;
      font-size: 1rem;
    }

    .resume-header a {
      color: #1e90ff;
      text-decoration: none;
      margin-right: 10px;
    }

    .resume-header a:hover {
      text-decoration: underline;
    }

    /* Section Styling */
    .resume-section {
      margin-bottom: 30px;
    }

    .section-title {
      font-size: 1.3rem;
      font-weight: 600;
      color: #1e90ff;
      margin-bottom: 20px;
      border-left: 5px solid #1e90ff;
      padding-left: 10px;
    }

    .resume-section ul {
      padding-left: 20px;
      list-style-type: disc;
    }

    .resume-section li {
      margin-bottom: 12px;
    }

    /* Job & Education Items */
    .job-title, .degree {
      font-size: 1.1rem;
      font-weight: bold;
      color: #333;
    }

    .company-name {
      color: #6c757d;
      font-size: 0.9rem;
    }

    .text-muted {
      font-size: 0.85rem;
    }

    /* Skills & Technologies */
    .badge-skill {
      font-size: 0.9rem;
      margin: 3px;
      padding: 5px 10px;
      border-radius: 20px;
      background-color: #1e90ff;
      color: #fff;
    }

    /* Footer */
    .resume-footer {
      margin-top: 40px;
      text-align: center;
      font-size: 0.9rem;
      color: #6c757d;
      border-top: 2px solid #dee2e6;
      padding-top: 15px;
    }

    .resume-footer a {
      color: #1e90ff;
    }

    /* Hover Effects */
    .resume-section ul li:hover {
      background-color: #f1f5f8;
      border-radius: 5px;
    }

  </style>
</head>
<body>

<div class="container">
  <div class="resume-container">

    <!-- Header -->
    <div class="resume-header text-center">
      {% if resume.personal_info %}
        <h2>{{ resume.personal_info.full_name }}</h2>
        <p class="text-muted">{{ resume.personal_info.email }} | {{ resume.personal_info.phone }}</p>
        <p>
          {% if resume.personal_info.linkedin %}
            <a href="{{ resume.personal_info.linkedin }}" target="_blank">LinkedIn</a> |
          {% endif %}
          {% if resume.personal_info.github %}
            <a href="{{ resume.personal_info.github }}" target="_blank">GitHub</a> |
          {% endif %}
          {% if resume.personal_info.portfolio %}
            <a href="{{ resume.personal_info.portfolio }}" target="_blank">Portfolio</a>
          {% endif %}
        </p>
      {% endif %}
    </div>

    <!-- Profile Summary -->
    {% if resume.summary %}
      <div class="resume-section">
        <h4 class="section-title">Profile Summary</h4>
        <p>{{ resume.summary }}</p>
      </div>
    {% endif %}

    <!-- Education -->
    {% if resume.education.all %}
      <div class="resume-section">
        <h4 class="section-title">Education</h4>
        <ul>
          {% for edu in resume.education.all %}
            <li>
              <span class="degree">{{ edu.degree }}</span> - {{ edu.institution }} 
              ({{ edu.start_year }} - {{ edu.end_year }})
              {% if edu.grade %}<br><small class="text-muted">Grade: {{ edu.grade }}</small>{% endif %}
            </li>
          {% endfor %}
        </ul>
      </div>
    {% endif %}

    <!-- Work Experience -->
    {% if resume.experience.all %}
      <div class="resume-section">
        <h4 class="section-title">Work Experience</h4>
        {% for exp in resume.experience.all %}
          <div class="mb-3">
            <span class="job-title">{{ exp.job_title }}</span> - 
            <span class="company-name">{{ exp.company }}</span> 
            <small class="text-muted">({{ exp.start_date }} - {{ exp.end_date|default:"Present" }})</small>
            {% if exp.location %}<br><small class="text-muted">{{ exp.location }}</small>{% endif %}
            <p class="mt-2">{{ exp.responsibilities|linebreaks }}</p>
          </div>
        {% endfor %}
      </div>
    {% endif %}

    <!-- Projects -->
    {% if resume.projects.all %}
      <div class="resume-section">
        <h4 class="section-title">Projects</h4>
        {% for project in resume.projects.all %}
          <div class="mb-3">
            <span class="job-title">{{ project.title }}</span>
            {% if project.organization %} - <span class="company-name">{{ project.organization }}</span>{% endif %}
            {% if project.duration %}
              <br><small class="text-muted">({{ project.duration }})</small>
            {% endif %}
            <p>{{ project.description }}</p>
            {% if project.technologies %}
              <p><em>Technologies:</em> {{ project.technologies }}</p>
            {% endif %}
          </div>
        {% endfor %}
      </div>
    {% endif %}

    <!-- Skills -->
    {% if resume.skills.all %}
      <div class="resume-section">
        <h4 class="section-title">Skills</h4>
        {% for skill in resume.skills.all %}
          <span class="badge-skill">{{ skill.name }}</span>
        {% endfor %}
      </div>
    {% endif %}

    <!-- Certifications -->
    {% if resume.certifications.all %}
      <div class="resume-section">
        <h4 class="section-title">Certifications</h4>
        <ul>
          {% for cert in resume.certifications.all %}
            <li>{{ cert.name }} - {{ cert.issued_by }} ({{ cert.year }})</li>
          {% endfor %}
        </ul>
      </div>
    {% endif %}

    <!-- Footer -->
    <div class="resume-footer">
      <p>Generated with ❤️ using Resume Builder | <a href="#">Privacy Policy</a> | <a href="#">Contact</a></p>
    </div>

  </div>
</div>

</body>
</html>
