/*
* 파일명: style.css
* 경로: /assets/css/
* 기능: 메인 페이지 스타일링 - 그린 테마 디자인
* 작성일: 2024-12-19
* 수정일: 2025-09-30 (그린 테마 리팩토링)
*/

/* ======== CSS 변수 정의 (그린 테마) ======== */
:root {
    /* 메인 컬러 */
    --primary-dark: #2C5F2D;      /* 진한 녹색 */
    --primary-light: #97BC62;     /* 연한 녹색 */
    --primary-hover: #234a24;     /* 더 진한 녹색 (호버) */
    --primary-soft: #b8d89e;      /* 더 연한 녹색 (배경) */
    
    /* 배경 컬러 */
    --bg-primary: #f5f9f3;        /* 연한 녹색 배경 */
    --bg-secondary: #ffffff;
    --bg-gradient-start: #2C5F2D;
    --bg-gradient-end: #97BC62;
    
    /* 텍스트 컬러 */
    --text-primary: #1a3a1b;      /* 진한 녹색 계열 */
    --text-secondary: #4a6b4d;
    --text-muted: #7a9b7d;
    --text-white: #ffffff;
    
    /* 강조 컬러 */
    --accent-color: #97BC62;
    --accent-hover: #7da350;
    --favorite-color: #d4af37;    /* 골드 (즐겨찾기) */
    
    /* 보더 & 그림자 */
    --border-color: #d4e5ce;
    --shadow-sm: 0 2px 4px rgba(44, 95, 45, 0.08);
    --shadow-md: 0 4px 6px rgba(44, 95, 45, 0.12);
    --shadow-lg: 0 10px 15px rgba(44, 95, 45, 0.15);
    
    /* 반경 & 전환 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======== 다크 모드 (그린 테마) ======== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a2e1b;
        --bg-secondary: #243426;
        --text-primary: #e8f3e9;
        --text-secondary: #b8d89e;
        --border-color: #3a5a3c;
    }
}

/* ======== 기본 리셋 ======== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ======== Body 스타일 (그린 그라디언트) ======== */
body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(44, 95, 45, 0.1) 0%, rgba(151, 188, 98, 0.1) 100%);
    z-index: -1;
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    min-height: 100vh;
}

/* ======== Today 섹션 스타일 ======== */
.today-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--primary-light);
}

.today-header {
    text-align: center;
    margin-bottom: 1.5rem;
    position: relative;
}

.today-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.today-header::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary-light));
    margin: 0.5rem auto 0;
    border-radius: 2px;
}

.today-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.today-item {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition);
    cursor: default;
    border: 2px solid var(--border-color);
}

.today-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    background: linear-gradient(135deg, rgba(151, 188, 98, 0.1), rgba(255, 255, 255, 1));
}

.today-item i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.8;
}

.today-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.today-item .value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ======== 관리자 버튼 영역 ======== */
.admin-section {
    margin-bottom: 2rem;
    text-align: right;
}

.admin-btn {
    background: var(--primary-dark);
    color: var(--text-white);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ======== 메인 헤더 ======== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-light);
}

.main-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sort-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
}

.sort-switch label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}

/* ======== 카테고리 카드 스타일 ======== */
.categories-container {
    display: grid;
    gap: 1.5rem;
}

.category-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 2px solid var(--border-color);
}

.category-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.category-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
    color: var(--text-white);
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.category-body {
    padding: 1.5rem;
}

.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ======== 북마크 아이템 스타일 ======== */
.bookmark-item-wrapper {
    position: relative;
}

.bookmark-link {
    text-decoration: none;
    display: block;
}

.bookmark-item {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 60px;
    position: relative;
    overflow: hidden;
}

.bookmark-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary-light));
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.bookmark-item:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-light);
    transform: translateX(3px);
    box-shadow: var(--shadow-md);
}

.bookmark-item:hover::before {
    transform: scaleY(1);
}

.bookmark-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-soft));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--primary-dark);
}

.bookmark-item.is-favorite .bookmark-icon {
    background: linear-gradient(135deg, #ffd700, #d4af37);
    color: var(--text-white);
}

.bookmark-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: -0.2px;
}

.favorite-star {
    color: var(--favorite-color);
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.9rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* ======== 빈 상태 스타일 ======== */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
    color: var(--primary-light);
}

/* ======== 스위치 스타일 개선 (그린 테마) ======== */
.form-check-input {
    width: 44px;
    height: 24px;
    background-color: var(--border-color);
    border: none;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--primary-light);
    border-color: var(--primary-light);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(151, 188, 98, 0.25);
}

/* ======== 인라인 Admin 버튼 (그린 테마) ======== */
.admin-btn-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
    color: var(--text-white);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(44, 95, 45, 0.3);
}

.admin-btn-inline:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 95, 45, 0.4);
    background: linear-gradient(135deg, var(--primary-hover) 0%, #7da350 100%);
}

.admin-btn-inline:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(44, 95, 45, 0.3);
}

.admin-btn-inline i {
    font-size: 1em;
}

/* ======== 반응형 스타일 ======== */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }
    
    .today-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bookmarks-grid {
        grid-template-columns: 1fr;
    }
    
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .sort-controls {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .today-grid {
        grid-template-columns: 1fr;
    }
    
    .main-title {
        font-size: 1.5rem;
    }
}

/* ======== 애니메이션 ======== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-card {
    animation: fadeIn 0.5s ease-out;
}

.category-card:nth-child(1) { animation-delay: 0.1s; }
.category-card:nth-child(2) { animation-delay: 0.2s; }
.category-card:nth-child(3) { animation-delay: 0.3s; }
.category-card:nth-child(4) { animation-delay: 0.4s; }

/* ======== 스크롤바 스타일링 (그린 테마) ======== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-dark), var(--primary-light));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* ======== 로딩 & 에러 메시지 (그린 테마) ======== */
.loading-indicator {
    opacity: 0.6;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.weather-info, .exchange-info {
    text-align: center;
    line-height: 1.2;
}

.weather-temp, .exchange-rate {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 2px;
    color: var(--primary-dark);
}

.weather-desc, .weather-city, .exchange-desc {
    font-size: 0.8em;
    opacity: 0.8;
    color: var(--text-secondary);
}

.error-message {
    color: #c53030;
    font-size: 0.85em;
    opacity: 0.9;
    font-weight: 500;
}

.retry-button {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 0.8em;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    margin-top: 3px;
}

.retry-button:hover {
    color: var(--primary-dark);
}

.weather-icon.updated {
    transition: color 0.3s ease;
}

/* ======== TODO 리스트 스타일 (그린 테마) ======== */
.today-item.todo-expanded {
    grid-column: span 2;
    align-items: flex-start;
    text-align: left;
    padding: 20px;
}

.today-item.todo-expanded .label {
    align-self: flex-start;
    margin-bottom: 8px;
}

.today-item.todo-expanded .value {
    width: 100%;
    text-align: left;
    font-weight: normal;
}

.todo-list {
    margin: 0;
    padding-left: 1.2em;
    width: 100%;
}

.todo-item {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(151, 188, 98, 0.1);
    border: 2px solid rgba(151, 188, 98, 0.3);
    border-radius: 6px;
    cursor: help;
    transition: all 0.2s ease;
    font-size: 0.9em;
    line-height: 1.4;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.todo-item:hover {
    background: rgba(151, 188, 98, 0.2);
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(151, 188, 98, 0.2);
}

.todo-empty {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px 0;
    font-size: 0.9em;
}

/* ======== 툴팁 스타일 개선 ======== */
.tooltip-inner {
    max-width: 300px;
    text-align: left;
    font-size: 0.9em;
    line-height: 1.4;
    padding: 10px 12px;
    background-color: var(--primary-dark);
}

.tooltip.bs-tooltip-bottom .tooltip-arrow::before {
    border-bottom-color: var(--primary-dark);
}

.tooltip.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: var(--primary-dark);
}