/*
 * =====================================================
 * 動物森友會風格 CSS
 * Animal Crossing Style CSS
 * =====================================================
 */

/* ===== 基礎變數 ===== */
:root {
    /* 主要配色 - 動物森友會綠色系 */
    --ac-green-light: #a8e6cf;
    --ac-green: #88d8b0;
    --ac-green-dark: #6cc299;

    /* 輔助配色 */
    --ac-yellow: #ffeaa7;
    --ac-yellow-dark: #fdcb6e;
    --ac-blue: #81ecec;
    --ac-blue-dark: #00cec9;
    --ac-pink: #fab1a0;
    --ac-pink-light: #ffeef0;
    --ac-brown: #b17a50;
    --ac-brown-dark: #8b5a2b;

    /* 背景色 */
    --bg-color: #f0fff4;
    --bg-card: #ffffff;
    --bg-overlay: rgba(255, 255, 255, 0.95);

    /* 文字色 */
    --text-primary: #2d5a27;
    --text-secondary: #5a8a54;
    --text-muted: #88b084;

    /* 陰影 */
    --shadow-sm: 0 2px 8px rgba(45, 90, 39, 0.1);
    --shadow-md: 0 4px 16px rgba(45, 90, 39, 0.15);
    --shadow-lg: 0 8px 32px rgba(45, 90, 39, 0.2);

    /* 圓角 */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    /* 字體 */
    --font-family: 'Noto Sans TC', 'Segoe UI', sans-serif;
}

/* ===== 基礎樣式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

/* 裝飾背景 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 20%, rgba(168, 230, 207, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(255, 234, 167, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(129, 236, 236, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ===== 浮動裝飾元素 ===== */
.floating-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.leaf {
    position: absolute;
    font-size: 24px;
    animation: float-leaf 15s ease-in-out infinite;
    opacity: 0.6;
}

.leaf:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
}

.leaf:nth-child(2) {
    left: 30%;
    animation-delay: 3s;
}

.leaf:nth-child(3) {
    left: 50%;
    animation-delay: 6s;
}

.leaf:nth-child(4) {
    left: 70%;
    animation-delay: 9s;
}

.leaf:nth-child(5) {
    left: 90%;
    animation-delay: 12s;
}

@keyframes float-leaf {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.star {
    position: absolute;
    font-size: 16px;
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ===== 容器 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.container-wide {
    max-width: 90%;
}

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 20px;
    border: 3px solid var(--ac-green-light);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--ac-green), var(--ac-yellow), var(--ac-blue));
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title::before {
    content: '🍃';
}

/* ===== 按鈕 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ac-green), var(--ac-green-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(108, 194, 153, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 194, 153, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--ac-yellow), var(--ac-yellow-dark));
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(253, 203, 110, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(253, 203, 110, 0.5);
}

.btn-danger {
    background: linear-gradient(135deg, var(--ac-pink), #e17055);
    color: white;
    box-shadow: 0 4px 12px rgba(250, 177, 160, 0.4);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(250, 177, 160, 0.5);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--ac-green);
    color: var(--ac-green-dark);
}

.btn-outline:hover {
    background: var(--ac-green);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.125rem;
}

/* ===== 輸入框 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--ac-green-light);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 1rem;
    color: var(--text-primary);
    background: white;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--ac-green);
    box-shadow: 0 0 0 4px rgba(136, 216, 176, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ===== 導航欄 ===== */
.navbar {
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid var(--ac-green-light);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.navbar-brand img {
    width: 40px;
    height: 40px;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    list-style: none;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    background: var(--ac-green-light);
    color: var(--text-primary);
}

/* ===== 手冊列表 ===== */
.manual-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.manual-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 3px solid var(--ac-green-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.manual-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--ac-green);
}

.manual-card-header {
    background: linear-gradient(135deg, var(--ac-green-light), var(--ac-yellow));
    padding: 20px;
    position: relative;
}

.manual-card-header::after {
    content: '📖';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
}

.manual-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    padding-right: 50px;
}

.manual-card-cover-wrap {
    width: 100%;
    height: 120px;
    overflow: hidden;
}

.manual-card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.manual-card-body {
    padding: 20px;
}

.manual-card-summary {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.manual-card-footer {
    padding: 16px 20px;
    border-top: 2px dashed var(--ac-green-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.manual-card-date {
    font-size: 0.825rem;
    color: var(--text-muted);
}

.manual-card-actions {
    display: flex;
    gap: 8px;
}

/* ===== 自訂對話框 ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 90, 39, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 4px solid var(--ac-green);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
    position: relative;
}

.dialog-overlay.active .dialog {
    transform: scale(1) translateY(0);
}

.dialog-header {
    background: linear-gradient(135deg, var(--ac-green-light), var(--ac-green));
    padding: 20px 24px;
    border-bottom: 3px solid var(--ac-green);
    display: flex;
    align-items: center;
    gap: 12px;
}

.dialog-header::before {
    content: '💬';
    font-size: 1.5rem;
}

.dialog-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.dialog-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.dialog-close:hover {
    background: white;
    transform: rotate(90deg);
}

.dialog-body {
    padding: 24px;
}

.dialog-message {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.dialog-footer {
    padding: 16px 24px;
    border-top: 2px dashed var(--ac-green-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== 圖片放大 ===== */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    cursor: zoom-out;
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.image-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--ac-green);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.image-lightbox-close:hover {
    background: var(--ac-green-dark);
    transform: scale(1.1);
}

/* ===== 編輯器 ===== */
.editor-container {
    border: 3px solid var(--ac-green-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: white;
}

.ql-toolbar {
    border: none !important;
    border-bottom: 2px solid var(--ac-green-light) !important;
    background: linear-gradient(135deg, var(--ac-green-light), var(--ac-yellow)) !important;
}

.ql-container {
    border: none !important;
    font-family: var(--font-family) !important;
    font-size: 1rem !important;
}

.ql-editor {
    min-height: 400px;
    padding: 20px;
    line-height: 1.8;
}

.ql-editor:focus {
    outline: none;
}

/* Quill tooltip 修復 */
.ql-tooltip {
    z-index: 100;
    background: white !important;
    border: 2px solid var(--ac-green) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 10px 15px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
}

.ql-tooltip input[type="text"] {
    border: 2px solid var(--ac-green-light) !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    width: 250px !important;
}

.ql-tooltip a.ql-action,
.ql-tooltip a.ql-remove {
    color: var(--ac-green-dark) !important;
    margin-left: 10px !important;
}

.ql-tooltip a.ql-action::after {
    content: '儲存' !important;
}

.ql-tooltip a.ql-remove::before {
    content: '移除' !important;
}

.ql-tooltip.ql-editing a.ql-action::after {
    content: '儲存' !important;
}

/* 確保編輯器容器不會裁切 tooltip */
.editor-container {
    overflow: visible !important;
    position: relative;
}

.ql-container {
    overflow: visible !important;
}

/* ===== 載入動畫 ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--ac-green-light);
    border-top-color: var(--ac-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-left: 16px;
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ===== 空狀態 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.empty-state-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ===== 標籤 ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--ac-green-light);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    font-size: 0.825rem;
    font-weight: 500;
}

.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ===== 分頁 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    padding: 20px;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-page {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ac-green-light);
    border-radius: var(--radius-full);
    background: white;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-page:hover {
    background: var(--ac-green-light);
}

.pagination-page.active {
    background: var(--ac-green);
    border-color: var(--ac-green);
    color: white;
    cursor: default;
}

.pagination-ellipsis {
    color: var(--text-muted);
    padding: 0 8px;
}

button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Toast 通知 ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 16px 20px;
    border-left: 4px solid var(--ac-green);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
    animation: toast-in 0.3s ease;
}

.toast.toast-success {
    border-left-color: var(--ac-green);
}

.toast.toast-error {
    border-left-color: #e17055;
}

.toast.toast-warning {
    border-left-color: var(--ac-yellow-dark);
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .navbar {
        padding: 12px 0;
    }

    .navbar-content {
        flex-direction: column;
        gap: 12px;
        padding: 0 12px;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    .navbar-nav {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 0.9rem;
    }

    /* 首頁標題區 */
    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch !important;
    }

    .page-header .d-flex {
        flex-direction: column;
        gap: 8px;
    }

    .page-header .form-input {
        max-width: 100% !important;
    }

    .card-title {
        font-size: 1.25rem;
    }

    .manual-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .manual-card-header {
        padding: 16px;
    }

    .manual-card-title {
        font-size: 1.1rem;
    }

    .manual-card-body {
        padding: 16px;
    }

    .manual-card-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .manual-card-date {
        text-align: center;
    }

    .manual-card-actions {
        justify-content: center;
    }

    .card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .dialog {
        width: 95%;
        max-height: 85vh;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 8px 12px;
    }

    .form-input,
    .form-textarea,
    .form-select {
        padding: 12px 14px;
        font-size: 16px;
        /* 防止 iOS 縮放 */
    }

    .ql-editor {
        min-height: 250px;
        padding: 16px;
    }

    .ql-toolbar {
        flex-wrap: wrap;
    }

    .empty-state {
        padding: 40px 16px;
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .empty-state-title {
        font-size: 1.25rem;
    }

    /* Toast 調整 */
    .toast-container {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 20px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* 更小螢幕 */
@media (max-width: 480px) {
    .navbar-brand {
        font-size: 1.1rem;
    }

    .navbar-nav {
        flex-wrap: wrap;
    }

    .btn {
        padding: 8px 14px;
    }

    .card-title::before {
        display: none;
    }
}

/* ===== 手機版隱藏/顯示 ===== */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }
}

/* ===== 工具類別 ===== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mt-4 {
    margin-top: 32px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mb-4 {
    margin-bottom: 32px;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.gap-3 {
    gap: 24px;
}

.w-100 {
    width: 100%;
}

.hidden {
    display: none !important;
}