/**
 * 個人財務管理系統 - 自定義樣式
 * 補充 Tailwind CSS 的功能
 */

/* 全域樣式 */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 側邊欄樣式 */
.sidebar-transition {
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* 導航項目 hover 效果 */
.nav-item {
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background-color: #3B82F6;
    transition: height 0.3s ease;
}

.nav-item.bg-blue-50::before {
    height: 60%;
}

/* 卡片動畫效果 */
.fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 進度條動畫 */
.progress-bar {
    transition: width 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
    background: linear-gradient(90deg, #3B82F6, #1D4ED8);
}

/* 圖表容器 */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
}

/* 表單樣式增強 */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #FFFFFF;
    color: #374151 !important; /* 確保文字顏色是深色 */
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    color: #374151 !important; /* 聚焦時也保持深色文字 */
}

/* 佔位符文字顏色 */
input::placeholder,
select::placeholder,
textarea::placeholder {
    color: #9CA3AF;
    opacity: 1;
}

/* 選項顏色 */
select option {
    color: #374151;
    background: white;
}

/* 加強所有輸入框的文字顏色 */
input, select, textarea {
    color: #1f2937 !important; /* 更深的顏色 */
    background-color: #ffffff !important;
}

input:focus, select:focus, textarea:focus {
    color: #1f2937 !important;
}

/* 加強表單標籤顏色 */
label, .form-label {
    color: #374151 !important;
    font-weight: 600;
}

/* 加強一般文字顏色 */
.text-gray-700, .text-gray-600 {
    color: #374151 !important;
}

/* 加強按鈕文字 */
button {
    font-weight: 600;
}

/* 修正佔位符顏色 */
::placeholder {
    color: #6b7280 !important;
    opacity: 1;
}

/* 彈窗樣式 */
.modal-overlay {
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 載入動畫 */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #F3F4F6;
    border-top: 4px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .sidebar-transition {
        transform: translateX(-100%);
    }
    
    .sidebar-transition.show {
        transform: translateX(0);
    }
    
    .chart-container {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .chart-container {
        height: 200px;
    }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #F3F4F6;
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* 分類選擇器樣式 */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.icon-option {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.icon-option:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: scale(1.05);
}

.icon-option.active {
    border-color: #3b82f6;
    background: #3b82f6;
    color: white;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #e5e7eb;
    transition: all 0.2s ease;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: #374151;
}

.color-option.active {
    border-color: #374151;
    transform: scale(1.15);
    box-shadow: 0 0 0 2px #374151;
}