:root {
    --warm: #D4A373;
    --warm-light: rgba(212,163,115,0.1);
    --cream: #FAEDCD;
    --coral: #E07A5F;
    --dark: #3D405B;
    --dark-deep: #2d2f45;
    --light-bg: #f5f6fa;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: var(--light-bg);
    margin: 0;
    color: #444;
}

.admin-wrapper { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.admin-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-deep) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.3s;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: opacity 0.2s;
}
.sidebar-brand:hover { opacity: 0.9; color: #fff; }
.sidebar-logo {
    height: 28px;
    width: auto;
}
.sidebar-brand i {
    color: var(--coral);
    font-size: 1.5rem;
    filter: drop-shadow(0 0 6px rgba(224,122,95,0.4));
}

.sidebar-close { color: #fff; padding: 0; }

.sidebar-nav { padding: 0.5rem 0; }
.sidebar-label {
    padding: 1.2rem 1.5rem 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}
.sidebar-nav .nav-link {
    color: rgba(255,255,255,0.6);
    padding: 0.65rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    margin: 1px 0;
}
.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}
.sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.15);
}
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(212,163,115,0.15);
    border-left-color: var(--warm);
    font-weight: 500;
}
.sidebar-nav .nav-link.active i { color: var(--warm); }
.sidebar-nav .nav-link.text-danger { color: rgba(224,122,95,0.7) !important; }
.sidebar-nav .nav-link.text-danger:hover { color: var(--coral) !important; background: rgba(224,122,95,0.08); }

.nav-divider { border-top: 1px solid rgba(255,255,255,0.06); margin: 0.5rem 1rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1030;
    backdrop-filter: blur(2px);
}

/* ===== Main Area ===== */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.admin-header {
    background: #fff;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eef0f3;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 60px;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.page-title { font-weight: 700; color: var(--dark); font-size: 1.05rem; }

.header-right { display: flex; align-items: center; gap: 1rem; }
.header-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.8rem 0.35rem 0.5rem;
    border-radius: 50px;
    background: var(--light-bg);
    font-size: 0.88rem;
    color: var(--dark);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}
.header-user:hover { background: #ecedf2; }
.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--warm);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}
.header-greeting {
    font-size: 0.82rem;
    color: var(--warm);
}

/* ===== Content ===== */
.admin-content { padding: 1.5rem; flex: 1; }

/* ===== Cards ===== */
.card {
    border-radius: var(--radius) !important;
    border: none !important;
}
.card.shadow-sm { box-shadow: var(--shadow) !important; }
.card-header {
    border-bottom: 1px solid #f0f1f5 !important;
    padding: 1rem 1.25rem !important;
    font-weight: 600;
}
.card-header h6 { font-weight: 600; color: var(--dark); }
.card-body { padding: 1.25rem !important; }

/* ===== Stat Cards ===== */
.stat-card {
    transition: all 0.3s;
    overflow: hidden;
    position: relative;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg) !important;
}
.stat-card:nth-child(1) .stat-card::before,
.col-md-4:nth-child(1) .stat-card::before { background: var(--warm); }
.col-md-4:nth-child(2) .stat-card::before { background: var(--coral); }
.col-md-4:nth-child(3) .stat-card::before { background: #27ae60; }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    flex-shrink: 0;
}
.bg-warm { background: linear-gradient(135deg, var(--warm), #c49363); }
.bg-coral { background: linear-gradient(135deg, var(--coral), #d06a4f); }
.bg-success-soft { background: linear-gradient(135deg, #27ae60, #219a52); }

.stat-card h3 { font-weight: 700; color: var(--dark); font-size: 1.6rem; }
.stat-card small { font-size: 0.82rem; }

/* ===== Tables ===== */
.table { font-size: 0.9rem; }
.table thead th {
    background: #f8f9fc;
    color: var(--dark);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #eef0f3;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}
.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f2f3f7;
    color: #555;
}
.table tbody tr:hover { background: rgba(212,163,115,0.04); }
.table tbody tr:last-child td { border-bottom: none; }

.thumb-sm {
    width: 56px;
    height: 38px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #eee;
}

/* ===== Badges ===== */
.badge { font-weight: 500; font-size: 0.75rem; padding: 0.35em 0.7em; border-radius: 6px; }
.badge.bg-success { background: #e6f8ee !important; color: #1a8a4a !important; }
.badge.bg-danger { background: #fde8e4 !important; color: #c0392b !important; }
.badge.bg-secondary { background: #ecedf2 !important; color: #555 !important; }
.badge.bg-info { background: #e3f0fc !important; color: #2471a3 !important; }

/* ===== Buttons ===== */
.btn { border-radius: 8px; font-weight: 500; font-size: 0.9rem; transition: all 0.2s; }
.btn-sm { border-radius: 6px; font-size: 0.82rem; padding: 0.3rem 0.6rem; }
.btn-lg { border-radius: 10px; }

.btn-primary { background: var(--warm); border-color: var(--warm); color: #fff; }
.btn-primary:hover { background: #c49363; border-color: #c49363; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(212,163,115,0.3); }
.btn-primary:active { transform: translateY(0); }

.btn-outline-primary { color: var(--warm); border-color: #ddd; }
.btn-outline-primary:hover { background: var(--warm); color: #fff; border-color: var(--warm); }

.btn-outline-danger { border-color: #ddd; color: #999; }
.btn-outline-danger:hover { background: var(--coral); color: #fff; border-color: var(--coral); }

.btn-outline-secondary { border-color: #ddd; color: #777; }
.btn-outline-secondary:hover { background: #f5f5f5; border-color: #ccc; color: #555; }

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: 8px;
    border-color: #e0e2e8;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--warm);
    box-shadow: 0 0 0 3px rgba(212,163,115,0.12);
}
.form-label { font-size: 0.88rem; color: var(--dark); margin-bottom: 0.4rem; }
.form-text { font-size: 0.78rem; color: #999; }
.form-check-input:checked { background-color: var(--warm); border-color: var(--warm); }
.slug-prefix {
    font-size: 0.82rem;
    background: #f8f9fc;
    color: #888;
    border-color: #e0e2e8;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Alerts ===== */
.alert { border-radius: var(--radius); border: none; font-size: 0.9rem; }
.alert-success { background: #e6f8ee; color: #1a8a4a; }
.alert-danger { background: #fde8e4; color: #c0392b; }
.alert-warning { background: #fef3e2; color: #b8860b; }
.alert-info { background: #e3f0fc; color: #2471a3; }

/* ===== Batch Toolbar ===== */
.batch-toolbar {
    background: var(--cream);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
}

/* ===== DataTables Override ===== */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #e0e2e8;
    padding: 0.4rem 0.8rem;
    font-size: 0.88rem;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--warm);
    box-shadow: 0 0 0 3px rgba(212,163,115,0.12);
    outline: none;
}
.dataTables_wrapper .dataTables_length select {
    border-radius: 6px;
    border: 1px solid #e0e2e8;
    padding: 0.3rem 1.8rem 0.3rem 0.5rem;
    min-width: 65px;
    margin: 0 0.4rem;
}
.dataTables_wrapper .dataTables_info { font-size: 0.82rem; color: #999; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    font-size: 0.85rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--warm) !important;
    border-color: var(--warm) !important;
    color: #fff !important;
}

/* ===== Image Dropzone ===== */
.image-dropzone {
    border: 2px dashed #d0d3da;
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafbfc;
    position: relative;
}
.image-dropzone:hover {
    border-color: var(--warm);
    background: var(--warm-light);
}
.image-dropzone.dragover {
    border-color: var(--warm);
    background: var(--warm-light);
    box-shadow: 0 0 0 4px rgba(212,163,115,0.15);
}
.image-dropzone.has-image {
    padding: 0;
    border-style: solid;
    border-color: #eee;
}
.image-dropzone.has-image:hover {
    border-color: var(--warm);
}
.dropzone-placeholder i {
    font-size: 2.5rem;
    color: #bfc3cc;
    margin-bottom: 0.5rem;
}
.dropzone-placeholder p {
    margin: 0;
    color: #888;
    font-size: 0.88rem;
}
.dropzone-placeholder .dropzone-hint {
    font-size: 0.78rem;
    color: #aaa;
    margin-top: 0.3rem;
}
.dropzone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.dropzone-preview {
    position: relative;
}
.dropzone-preview img {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 10px;
    display: block;
    background: #f5f5f5;
}
.dropzone-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.2s;
}
.image-dropzone:hover .dropzone-remove {
    opacity: 1;
}
.gallery-dropzone .dropzone-preview img {
    max-height: 120px;
}
.dropzone-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.image-dropzone:hover .dropzone-actions {
    opacity: 1;
}
.dropzone-actions .btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    backdrop-filter: blur(6px);
    font-size: 0.9rem;
}
.dropzone-actions .btn-edit {
    background: rgba(255,255,255,0.9);
    color: var(--dark);
    border: 1px solid rgba(0,0,0,0.1);
}
.dropzone-actions .btn-edit:hover {
    background: var(--warm);
    color: #fff;
    border-color: var(--warm);
}
.dropzone-actions .btn-remove {
    background: rgba(255,255,255,0.9);
    color: var(--coral);
    border: 1px solid rgba(0,0,0,0.1);
}
.dropzone-actions .btn-remove:hover {
    background: var(--coral);
    color: #fff;
    border-color: var(--coral);
}

/* ===== Focus Grid ===== */
.focus-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 160px;
}
.focus-cell {
    width: 48px;
    height: 48px;
    border: 1px solid #e0e2e8;
    border-radius: 6px;
    background: #fafbfc;
    cursor: pointer;
    font-size: 1rem;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}
.focus-cell:hover {
    border-color: var(--warm);
    color: var(--warm);
    background: var(--warm-light);
}
.focus-cell.active {
    background: var(--warm);
    color: #fff;
    border-color: var(--warm);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(212,163,115,0.3);
}

/* ===== Image Info ===== */
.image-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    padding: 0.6rem 0 0;
    font-size: 0.78rem;
    color: #888;
}
.image-info span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.image-info i {
    font-size: 0.82rem;
    color: #aaa;
}

/* ===== Image Editor Modal ===== */
.image-editor-modal .modal-dialog {
    max-width: 900px;
}
.image-editor-modal .modal-body {
    padding: 0;
    background: #1a1a2e;
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-editor-modal .cropper-container {
    max-height: 60vh;
}
.editor-canvas-wrap {
    width: 100%;
    max-height: 60vh;
    overflow: hidden;
}
.editor-canvas-wrap img {
    max-width: 100%;
    display: block;
}
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.75rem 1rem;
    background: #f8f9fc;
    border-top: 1px solid #eee;
}
.editor-toolbar .btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 8px;
    background: #fff;
    color: var(--dark);
    border: 1px solid #e0e2e8;
}
.editor-toolbar .btn:hover {
    background: var(--warm);
    color: #fff;
    border-color: var(--warm);
}
.editor-toolbar .btn.active {
    background: var(--warm);
    color: #fff;
    border-color: var(--warm);
}
.editor-toolbar .toolbar-divider {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 0.3rem;
}
.editor-toolbar .ratio-btns .btn {
    width: auto;
    padding: 0 0.6rem;
    font-size: 0.78rem;
    font-weight: 500;
}

/* ===== SEO Panel ===== */
.collapse .card-body, .card-body .form-label {
    font-size: 0.88rem;
}
.seo-counter {
    font-size: 0.75rem;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}
.seo-counter.warn { color: #e67e22; }
.seo-counter.danger { color: var(--coral); }
.seo-counter.good { color: #27ae60; }
.seo-preview-box {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    padding: 1rem;
    margin-top: 0.25rem;
}
.seo-preview-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.seo-preview-title {
    font-size: 1.1rem;
    color: #1a0dab;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.seo-preview-url {
    font-size: 0.8rem;
    color: #006621;
    margin: 0.15rem 0;
}
.seo-preview-desc {
    font-size: 0.82rem;
    color: #545454;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Gemini Panel ===== */
.btn-gemini-text {
    background: linear-gradient(135deg, #4285f4, #6c5ce7);
    color: #fff;
    border: none;
}
.btn-gemini-text:hover {
    background: linear-gradient(135deg, #3574e0, #5b4bd5);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66,133,244,0.3);
}
.btn-gemini-img {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #fff;
    border: none;
}
.btn-gemini-img:hover {
    background: linear-gradient(135deg, #219a52, #27ae60);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39,174,96,0.3);
}

/* ===== AI Progress ===== */
.ai-progress-wrap {
    background: #f8f9fc;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #eef0f3;
}
.ai-progress-bar {
    height: 6px;
    background: #e8e9ee;
    border-radius: 3px;
    overflow: hidden;
}
.ai-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4285f4, #6c5ce7);
    border-radius: 3px;
    transition: width 0.6s ease;
}
.ai-progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}
.ai-progress-step { color: var(--dark); font-weight: 500; }
.ai-progress-pct { color: #888; }
.ai-progress-steps {
    display: flex;
    gap: 0.2rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}
.ai-step {
    font-size: 0.72rem;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s;
}
.ai-step i { font-size: 0.6rem; }
.ai-step.active {
    color: #4285f4;
    background: rgba(66,133,244,0.08);
}
.ai-step.active i::before { content: '\F544'; }
.ai-step.done {
    color: #27ae60;
}
.ai-step.done i::before { content: '\F26B'; }

/* ===== Page Title Bar ===== */
.page-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-title-bar h5 {
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    font-size: 1.15rem;
}

/* ===== Homepage Admin Tabs ===== */
.nav-pills {
    background: #fff;
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow);
    gap: 4px;
}
.nav-pills .nav-link {
    color: var(--dark);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}
.nav-pills .nav-link i {
    font-size: 1rem;
    vertical-align: -1px;
}
.nav-pills .nav-link:hover {
    background: var(--warm-light);
    color: var(--coral);
}
.nav-pills .nav-link.active {
    background: linear-gradient(135deg, var(--warm), var(--coral));
    color: #fff;
    box-shadow: 0 4px 14px rgba(212, 163, 115, 0.4);
    border-color: transparent;
}
.nav-pills .nav-link.active i {
    color: #fff;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-sidebar.show + .sidebar-overlay { display: block; }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 1rem; }
    .stat-card h3 { font-size: 1.3rem; }
}
@media (max-width: 575.98px) {
    .page-title-bar { flex-direction: column; gap: 0.8rem; align-items: flex-start; }
}
