/* ========================================
   염소축사관리 - Farm-friendly Practical UI
   네이비 블루 테마 + 가독성 최적화
   ======================================== */

:root {
    /* 메인 컬러 - 네이비 블루 */
    --primary: #1e3a5f;
    --primary-dark: #152a45;
    --primary-light: #2d4a6f;
    
    /* 배경색 - 웜 그레이/베이지 */
    --bg-main: #f5f3f0;
    --bg-card: #ffffff;
    --bg-hover: #faf9f7;
    
    /* 텍스트 - 다크 차콜 */
    --text-primary: #2e2e2e;
    --text-secondary: #5a5a5a;
    --text-muted: #8a8a8a;
    
    /* 강조 숫자 */
    --number-bold: #1a1a1a;
    
    /* 상태 색상 */
    --success: #2e7d32;
    --warning: #ed6c02;
    --danger: #c62828;
    --info: #0277bd;
    
    /* 테두리 */
    --border-light: #e8e6e3;
    --border-medium: #d5d3d0;
    
    /* 그림자 */
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
    
    /* 둥글기 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* 폰트 */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 20px;
    line-height: 1.6;
}

/* ==================== 네비게이션 ==================== */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    box-shadow: var(--shadow);
    padding: 12px 0;
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: white !important;
}

.navbar-brand:hover {
    color: rgba(255,255,255,0.9) !important;
}

.navbar .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 8px 16px !important;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.navbar .nav-link:hover {
    color: white !important;
    background: rgba(255,255,255,0.1);
}

.navbar .nav-link.active {
    color: white !important;
    background: rgba(255,255,255,0.15);
}

/* 탭 메뉴 스타일 (모달/페이지 내) */
.nav-tabs .nav-link {
    color: var(--text-primary);
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    border-color: var(--border-light) var(--border-light) transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: var(--bg-card);
    border-color: var(--border-medium) var(--border-medium) var(--bg-card);
}

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hover);
    padding: 8px;
}

.dropdown-item {
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

/* 모바일 메뉴 */
.navbar-toggler {
    border: 2px solid rgba(255,255,255,0.5);
    padding: 8px 12px;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.9%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* 모바일 펼친 메뉴 */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: var(--primary-dark);
        margin-top: 15px;
        padding: 15px;
        border-radius: var(--radius-md);
    }
    
    .navbar-nav .nav-link {
        color: white !important;
        padding: 12px 16px !important;
        margin: 2px 0;
    }
    
    .navbar-nav .nav-link:hover {
        background: rgba(255,255,255,0.15);
    }
    
    .dropdown-menu {
        background: rgba(255,255,255,0.1);
        border: none;
    }
    
    .dropdown-item {
        color: white;
    }
    
    .dropdown-item:hover {
        background: rgba(255,255,255,0.15);
        color: white;
    }
}

/* ==================== 카드 ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
    margin-bottom: 20px;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* ==================== 통계 카드 ==================== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 15px;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stat-card .card-body {
    padding: 24px;
}

.stat-card h2 {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--number-bold);
    margin-bottom: 5px;
}

.stat-card p {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0;
}

.stat-icon {
    font-size: 2.5rem;
    color: var(--primary);
    opacity: 0.7;
}

/* ==================== 버튼 ==================== */
.btn {
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-outline-secondary {
    border: 2px solid var(--border-medium);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

.btn-touch {
    min-height: 56px;
    font-size: 1.1rem;
}

/* ==================== 폼 ==================== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-light);
    padding: 12px 16px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ==================== 테이블 ==================== */
.table {
    margin-bottom: 0;
    color: var(--text-primary);
}

.table th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-primary);
    border-top: none;
    padding: 14px 16px;
}

.table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: var(--bg-hover);
}

.table-responsive {
    border-radius: var(--radius-md);
}

/* ==================== 뱃지 ==================== */
.badge {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
}

.badge.bg-primary {
    background: var(--primary) !important;
}

.badge.bg-success {
    background: var(--success) !important;
}

.badge.bg-warning {
    background: var(--warning) !important;
}

.badge.bg-danger {
    background: var(--danger) !important;
}

.badge.bg-secondary {
    background: var(--text-muted) !important;
}

/* ==================== 모달 ==================== */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-hover);
}

.modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    padding: 20px 24px;
}

/* 모달/카드 헤더 - 프로그램 기본 색상(네이비 블루) */
.modal-header.bg-success,
.card-header.bg-success {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
}

.modal-title {
    font-weight: 700;
    color: var(--text-primary);
}

.modal-header.bg-success .modal-title,
.modal-header.bg-success .btn-close {
    color: white;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 16px 24px;
}

/* ==================== 알림 ==================== */
.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 16px 20px;
}

.alert-success {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success);
}

.alert-warning {
    background: rgba(237, 108, 2, 0.1);
    color: var(--warning);
}

.alert-danger {
    background: rgba(198, 40, 40, 0.1);
    color: var(--danger);
}

.alert-info {
    background: rgba(2, 119, 189, 0.1);
    color: var(--info);
}

/* ==================== 입력 그룹 ==================== */
.input-group {
    border-radius: var(--radius-sm);
}

.input-group-text {
    background: var(--bg-hover);
    border: 2px solid var(--border-light);
    color: var(--text-secondary);
}

/* ==================== 상태 색상 ==================== */
.status-active, .text-success {
    color: var(--success) !important;
}

.status-sold, .text-info {
    color: var(--info) !important;
}

.status-dead, .text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* ==================== 페이지 헤더 ==================== */
.page-header {
    margin-bottom: 24px;
}

.page-header h1, .page-header h2 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* ==================== 푸터 ==================== */
footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    padding: 20px 0;
    margin-top: 40px;
    color: var(--text-muted);
}

/* ==================== 반응형 ==================== */
@media (max-width: 768px) {
    .btn {
        padding: 12px 20px;
    }
    
    .stat-card h2 {
        font-size: 2.2rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .table th, .table td {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

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

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

/* ==================== 스크롤바 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== PWA 설치 프롬프트 ==================== */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 14px 28px;
    border-radius: 50px;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    display: none;
}

.install-prompt.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* ==================== 로딩 ==================== */
.spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--primary);
}

/* ==================== 인쇄 ==================== */
@media print {
    .navbar, .btn, footer, .install-prompt {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    body {
        background: white;
    }
}
