/**
 * 자재관리 시스템 - 모바일 최적화 스타일
 */

/* 기본 설정 */
:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --secondary-color: #6c757d;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    padding-bottom: env(safe-area-inset-bottom);
}

/* 모바일 터치 영역 최적화 */
.btn, .form-control, .form-select, a, button {
    min-height: 44px;
}

/* 통계 카드 스타일 */
.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card .card-body {
    padding: 1.25rem;
}

/* 네비게이션 바 */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.2rem;
}

/* 카드 스타일 */
.card {
    border-radius: 10px;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

/* 테이블 모바일 최적화 */
.table-responsive {
    border-radius: 10px;
}

.table {
    font-size: 0.9rem;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    white-space: nowrap;
    background-color: #f8f9fa;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 버튼 그룹 */
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* 배지 */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* 알림 메시지 */
.alert {
    border-radius: 10px;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 페이지네이션 */
.pagination {
    flex-wrap: wrap;
}

.pagination .page-item {
    margin: 2px;
}

.pagination .page-link {
    border-radius: 5px;
    border: 1px solid #dee2e6;
    color: #495057;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 폼 스타일 */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* 이미지 썸네일 */
.img-thumbnail {
    border-radius: 8px;
    border: 2px solid #dee2e6;
}

/* 리스트 그룹 */
.list-group-item {
    border: none;
    border-bottom: 1px solid #f0f0f0;
}

.list-group-item:last-child {
    border-bottom: none;
}

/* 빠른 메뉴 버튼 */
.btn-outline-primary,
.btn-outline-success,
.btn-outline-info,
.btn-outline-secondary {
    border-width: 2px;
    font-weight: 500;
}

/* 로딩 스피너 */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* 모바일 전용 스타일 (768px 이하) */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }

    h4 {
        font-size: 1.3rem;
    }

    h5 {
        font-size: 1.1rem;
    }

    /* 카드 여백 조정 */
    .card-body {
        padding: 1rem;
    }

    /* 통계 카드 작게 */
    .stat-card h2 {
        font-size: 1.8rem;
    }

    .stat-card h6 {
        font-size: 0.75rem;
    }

    .stat-card i {
        font-size: 2rem !important;
    }

    /* 테이블 스크롤 */
    .table-responsive {
        font-size: 0.85rem;
    }

    .table thead th {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .table tbody td {
        padding: 0.5rem;
    }

    /* 버튼 크기 */
    .btn-sm {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* 페이지네이션 */
    .pagination-sm .page-link {
        padding: 0.4rem 0.65rem;
        font-size: 0.8rem;
    }

    /* 네비게이션 */
    .navbar-brand {
        font-size: 1rem;
    }

    .nav-link {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }

    /* 폼 여백 */
    .row.g-3 {
        --bs-gutter-y: 1rem;
    }
}

/* 초소형 모바일 (576px 이하) */
@media (max-width: 576px) {
    body {
        font-size: 12.5px;
    }

    /* 터치 요소를 더 콤팩트하게 */
    .btn, .form-control, .form-select, a, button {
        min-height: 36px;
    }

    /* 컨테이너 여백 줄이기 */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* 카드 여백 */
    .card {
        margin-bottom: 0.75rem;
    }

    /* 버튼 풀 너비 */
    .btn-group {
        width: 100%;
    }

    .btn-group .btn {
        flex: 1;
    }

    /* 테이블 작게 */
    .table {
        font-size: 0.75rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.4rem;
    }

    /* 배지 작게 */
    .badge {
        font-size: 0.7rem;
        padding: 0.25em 0.5em;
    }

    /* 통계 카드 더 작게 */
    .stat-card h2 {
        font-size: 1.5rem;
    }

    .stat-card h6 {
        font-size: 0.7rem;
    }

    .stat-card i {
        font-size: 1.5rem !important;
    }

    /* 검색 폼 */
    .card-body .row.g-2 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
}

/* 태블릿 (769px ~ 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-fluid {
        max-width: 95%;
    }

    .table {
        font-size: 0.95rem;
    }
}

/* 프린트 스타일 */
@media print {
    .navbar,
    .btn,
    .pagination,
    .card-footer,
    .alert {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }

    body {
        background: white;
    }
}

/* 다크모드 지원 (선택사항) */
@media (prefers-color-scheme: dark) {
    /* 다크모드 관련 스타일은 필요시 추가 */
}

/* 로딩 오버레이 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* 터치 피드백 */
.btn:active,
.card:active,
a:active {
    opacity: 0.7;
}

/* iOS Safe Area 지원 */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .navbar {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

/* 스크롤바 스타일 (WebKit 브라우저) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 포커스 가시성 향상 */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* 빈 상태 스타일 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

/* 성공/에러 메시지 강조 */
.alert-success {
    background-color: #d1e7dd;
    color: #0f5132;
}

.alert-danger {
    background-color: #f8d7da;
    color: #842029;
}

.alert-warning {
    background-color: #fff3cd;
    color: #664d03;
}

.alert-info {
    background-color: #cff4fc;
    color: #055160;
}
