/* 全域設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* 統一根節點背景 */
html, body {
    background: #0b1220;
    height: 100%;
}

/* 背景動畫 */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.floating-shapes {
    position: relative;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, rgba(0, 255, 255, 0.1), rgba(0, 150, 255, 0.1));
    animation: float 6s ease-in-out infinite;
}

.shape-1 {
    width: 80px;
    height: 80px;
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 120px;
    height: 120px;
    top: 60%;
    right: 15%;
    animation-delay: 2s;
}

.shape-3 {
    width: 60px;
    height: 60px;
    top: 80%;
    left: 20%;
    animation-delay: 4s;
}

.shape-4 {
    width: 100px;
    height: 100px;
    top: 30%;
    right: 30%;
    animation-delay: 1s;
}

.shape-5 {
    width: 70px;
    height: 70px;
    top: 70%;
    left: 60%;
    animation-delay: 3s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
        opacity: 1;
    }
}

/* 登入卡片 */
.login-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 3rem 2.5rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #00ffff, #0096ff, #00ffff);
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 系統標題 */
.system-logo {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container {
    position: relative;
    display: inline-block;
}

.logo-icon {
    font-size: 4rem;
    color: #00ffff;
    background: linear-gradient(135deg, #00ffff, #0099ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logoFloat 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.logo-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 50%;
    animation: pulseRing 2s ease-in-out infinite;
}

.logo-pulse::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border: 1px solid rgba(0, 153, 255, 0.2);
    border-radius: 50%;
    animation: pulseRing 2s ease-in-out infinite 0.5s;
}

@keyframes logoFloat {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg);
    }
    50% { 
        transform: translateY(-5px) rotate(2deg);
    }
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0;
    }
}

.system-title {
    color: #ffffff;
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.system-subtitle {
    color: #b0b0b0;
    font-size: 1.1rem;
    font-weight: 300;
}

/* 表單樣式 */
.form-label {
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.form-control {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 12px;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #00ffff;
    box-shadow: 0 0 0 0.2rem rgba(0, 255, 255, 0.25);
    color: #ffffff;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.form-control.is-invalid {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 0.2rem rgba(255, 107, 107, 0.25);
}

/* 密碼輸入群組 */
.password-input-group {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #b0b0b0;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.password-toggle:hover {
    color: #00ffff;
    background: rgba(0, 255, 255, 0.1);
}

/* 記住我選項 */
.form-check-input {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.form-check-input:checked {
    background-color: #00ffff;
    border-color: #00ffff;
}

.form-check-label {
    color: #ffffff;
    font-weight: 400;
}

/* 登入按鈕 */
.login-btn {
    background: linear-gradient(45deg, #00ffff, #0096ff);
    border: none;
    border-radius: 12px;
    padding: 0.875rem 2rem;
    font-weight: 600;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-btn:hover {
    background: linear-gradient(45deg, #0096ff, #00ffff);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 255, 255, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* 提示訊息 */
.alert {
    background: rgba(0, 150, 255, 0.1);
    border: 1px solid rgba(0, 150, 255, 0.3);
    color: #b0d4ff;
    border-radius: 12px;
    font-size: 0.9rem;
}

/* 載入動畫 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
    color: #ffffff;
}

.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* 桌面端容器邊距 - 調整最小高度而非 100vh */
@media (min-width: 769px) {
    .container-fluid.vh-100 {
        min-height: calc(100vh - 4rem) !important;
        height: auto !important;
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    body, html {
        background: #0b1220 !important;
    }
    
    .login-card {
        padding: 2rem 1.5rem;
        margin: 1rem;
        margin-top: 2rem;
    }
    
    .system-title {
        font-size: 1.5rem;
    }
    
    .system-subtitle {
        font-size: 1rem;
    }
    
    .logo-icon {
        font-size: 3rem;
    }
    
    .logo-pulse {
        width: 60px;
        height: 60px;
    }
    
    .container-fluid {
        padding-top: 1rem;
    }
}

@media (max-width: 576px) {
    body, html {
        background: #0b1220 !important;
    }
    
    .login-card {
        padding: 1.5rem 1rem;
        margin-top: 1rem;
    }
    
    .system-title {
        font-size: 1.25rem;
    }
    
    .system-subtitle {
        font-size: 0.9rem;
    }
    
    .logo-icon {
        font-size: 2.5rem;
    }
    
    .logo-pulse {
        width: 50px;
        height: 50px;
    }
    
    .form-control {
        font-size: 0.9rem;
    }
    
    .login-btn {
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }
    
    .container-fluid {
        padding-top: 0.5rem;
    }
    
    .feature-card {
        padding: 1rem;
    }
    
    .feature-icon {
        font-size: 2rem;
    }
}

/* 動畫效果 */
.login-card {
    animation: slideInUp 0.8s ease-out;
}

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

/* 輸入框焦點效果 */
.form-control:focus {
    animation: glow 0.3s ease;
}

@keyframes glow {
    0% { box-shadow: 0 0 0 0.2rem rgba(0, 255, 255, 0.25); }
    50% { box-shadow: 0 0 0 0.4rem rgba(0, 255, 255, 0.4); }
    100% { box-shadow: 0 0 0 0.2rem rgba(0, 255, 255, 0.25); }
}

/* 按鈕載入狀態 */
.login-btn.loading .btn-text {
    opacity: 0;
}

.login-btn.loading .spinner-border {
    display: inline-block !important;
}

/* 成功/錯誤狀態 */
.form-control.is-valid {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 0.2rem rgba(0, 255, 255, 0.25);
    background-image: none !important;
}

/* 移除所有輸入框的驗證圖示 */
.form-control.is-valid,
.form-control.is-invalid {
    background-image: none !important;
    background-repeat: no-repeat !important;
    background-position: right calc(0.375em + 0.1875rem) center !important;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem) !important;
}

.alert-danger {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.3);
    color: #ffb3b3;
}

.alert-success {
    background: rgba(0, 255, 136, 0.1);
    border-color: rgba(0, 255, 136, 0.3);
    color: #b3ffd9;
}

/* 測試模式下拉框樣式 */
#testRole {
    background: rgba(255, 193, 7, 0.1);
    border: 2px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    font-weight: 500;
}

#testRole:focus {
    background: rgba(255, 193, 7, 0.15);
    border-color: #ffc107;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

#testRole option {
    background: #1a1a2e;
    color: #ffffff;
}

/* 測試模式標籤 */
label[for="testRole"] {
    color: #ffc107 !important;
    font-weight: 600;
}

/* 測試模式容器 */
.mb-4:has(#testRole) {
    background: rgba(255, 193, 7, 0.05);
    border: 1px solid rgba(255, 193, 7, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem !important;
}

/* 儀表板功能卡片樣式 */
.feature-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.feature-card:hover {
    background: rgba(0, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.3);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 255, 255, 0.2);
}

.feature-icon {
    font-size: 2.5rem;
    color: #00ffff;
    margin-bottom: 1rem;
}

.feature-card h5 {
    color: #ffffff;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: #b0b0b0;
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* 使用者資訊樣式 */
.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.user-info .badge {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}

/* 按鈕樣式 */
.btn-outline-primary {
    border-color: rgba(0, 255, 255, 0.5);
    color: #00ffff;
}

.btn-outline-primary:hover {
    background-color: rgba(0, 255, 255, 0.1);
    border-color: #00ffff;
    color: #ffffff;
}

.btn-danger {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(45deg, #ff5252, #ff7979);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
}

/* 自定義滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #00ffff, #0080ff);
    border-radius: 4px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #00e6e6, #0066cc);
    transform: scale(1.1);
}

::-webkit-scrollbar-corner {
    background: rgba(255, 255, 255, 0.05);
}

/* Firefox 滾動條樣式 */
* {
    scrollbar-width: thin;
    scrollbar-color: #00ffff rgba(255, 255, 255, 0.05);
}

/* 手機端滾動條優化 */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}
