/*
 * CSS Layout 예제 스타일시트
 * Flexbox와 Grid 레이아웃
 */

/* ============================================
   기본 스타일
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
    background-color: #f5f5f5;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    margin: 20px 0;
}

h3 {
    color: #34495e;
    margin: 15px 0 10px;
}

.section {
    background: white;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

code {
    background-color: #ecf0f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* ============================================
   Flexbox 스타일
   ============================================ */

.flex-container {
    display: flex;
    background-color: #ecf0f1;
    padding: 10px;
    margin-bottom: 15px;
    min-height: 60px;
}

.flex-item {
    background-color: #3498db;
    color: white;
    padding: 15px 20px;
    margin: 5px;
    text-align: center;
    border-radius: 4px;
}

/* flex-direction */
.direction-row { flex-direction: row; }
.direction-row-reverse { flex-direction: row-reverse; }
.direction-column { flex-direction: column; }
.direction-column-reverse { flex-direction: column-reverse; }

/* justify-content */
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* align-items */
.align-stretch { align-items: stretch; }
.align-stretch .flex-item { height: auto; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }
.align-center { align-items: center; }
.align-baseline { align-items: baseline; }

/* flex-wrap */
.wrap-nowrap { flex-wrap: nowrap; }
.wrap-wrap { flex-wrap: wrap; }
.wrap-reverse { flex-wrap: wrap-reverse; }
.flex-item.wide { min-width: 150px; }

/* 완전 중앙 정렬 */
.center-perfect {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.center-perfect .flex-item {
    font-size: 1.5em;
    font-weight: bold;
}

/* 네비게이션 바 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #2c3e50;
    padding: 15px 20px;
    border-radius: 4px;
}

.logo {
    color: white;
    font-size: 1.5em;
    font-weight: bold;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 20px;
}

.nav-links a {
    color: #ecf0f1;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-links a:hover {
    background-color: #34495e;
}

/* 카드 레이아웃 */
.card-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.card {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-header {
    background-color: #3498db;
    color: white;
    padding: 15px;
    font-weight: bold;
}

.card-body {
    flex: 1;
    padding: 15px;
}

.card-footer {
    padding: 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #ecf0f1;
}

.card-footer button {
    width: 100%;
    padding: 8px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.card-footer button:hover {
    background-color: #2980b9;
}

/* ============================================
   Grid 스타일
   ============================================ */

.grid-container {
    display: grid;
    background-color: #ecf0f1;
    padding: 10px;
    margin-bottom: 15px;
}

.grid-item {
    background-color: #9b59b6;
    color: white;
    padding: 20px;
    text-align: center;
    border-radius: 4px;
}

.grid-item.small {
    padding: 10px;
    width: 80px;
    height: 60px;
}

/* 기본 Grid */
.basic-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* grid-template-columns */
.columns-fixed {
    grid-template-columns: 100px 200px 100px;
    gap: 10px;
}

.columns-fr {
    grid-template-columns: 1fr 2fr 1fr;
    gap: 10px;
}

.columns-repeat {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.columns-minmax {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
    gap: 10px;
}

.columns-auto-fill {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.columns-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

/* grid-template-rows */
.rows-example {
    grid-template-columns: 1fr;
    grid-template-rows: 100px 200px 100px;
    gap: 10px;
}

/* gap */
.gap-example {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.gap-separate {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 30px;
    column-gap: 10px;
}

/* 아이템 배치 */
.placement-example {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 80px);
    gap: 10px;
}

.span-col-2 { grid-column: 1 / 3; }
.span-row-2 { grid-row: 2 / 4; }
.span-both {
    grid-column: 2 / 4;
    grid-row: 3 / 5;
}

/* grid-template-areas */
.areas-example {
    grid-template-areas:
        "header header header"
        "sidebar main main"
        "footer footer footer";
    grid-template-columns: 200px 1fr 1fr;
    grid-template-rows: 60px 200px 60px;
    gap: 10px;
}

.area-header { grid-area: header; background-color: #e74c3c; }
.area-sidebar { grid-area: sidebar; background-color: #f39c12; }
.area-main { grid-area: main; background-color: #27ae60; }
.area-footer { grid-area: footer; background-color: #3498db; }

/* justify-items, align-items */
.items-center {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 100px);
    gap: 10px;
    justify-items: center;
    align-items: center;
}

.items-stretch {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 100px);
    gap: 10px;
}

/* justify-content, align-content */
.content-center {
    grid-template-columns: repeat(2, 100px);
    grid-template-rows: repeat(2, 80px);
    gap: 10px;
    height: 250px;
    justify-content: center;
    align-content: center;
}

/* justify-self, align-self */
.self-example {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 100px);
    gap: 10px;
}

/* 갤러리 */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-rows: 150px;
    gap: 10px;
}

.gallery-item {
    background-color: #1abc9c;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    font-weight: bold;
}

.gallery-item.large {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-item.tall {
    grid-row: span 2;
}

.gallery-item.wide {
    grid-column: span 2;
}

/* 대시보드 */
.dashboard {
    display: grid;
    grid-template-areas:
        "header header header"
        "nav main aside"
        "footer footer footer";
    grid-template-columns: 150px 1fr 200px;
    grid-template-rows: 60px 1fr 50px;
    gap: 10px;
    min-height: 400px;
}

.dash-header {
    grid-area: header;
    background-color: #2c3e50;
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.dash-nav {
    grid-area: nav;
    background-color: #34495e;
    color: white;
    padding: 15px;
}

.dash-main {
    grid-area: main;
    background-color: #ecf0f1;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.widget {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wide-widget {
    grid-column: span 2;
}

.dash-aside {
    grid-area: aside;
    background-color: #bdc3c7;
    padding: 15px;
}

.dash-footer {
    grid-area: footer;
    background-color: #7f8c8d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 반응형 Grid */
.responsive-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* ============================================
   푸터
   ============================================ */

footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    border-top: 1px solid #ecf0f1;
    margin-top: 30px;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}
