/* =============================================
   Shared Theme — Material Design 3
   
   所有後台頁面共用的 M3 design tokens 與基礎樣式。
   與 admin-layout.css 搭配使用。
   ============================================= */

/* ── Design Tokens ── */
:root {
    /* Colors — Indigo System */
    --s79-primary: #6366f1;
    --s79-primary-hover: #4f46e5;
    --s79-primary-light: #ede9fe;
    --s79-primary-subtle: rgba(99, 102, 241, 0.08);
    --s79-primary-glow: rgba(99, 102, 241, 0.15);
    --s79-success: #10b981;
    --s79-success-light: #d1fae5;
    --s79-warning: #f59e0b;
    --s79-warning-light: #fef3c7;
    --s79-error: #ef4444;
    --s79-error-light: #fee2e2;

    /* Colors — Neutral */
    --s79-bg: #f6f7f9;
    --s79-surface: #ffffff;
    --s79-surface-hover: #f0f1f3;
    --s79-surface-alt: #eef0f4;
    --s79-border: #e2e5ea;
    --s79-border-strong: #c4c8d0;
    --s79-text: #1a1a2e;
    --s79-text-secondary: #6b7280;
    --s79-text-muted: #9ca3af;

    /* Typography */
    --s79-font: 'Google Sans', 'Roboto', 'Noto Sans TC', system-ui, -apple-system, sans-serif;

    /* Radius */
    --s79-radius-sm: 10px;
    --s79-radius-md: 14px;
    --s79-radius-lg: 16px;
    --s79-radius-xl: 28px;
    --s79-radius-full: 9999px;

    /* Shadow */
    --s79-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --s79-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --s79-shadow-md: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.06);
    --s79-shadow-lg: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.08);
    --s79-shadow-xl: 0 2px 6px rgba(0, 0, 0, 0.06), 0 16px 48px rgba(0, 0, 0, 0.12);
    --s79-shadow-focus: 0 0 0 3px rgba(99, 102, 241, 0.12);
    --s79-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04);
    --s79-shadow-card-hover: 0 8px 24px rgba(99, 102, 241, 0.08);
    --s79-shadow-primary-glow: 0 4px 16px rgba(99, 102, 241, 0.2);

    /* Duration */
    --s79-duration: 200ms;
    --s79-duration-md: 250ms;
    --s79-duration-lg: 350ms;

    /* ── Layout ── */
    --sidebar-w: 260px;
    --content-bg: #f6f7f9;
    --border-color: #e2e5ea;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --bg-hover: rgba(0, 0, 0, 0.03);
    --header-h: 60px;

    /* ── Shortcuts ── */
    --primary: #6366f1;
    --text-1: #1a1a2e;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --border: #e2e5ea;
    --bg-2: #eef0f4;
}

/* ── Base Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ── Body ── */
body {
    font-family: var(--s79-font);
    background: var(--s79-bg);
    color: var(--s79-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

@media (max-width: 768px) {
    body { padding-left: 0; }
}

body.sidebar-closed {
    padding-left: 0;
}

/* ── Google Sans + Roboto font import ── */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@300;400;500;700&display=swap');

/* ── Admin Header Override — M3 Top App Bar ── */
.admin-header {
    background: #ffffff;
    border-bottom: 1px solid var(--s79-border);
    height: var(--header-h);
    font-family: var(--s79-font);
    box-shadow: none;
}

.admin-header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--s79-text);
}

/* ── Shared Button Styles — M3 ── */
.s79-btn,
.admin-header-actions .btn,
button.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--s79-font);
    cursor: pointer;
    transition: background var(--s79-duration) ease, box-shadow var(--s79-duration) ease;
    border: 1px solid transparent;
    min-height: 40px;
    line-height: 1;
    letter-spacing: 0.01em;
}

.s79-btn:focus-visible {
    outline: none;
    box-shadow: var(--s79-shadow-focus);
}

.s79-btn-primary {
    background: var(--s79-primary);
    color: #fff;
    border-color: var(--s79-primary);
    box-shadow: none;
}

.s79-btn-primary:hover {
    background: var(--s79-primary-hover);
    box-shadow: var(--s79-shadow-sm);
}

.s79-btn-primary:active {
    background: #1557b0;
}

.s79-btn-ghost {
    background: transparent;
    color: var(--s79-text-secondary);
    border-color: var(--s79-border);
}

.s79-btn-ghost:hover {
    background: var(--s79-surface-hover);
    border-color: var(--s79-border-strong);
}

.s79-btn-danger {
    background: var(--s79-error);
    color: #fff;
}

.s79-btn-danger:hover {
    background: #c5221f;
}

.s79-btn .material-symbols-outlined,
.s79-btn .material-symbols-rounded {
    font-size: 18px;
}

/* ── Card — M3 Elevated ── */
.s79-card {
    background: var(--s79-surface);
    border: 1px solid var(--s79-border);
    border-radius: var(--s79-radius-lg);
    overflow: hidden;
    box-shadow: var(--s79-shadow-card);
    transition: box-shadow var(--s79-duration-md) ease;
}

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

.s79-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--s79-border);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.s79-card-body {
    padding: 20px;
}

/* ── Table — M3 Data Table ── */
.s79-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.s79-table th {
    background: transparent;
    border-bottom: 1px solid var(--s79-border);
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--s79-text-secondary);
    letter-spacing: 0.01em;
}

.s79-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--s79-border);
    color: var(--s79-text);
}

.s79-table tbody tr {
    transition: background var(--s79-duration) ease;
}

.s79-table tbody tr:nth-child(even) {
    background: transparent;
}

.s79-table tbody tr:hover td {
    background: rgba(0, 0, 0, 0.04);
}

/* ── Badge ── */
.s79-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--s79-radius-full);
    letter-spacing: 0.02em;
}

.s79-badge-primary { background: var(--s79-primary-light); color: var(--s79-primary); }
.s79-badge-success { background: var(--s79-success-light); color: #188038; }
.s79-badge-warning { background: var(--s79-warning-light); color: #e37400; }
.s79-badge-error { background: var(--s79-error-light); color: var(--s79-error); }
.s79-badge-neutral { background: #F3F4F6; color: var(--s79-text-muted); }

/* ── Input / Select ── */
.s79-input,
.s79-select,
.s79-textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1.5px solid var(--s79-border);
    border-radius: var(--s79-radius-sm);
    font-size: 14px;
    font-family: var(--s79-font);
    background: var(--s79-surface);
    color: var(--s79-text);
    outline: none;
    transition: border-color var(--s79-duration) ease, box-shadow var(--s79-duration) ease;
}

.s79-input:focus,
.s79-select:focus,
.s79-textarea:focus {
    border-color: var(--s79-primary);
    box-shadow: var(--s79-shadow-focus);
}

.s79-textarea {
    resize: vertical;
    min-height: 60px;
}

/* ── Modal — Premium ── */
.s79-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
}

.s79-modal-overlay.show { display: flex; }

.s79-modal {
    background: var(--s79-surface);
    border-radius: var(--s79-radius-lg);
    width: min(520px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: var(--s79-shadow-xl);
    animation: s79ModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes s79ModalIn {
    from { transform: translateY(12px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.s79-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

/* ── Form Group ── */
.s79-form-group {
    margin-bottom: 16px;
}

.s79-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--s79-text);
    margin-bottom: 6px;
}

/* ── Toast — positioned bottom-right ── */
.s79-toast,
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1F2937;
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--s79-radius-sm);
    font-size: 13px;
    z-index: 999;
    animation: s79-toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--s79-font);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    font-weight: 500;
    border-left: 3px solid var(--s79-primary);
}

@keyframes s79-toast-in {
    from { transform: translateY(12px) scale(0.96); opacity: 0; }
}

/* ── Empty State ── */
.s79-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--s79-text-muted);
}

.s79-empty .material-symbols-outlined,
.s79-empty .material-symbols-rounded {
    font-size: 48px;
    opacity: 0.15;
    display: block;
    margin: 0 auto 12px;
}

/* ── Stat Card ── */
.s79-stat,
.stat-card {
    background: var(--s79-surface);
    border: 1.5px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--s79-radius-md);
    padding: 18px 20px;
    box-shadow: var(--s79-shadow-card);
    transition: all 0.25s cubic-bezier(.4,0,.2,1);
    position: relative;
    overflow: hidden;
}

.s79-stat:hover,
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--s79-shadow-card-hover);
}

.s79-stat-value,
.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: -0.03em;
    color: var(--s79-text);
}

.s79-stat-label,
.stat-card .stat-label {
    font-size: 0.68rem;
    color: var(--s79-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Pagination ── */
.s79-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}

.s79-page-btn {
    padding: 6px 12px;
    border: 1px solid var(--s79-border);
    border-radius: var(--s79-radius-sm);
    background: var(--s79-surface);
    color: var(--s79-text-secondary);
    font-size: 13px;
    font-family: var(--s79-font);
    cursor: pointer;
    transition: all var(--s79-duration) ease;
}

.s79-page-btn:hover { background: var(--s79-surface-hover); }
.s79-page-btn:disabled { opacity: 0.4; cursor: default; }
.s79-page-btn.active { background: var(--s79-primary); color: #fff; border-color: var(--s79-primary); }

/* ── Search Bar ── */
.s79-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1.5px solid var(--s79-border);
    border-radius: var(--s79-radius-sm);
    background: var(--s79-surface);
    transition: border-color var(--s79-duration) ease, box-shadow var(--s79-duration) ease;
}

.s79-search:focus-within {
    border-color: var(--s79-primary);
    box-shadow: var(--s79-shadow-focus);
}

.s79-search input {
    border: none;
    outline: none;
    font-size: 13px;
    font-family: var(--s79-font);
    background: transparent;
    flex: 1;
    color: var(--s79-text);
}

.s79-search .material-symbols-outlined,
.s79-search .material-symbols-rounded {
    font-size: 16px;
    color: var(--s79-text-muted);
}

/* ── Tabs — M3 ── */
.s79-tabs {
    display: flex;
    border-bottom: 1px solid var(--s79-border);
    gap: 0;
}

.s79-tab {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--s79-text-secondary);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-family: var(--s79-font);
    transition: all var(--s79-duration) ease;
}

.s79-tab:hover { color: var(--s79-text); background: rgba(0, 0, 0, 0.04); }
.s79-tab.active { color: var(--s79-primary); border-bottom-color: var(--s79-primary); font-weight: 500; }

/* ── Chip / Tag ── */
.s79-chip {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: var(--s79-radius-full);
    background: #F3F4F6;
    color: var(--s79-text-muted);
    border: none;
}

/* ── Loading ── */
.s79-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--s79-border);
    border-top-color: var(--s79-primary);
    border-radius: 50%;
    animation: s79-spin 0.6s linear infinite;
}

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

/* ── Page Entrance Animation ── */
@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-container,
.container,
.admin-main > .admin-header ~ *:not(.admin-header) {
    animation: pageFadeIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Stagger animation for stat cards */
.stat-card,
.s79-stat {
    animation: pageFadeIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.stats-row .stat-card:nth-child(1),
.stats-grid .stat-card:nth-child(1),
.stats-bar .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-row .stat-card:nth-child(2),
.stats-grid .stat-card:nth-child(2),
.stats-bar .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-row .stat-card:nth-child(3),
.stats-grid .stat-card:nth-child(3),
.stats-bar .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-row .stat-card:nth-child(4),
.stats-grid .stat-card:nth-child(4),
.stats-bar .stat-card:nth-child(4) { animation-delay: 0.2s; }

/* ── Override existing page-specific styles ── */

.topbar {
    background: #ffffff !important;
    border-bottom: 1px solid var(--s79-border) !important;
    font-family: var(--s79-font);
}

button, .btn, input[type="submit"] {
    font-family: var(--s79-font);
    border-radius: 10px;
}

.btn-primary,
.btn-dark {
    background: var(--s79-primary);
    border-color: var(--s79-primary);
}

.btn-primary:hover,
.btn-dark:hover {
    background: var(--s79-primary-hover);
}

/* Table overrides for existing pages — M3 clean */
table {
    border-collapse: collapse;
    font-family: var(--s79-font);
}

table th {
    font-size: 12px;
    font-weight: 500;
    color: var(--s79-text-secondary);
    letter-spacing: 0.01em;
}

table tbody tr:nth-child(even) {
    background: transparent;
}

table tbody tr:hover td {
    background: rgba(0, 0, 0, 0.04);
}

/* Data table card wrapper */
.data-table-wrap,
.table-wrap {
    background: var(--s79-surface);
    border: 1px solid var(--s79-border);
    border-radius: var(--s79-radius-md);
    overflow-x: auto;
    box-shadow: var(--s79-shadow-card);
}

.table-wrap table {
    min-width: 900px;
    width: 100%;
}

.table-wrap td,
.table-wrap th {
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure all inputs get consistent styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="url"],
textarea,
select {
    font-family: var(--s79-font);
    border-radius: var(--s79-radius-sm);
}

/* ── Project / HW cards — M3 elevation ── */
.project-card,
.hw-card,
.project-mini-card,
.pcard-top {
    box-shadow: var(--s79-shadow-card);
}

.project-card:hover,
.hw-card:hover,
.project-mini-card:hover {
    box-shadow: var(--s79-shadow-card-hover);
}

/* ── Global content animations ── */
@keyframes contentFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* Scrollbar styling — M3 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bdc1c6; }

/* ── Print ── */
@media print {
    .admin-sidebar,
    .admin-sidebar-overlay,
    .admin-hamburger { display: none !important; }
    body { padding-left: 0 !important; }
}
