/*
 * 파일명: style.css
 * 위치: /assets/css/style.css
 * 기능: 내신등급 계산기 모바일 우선 스타일
 * 작성일: 2025-07-22
 */

/* ===================================
 * 기본 설정 (모바일 우선)
 * ===================================
 */

* {
    font-family: 'Noto Sans KR', sans-serif;
    box-sizing: border-box;
}

body {
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.5;
    font-size: 16px; /* iOS 줌 방지 */
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    padding: 0 15px;
    margin: 0 auto;
}

/* 작은 화면에서 여백 조정 */
@media (max-width: 575px) {
    .container {
        padding: 0 10px;
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    .container {
        padding: 0 15px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1200px;
        padding: 0 15px;
    }
}

/* ===================================
 * 헤더 스타일 (모바일 우선)
 * ===================================
 */

header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    padding: 1.5rem 0;
    text-align: center;
}

header h1 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

header p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

/* 평균 등급 박스 */
.avg-grade-box {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    margin-top: 1rem;
}

.avg-grade-box .h5 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    opacity: 0.9;
}

.avg-grade-box .h4 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
}

/* 데스크톱에서 헤더 개선 */
@media (min-width: 768px) {
    header {
        padding: 2rem 0;
        text-align: left;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .avg-grade-box {
        margin-top: 0;
        text-align: center;
    }
}

/* ===================================
 * 카드 스타일
 * ===================================
 */

.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    border-radius: 0.75rem 0.75rem 0 0;
    padding: 1rem;
}

.card-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

/* ===================================
 * 모바일 과목 입력 카드 스타일
 * ===================================
 */

/* ===================================
 * 모바일 과목 입력 카드 스타일
 * ===================================
 */

/* 모바일에서는 테이블 대신 개별 카드 사용 */
.subject-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.subject-card .subject-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f1f1;
}

.subject-card .subject-number {
    background: #007bff;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
}

.subject-card .delete-btn {
    flex-shrink: 0;
}

.subject-row {
    margin-bottom: 0.75rem;
}

.subject-row:last-child {
    margin-bottom: 0;
}

.subject-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.4rem;
}

.subject-row .form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.5rem;
    font-size: 16px;
}

/* 모바일 입력 그룹 수정 */
.subject-row .input-group {
    display: flex;
    width: 100%;
}

.subject-row .input-group-text {
    background: #f8f9fa;
    border: 1px solid #ced4da;
    border-right: none;
    border-radius: 0.5rem 0 0 0.5rem;
    padding: 0.75rem 0.75rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.subject-row .input-group .form-control {
    border-left: none;
    border-radius: 0 0.5rem 0.5rem 0;
    flex: 1;
    min-width: 0; /* 중요: flex item이 줄어들 수 있도록 */
}

.subject-row .input-group .form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: 0;
    z-index: 3;
}

/* 등급 표시 */
.grade-display {
    text-align: center;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

.grade-display label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

.grade-display .badge {
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
}






/* 데스크톱에서는 기존 테이블 스타일 사용 */
@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
    
    .desktop-only {
        display: block;
    }
    
    .table-responsive {
        display: block;
    }
    
    .table th {
        background-color: #f8f9fa;
        border-bottom: 2px solid #dee2e6;
        font-weight: 600;
        font-size: 0.9rem;
        padding: 0.75rem 0.5rem;
        text-align: center;
    }
    
    .table td {
        vertical-align: middle;
        border-bottom: 1px solid #e9ecef;
        padding: 0.75rem 0.5rem;
    }
    
    .table .form-control {
        font-size: 0.9rem;
    }
}

/* 모바일에서 기존 테이블 숨김 */
@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* ===================================
 * 입력 필드 스타일
 * ===================================
 */

.form-control {
    border: 1px solid #ced4da;
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 16px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: 0;
}

input[type="number"] {
    text-align: center;
}

/* ===================================
 * 버튼 스타일
 * ===================================
 */

.btn {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease-in-out;
    border: none;
}

.btn:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-1px);
}

.btn-outline-success {
    border: 1px solid #28a745;
    color: #28a745;
}

.btn-outline-success:hover {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

.btn-outline-danger {
    border: 1px solid #dc3545;
    color: #dc3545;
}

.btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: 44px;
    min-height: 44px;
}

/* 모바일에서 버튼 간격 */
@media (max-width: 767px) {
    .btn + .btn {
        margin-top: 0.5rem;
    }
    
    .card-header .btn {
        margin-top: 0.5rem;
        width: 100%;
    }
    
    .card-header .btn + .btn {
        margin-left: 0;
    }
}

@media (min-width: 768px) {
    .btn-lg {
        width: auto;
    }
    
    .card-header .btn {
        width: auto;
    }
    
    .card-header .btn + .btn {
        margin-left: 0.5rem;
        margin-top: 0;
    }
}

/* ===================================
 * 등급 배지 스타일
 * ===================================
 */

.badge {
    font-weight: 600;
    border-radius: 0.5rem;
}

.grade-1 { background-color: #28a745 !important; }
.grade-2 { background-color: #20c997 !important; }
.grade-3 { background-color: #17a2b8 !important; }
.grade-4 { background-color: #007bff !important; }
.grade-5 { background-color: #6f42c1 !important; }
.grade-6 { background-color: #e83e8c !important; }
.grade-7 { background-color: #fd7e14 !important; }
.grade-8 { background-color: #dc3545 !important; }
.grade-9 { background-color: #6c757d !important; }

/* ===================================
 * 알림 스타일
 * ===================================
 */

.alert {
    border: none;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.alert-info {
    background-color: rgba(13, 110, 253, 0.1);
    color: #084298;
}

/* 모바일에서 알림 위치 조정 */
@media (max-width: 767px) {
    .alert.position-fixed {
        top: 10px;
        left: 10px;
        right: 10px;
        z-index: 1055;
        width: auto;
        min-width: auto;
    }
}

/* ===================================
 * 등급 기준표 (우측 사이드바)
 * ===================================
 */

/* 모바일에서는 등급 기준표를 간소화 */
@media (max-width: 991px) {
    .grade-reference {
        margin-top: 1rem;
    }
    
    .grade-reference .table {
        font-size: 0.8rem;
    }
    
    .grade-reference .card:last-child {
        display: none; /* 계산 방법 설명은 모바일에서 숨김 */
    }
}

/* ===================================
 * 푸터 스타일 (심플 버전)
 * ===================================
 */

footer {
    background-color: transparent;
    border-top: 1px solid #e9ecef;
    margin-top: 3rem;
}

footer .text-muted {
    color: #6c757d !important;
    font-size: 0.85rem;
}

footer a {
    color: #007bff;
    transition: color 0.2s ease-in-out;
}

footer a:hover {
    color: #0056b3;
}

/* 모바일에서 글자 크기 조정 */
@media (max-width: 767px) {
    footer .small {
        font-size: 0.8rem !important;
    }
}

/* ===================================
 * 유틸리티 클래스
 * ===================================
 */

/* 간격 조정 */
.mb-mobile {
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .mb-mobile {
        margin-bottom: 0;
    }
}

/* 텍스트 크기 */
.text-small {
    font-size: 0.85rem;
}

/* 중앙 정렬 */
.text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .text-center-mobile {
        text-align: left;
    }
}

/* ===================================
 * 애니메이션
 * ===================================
 */

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 등급 업데이트 애니메이션 */
.badge.updated {
    animation: gradeUpdate 0.5s ease-in-out;
}

@keyframes gradeUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ===================================
 * 접근성 개선
 * ===================================
 */

/* 포커스 표시 개선 */
*:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.btn:focus, .form-control:focus {
    outline: none;
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }
}

/* ===================================
 * 인쇄 스타일
 * ===================================
 */

@media print {
    .btn, .alert, footer, .card-header .btn {
        display: none !important;
    }
    
    * {
        background: #fff !important;
        color: #000 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}