:root {
    --primary: #1a3a6b;
    --primary-dark: #0f2548;
    --primary-light: #e8eef7;
    --accent: #3b7dd8;
    --danger: #dc3545;
    --danger-light: #fce8ea;
    --success: #28a745;
    --dark: #1a1a1a;
    --text: #333;
    --text-light: #666;
    --text-lighter: #999;
    --bg: #f0f2f5;
    --white: #fff;
    --border: #e0e3e8;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 8px;
    --sidebar-w: 240px;
    --font: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    --font-en: 'Montserrat', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* ============ Login Page ============ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f2548 0%, #1a3a6b 50%, #2a5a9b 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 48px 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    height: 40px;
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: 2px;
}

.login-header p {
    font-family: var(--font-en);
    font-size: 0.75rem;
    color: var(--text-lighter);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,125,216,0.1);
}

.login-error {
    display: none;
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--danger-light);
    border-radius: var(--radius);
}

.login-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(26,58,107,0.3);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
}

.login-footer a {
    color: var(--text-lighter);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.login-footer a:hover {
    color: var(--accent);
}

/* ============ Sidebar ============ */

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--primary-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    height: 28px;
    filter: brightness(0) invert(1);
}

.sidebar-header span {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.8;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-link:hover, .sidebar-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.badge {
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b7dd8;
    display: inline-block;
}

.unread-dot.read {
    background: #ddd;
}

.inquiry-msg {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-light);
    font-size: 0.85rem;
}

.inquiry-contact {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.6;
}

.inquiry-detail-grid {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 8px 16px;
    font-size: 0.9rem;
    line-height: 1.8;
}

.inquiry-detail-grid dt {
    font-weight: 600;
    color: var(--text);
}

.inquiry-detail-grid dd {
    color: var(--text-light);
    word-break: break-all;
}

.inquiry-detail-msg {
    margin-top: 16px;
    padding: 16px;
    background: #f7f8fa;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.8;
    white-space: pre-wrap;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

.logout-btn:hover {
    background: rgba(220,53,69,0.2);
    color: #ff6b7a;
}

/* ============ Main Content ============ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 32px;
    height: 64px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
    color: var(--text);
}

.topbar h2 {
    font-size: 1.1rem;
    font-weight: 700;
    flex: 1;
    letter-spacing: 1px;
}

.admin-user {
    font-size: 0.85rem;
    color: var(--text-light);
    padding: 6px 14px;
    background: var(--primary-light);
    border-radius: 20px;
}

.content-area {
    padding: 24px 32px;
}

/* ============ Action Bar ============ */

.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.action-info {
    font-size: 0.85rem;
    color: var(--text-lighter);
}

/* ============ Buttons ============ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-light);
}

.btn-icon:hover {
    background: var(--primary-light);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-icon.danger:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

/* ============ Table ============ */

.table-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-lighter);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #fafbfc;
}

.table-title {
    font-weight: 600;
    color: var(--dark);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 12px;
}

.table-thumb {
    width: 64px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--bg);
}

.table-actions {
    display: flex;
    gap: 6px;
}

.featured-star {
    color: #f0ad4e;
    font-size: 1.1rem;
}

.featured-star.inactive {
    color: #ddd;
}

/* ============ Empty State ============ */

.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-lighter);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ============ Modal ============ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

.modal-sm {
    max-width: 420px;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-lighter);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-form {
    padding: 24px;
}

.modal-body-text {
    padding: 24px;
}

.unread-row {
    background: #f0f6ff;
}

.unread-row td {
    font-weight: 500;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-field {
    margin-bottom: 18px;
}

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

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,125,216,0.1);
}

.form-field small {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-lighter);
}

.form-field textarea {
    resize: vertical;
    min-height: 100px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* ============ Upload Area ============ */

.upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    background: #fafbfc;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent);
    background: var(--primary-light);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    color: var(--text-lighter);
    text-align: center;
}

.upload-placeholder svg {
    width: 32px;
    height: 32px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.upload-placeholder p {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.upload-placeholder small {
    font-size: 0.75rem;
    opacity: 0.6;
}

.upload-preview {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.upload-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.upload-remove:hover {
    background: var(--danger);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

/* ============ Responsive ============ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .topbar {
        padding: 0 16px;
    }

    .content-area {
        padding: 16px;
    }

    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        display: none;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}
