/**
 * Neo Framework - 共用樣式
 * 前後台都可使用的通用樣式
 *
 * @version 2.0.0 - 新增統一工具類
 * @date 2025-12-07
 */

/* ========================================
   共用 CSS 變數 (與 app.css 整合)
======================================== */
:root {
    /* 語意化顏色 */
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-danger-border: #fecaca;

    --color-success: #22c55e;
    --color-success-hover: #16a34a;
    --color-success-bg: #ecfdf5;

    --color-warning: #f59e0b;
    --color-warning-bg: #fff3cd;

    --color-info: #3b82f6;
    --color-info-bg: #eff6ff;

    /* 中性色 */
    --color-text: #333333;
    --color-text-secondary: #666666;
    --color-text-muted: #999999;
    --color-border: #eeeeee;
    --color-bg-light: #f5f5f5;

    /* 統一圓角 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 20px;
    --radius-full: 50%;

    /* 統一陰影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
}

/* 全域重置 */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

/* ========================================
   Flexbox 工具類 (減少重複)
======================================== */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* 對齊 */
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }

/* 常用組合 */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-col-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Gap 間距 */
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ========================================
   文字工具類
======================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   間距工具類
======================================== */
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

.p-8 { padding: 8px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
.px-12 { padding-left: 12px; padding-right: 12px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.py-8 { padding-top: 8px; padding-bottom: 8px; }
.py-12 { padding-top: 12px; padding-bottom: 12px; }

/* ========================================
   圓角工具類
======================================== */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-pill { border-radius: var(--radius-pill); }
.rounded-full { border-radius: var(--radius-full); }

/* ========================================
   常用元件樣式
======================================== */

/* 圓形頭像容器 */
.avatar-circle {
    border-radius: var(--radius-full);
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 漸層背景 (主色) */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--paws-primary, #FFBD59) 0%, var(--paws-primary-light, #FFCE80) 100%);
}

/* 危險按鈕樣式 */
.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid var(--color-danger-border);
}

.btn-danger:hover {
    background: #fee2e2;
    color: var(--color-danger-hover);
}

/* 播放按鈕覆蓋層 */
.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.play-overlay:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translate(-50%, -50%) scale(1.1);
}

/* 徽章/標籤 */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
}

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

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

.badge-warning {
    background: var(--color-warning-bg);
    color: #856404;
}

/* 卡片陰影 */
.card-shadow {
    box-shadow: var(--shadow-md);
}

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

/* 狀態標籤 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.status-draft {
    background: #fff3cd;
    color: #856404;
}

.status-published {
    background: #d1ecf1;
    color: #0c5460;
}

/* 圖片預覽 */
.image-preview {
    max-width: 200px;
    max-height: 200px;
    border: 2px solid #e1e8ed;
    border-radius: 4px;
    padding: 5px;
    object-fit: cover;
}

.form-input-reminder {
    font-size: .875rem;
    line-height: 1.4;
    color: #999;
    margin-top: 10px;
}

.uk-button {
    justify-content: center;
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.uk-notification-message {
    background: #2f2f2f;
    color: #fff;
    font-size: .9rem;
}

.uk-input,
.uk-select,
.uk-textarea,
.uk-button,
.uk-notification-message  {
    border-radius: 4px;
}

tr {
    transition: background-color 0.6s ease-out;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ==================== Neo Toggle Switch ==================== */
.neo-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.neo-toggle {
    position: relative;
    display: inline-block;
}

/* 尺寸變體 */
.neo-toggle-small {
    width: 36px;
    height: 20px;
}

.neo-toggle-medium {
    width: 44px;
    height: 24px;
}

.neo-toggle-large {
    width: 52px;
    height: 28px;
}

.neo-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.neo-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 50px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.neo-toggle-slider:before {
    position: absolute;
    content: "";
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 小尺寸滑塊 */
.neo-toggle-small .neo-toggle-slider:before {
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
}

/* 中尺寸滑塊 */
.neo-toggle-medium .neo-toggle-slider:before {
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
}

/* 大尺寸滑塊 */
.neo-toggle-large .neo-toggle-slider:before {
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
}

/* 選中狀態 - 滑塊位置 */
.neo-toggle-small input:checked + .neo-toggle-slider:before {
    transform: translateX(16px);
}

.neo-toggle-medium input:checked + .neo-toggle-slider:before {
    transform: translateX(20px);
}

.neo-toggle-large input:checked + .neo-toggle-slider:before {
    transform: translateX(24px);
}

/* 顏色變體 - Primary */
.neo-toggle-primary input:checked + .neo-toggle-slider {
    background-color: #1e87f0;
}

/* 顏色變體 - Success */
.neo-toggle-success input:checked + .neo-toggle-slider {
    background-color: #32d296;
}

/* 顏色變體 - Warning */
.neo-toggle-warning input:checked + .neo-toggle-slider {
    background-color: #faa05a;
}

/* 顏色變體 - Danger */
.neo-toggle-danger input:checked + .neo-toggle-slider {
    background-color: #f0506e;
}

/* 停用狀態 */
.neo-toggle input:disabled + .neo-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Focus 狀態 */
.neo-toggle input:focus + .neo-toggle-slider {
    box-shadow: 0 0 0 2px rgba(30, 135, 240, 0.3);
}

/* 標籤樣式 */
.neo-toggle-label,
.neo-toggle-label-on,
.neo-toggle-label-off {
    font-size: 14px;
    color: #666;
}

.neo-toggle-wrapper:hover .neo-toggle-label,
.neo-toggle-wrapper:hover .neo-toggle-label-on,
.neo-toggle-wrapper:hover .neo-toggle-label-off {
    color: #333;
}

/* ========================================
   Pull to Refresh (PWA 下拉刷新)
======================================== */
.pull-refresh-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transform: translateY(0);
    transition: opacity 0.2s ease;
}

.pull-refresh-indicator.visible {
    opacity: 1;
}

.pull-refresh-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--paws-card, #fff);
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 10px;
}

.pull-refresh-icon {
    font-size: 22px;
    color: var(--paws-primary, #6366f1);
    transition: transform 0.2s ease;
}

.pull-refresh-icon.spinning {
    animation: pull-refresh-spin 1s linear infinite;
}

.pull-refresh-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--paws-text, #333);
}

.pull-refresh-indicator.ready .pull-refresh-content {
    background: var(--paws-primary, #6366f1);
}

.pull-refresh-indicator.ready .pull-refresh-icon,
.pull-refresh-indicator.ready .pull-refresh-text {
    color: #fff;
}

.pull-refresh-indicator.refreshing .pull-refresh-content {
    background: var(--paws-primary, #6366f1);
}

.pull-refresh-indicator.refreshing .pull-refresh-icon,
.pull-refresh-indicator.refreshing .pull-refresh-text {
    color: #fff;
}

@keyframes pull-refresh-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
