/* ===== 基礎樣式 - 全站共用 ===== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== 導航列 ===== */
.header {
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 0;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: #667eea;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* 用戶名稱徽章 */
.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.75rem;
    padding: 0 0.75rem;
    background: rgba(102, 126, 234, 0.15);
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(102, 126, 234, 0.3);
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    color: #667eea;
    margin-left: 0.5rem;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    transition: all 0.3s ease;
    animation: badge-appear 0.5s ease;
    vertical-align: middle;
}

.nav-link:hover .user-badge {
    transform: scale(1.1);
    background: rgba(102, 126, 234, 0.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

/* 訊息通知樣式 */
.nav-messages {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    position: relative;
}

.message-icon {
    font-size: 1.125rem;
}

.message-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    background: #ef4444;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.nav-link:hover .message-badge {
    animation: none;
    transform: scale(1.15);
}

@keyframes badge-appear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== 下拉選單樣式 ===== */
.nav-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0;
    padding-top: 0.5rem;
    background-color: transparent;
    list-style: none;
    min-width: 160px;
    z-index: 1000;
}

.dropdown-menu::before {
    content: '';
    display: block;
    height: 0.5rem;
}

.nav-dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    display: block;
}

.dropdown-menu li {
    background-color: #fff;
    animation: fadeInDown 0.3s ease;
}

.dropdown-menu li:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-menu li:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-menu li:only-child {
    border-radius: 8px;
}

.nav-dropdown:hover .dropdown-menu li {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.dropdown-link {
    display: block;
    padding: 0.75rem 1.25rem;
    color: #555;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.dropdown-link:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

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

/* ===== Hero 區域 (通用) ===== */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 80px 0;
    text-align: center;
}

.hero-header {
    animation: fadeInUp 0.8s ease;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.5rem;
    opacity: 0.95;
}

/* ===== 共用區塊標題 ===== */
.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #2d3748;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 1rem auto 0;
    border-radius: 2px;
}

/* ===== Footer ===== */
.footer {
    background-color: #2d3748;
    color: #fff;
    padding: 2.5rem 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-content p {
    opacity: 0.9;
    font-size: 1rem;
}

.footer-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    opacity: 0.7;
    font-size: 0.9rem;
}

.footer-info span {
    white-space: nowrap;
}

/* ===== 動畫效果 ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* ===== 響應式設計 (基礎) ===== */
@media (max-width: 768px) {
    .nav-menu {
        gap: 1rem;
        font-size: 0.9rem;
    }

    .hero {
        padding: 60px 0;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.2rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .footer-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-info span:nth-child(even) {
        display: none;
    }
}

@media (max-width: 480px) {
    .nav {
        flex-direction: column;
        gap: 1rem;
    }

    .hero {
        padding: 50px 0;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }
}

/* ===== Django Messages 訊息提示 ===== */
.messages-container-alerts {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
    width: 100%;
}

.alert {
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.4s ease-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
}

/* 成功訊息 */
.alert-success {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    border-left: 5px solid #16a34a;
}

/* 錯誤訊息 */
.alert-error {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: white;
    border-left: 5px solid #dc2626;
}

/* 警告訊息 */
.alert-warning {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    border-left: 5px solid #d97706;
}

/* 資訊訊息 */
.alert-info {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
    border-left: 5px solid #2563eb;
}

/* 動畫效果 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 自動消失動畫 */
@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.alert.fade-out {
    animation: fadeOut 0.4s ease-out forwards;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .messages-container-alerts {
        top: 70px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .alert {
        padding: 0.875rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* ===== Toast 通知樣式 ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    cursor: pointer;
    font-weight: 600;
    max-width: 350px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(102, 126, 234, 0.5);
}

.notification-toast {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.6);
    }
}

/* Toast 響應式 */
@media (max-width: 768px) {
    .toast-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        max-width: none;
        padding: 0.875rem 1.25rem;
    }
}

/* ===== 通知徽章樣式 ===== */
.notification-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0 0 0 0.5rem;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-sizing: border-box;
    top: 1px;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}


/* ===== 漢堡選單樣式 ===== */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger {
    width: 30px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* 漢堡選單動畫 - 變成 X */
.nav-toggle.active .hamburger:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}

.nav-toggle.active .hamburger:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active .hamburger:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}


/* ===== 響應式導航 ===== */
@media (max-width: 768px) {
    .nav {
        position: relative;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: white;
        flex-direction: column;
        padding: 80px 2rem 2rem;
        gap: 0;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        overflow-y: auto;
        z-index: 1001;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-menu > li {
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-menu > li:last-child {
        border-bottom: none;
    }

    .nav-link {
        display: block;
        padding: 1rem 0;
        font-size: 1rem;
    }

    /* 下拉選單在手機版的樣式 */
    .nav-dropdown {
        position: relative;
    }

    .nav-dropdown .nav-link {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* 只有帶下拉箭頭的項目才使用 space-between */
    .nav-dropdown .nav-link::after {
        margin-left: auto;
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: #f8f9fa;
        padding: 0.5rem 0;
        margin: 0;
        border-radius: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .nav-dropdown:hover .dropdown-menu,
    .nav-dropdown .dropdown-menu {
        max-height: 0;
    }

    .nav-dropdown.active .dropdown-menu {
        max-height: 500px;
    }

    .dropdown-link {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* 訊息和通知徽章 */
    .message-badge,
    .notification-badge {
        position: static;
        margin-left: 0.5rem;
    }

    /* 用戶名徽章 */
    .user-badge {
        display: inline-flex;
        margin-left: 0.5rem;
        padding: 0.35rem 0.875rem;
        font-size: 0.875rem;
        min-width: auto;
        height: auto;
    }
}

/* 遮罩層（可選） */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 平板尺寸優化 */
@media (max-width: 1024px) and (min-width: 769px) {
    .nav-menu {
        gap: 1.5rem;
        font-size: 0.95rem;
    }

    .dropdown-menu {
        min-width: 180px;
    }
}

/* 小手機優化 */
@media (max-width: 480px) {
    .nav-menu {
        width: 100%;
        right: -100%;
        padding: 70px 1.5rem 1.5rem;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-link {
        padding: 0.875rem 0;
    }

    .logo {
        font-size: 1.5rem;
    }
}
/* 遮罩層已移除 - 避免遮擋選單內容 */
@media (max-width: 768px) {
    /* 確保漢堡按鈕在最上層 */
    .nav-toggle {
        z-index: 1002;
    }
}
