/* ==========================================
   CSS Lesson 2: Flexbox Layout Examples
   File: css-flexbox-guide.css
   ========================================== */

/* 1. Global Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #ec4899;
  --secondary-color: #8b5cf6;
  --bg-dark: #0f0f1b;
  --card-bg: #181825;
  --text-color: #cdd6f4;
  --border-color: #313244;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-color);
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  padding: 40px 20px;
}

/* 2. Example 1: Navigation Bar Layout (Alignments) */
.flex-navbar {
  display: flex;
  justify-content: space-between; /* Đẩy hai khối ra hai bên biên */
  align-items: center; /* Căn giữa các phần tử con theo trục đứng */
  padding: 16px 24px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 30px;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 20px; /* Tạo khoảng trống bằng nhau giữa các a */
}

.nav-links a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.nav-links a:hover {
  color: var(--primary-color);
}

/* 3. Example 2: Flexbox Responsive Grid (Wrap & Basis) */
.flex-grid {
  display: flex;
  flex-wrap: wrap; /* Cho phép các card tự động xuống dòng */
  gap: 16px;
  margin-bottom: 30px;
}

.grid-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  /* flex-basis: 250px (kích thước tối thiểu đề xuất)
     flex-grow: 1 (giúp lấp đầy không gian thừa)
     flex-shrink: 1 (cho phép bóp nhỏ hơn 250px trên mobile) */
  flex: 1 1 250px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
}

.grid-card h3 {
  color: #fff;
  margin-bottom: 8px;
}

.grid-card p {
  font-size: 13px;
  color: #a6adc8;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* 4. Example 3: Centering elements perfectly (Flex Center) */
.flex-center-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  background-color: #11111b;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
}

.centered-box {
  padding: 16px 30px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  font-weight: 700;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}
