/* ===== 全域樣式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--dark-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 標題列 ===== */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    margin: 1rem 0;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 2rem;
    color: var(--warning-color);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--warning-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.wallet-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ===== 按鈕樣式 ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

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

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--secondary-color);
    border-radius: 4px;
    transition: all 0.2s ease;
}

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

/* ===== 主要內容 ===== */
.main-content {
    flex: 1;
    padding: 1rem 0;
}

/* ===== 歡迎區域 ===== */
.welcome-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.welcome-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 600px;
}

.welcome-card h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--warning-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-card p {
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: 2rem;
}

.features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.feature i {
    font-size: 2rem;
    color: var(--primary-color);
}

.feature span {
    font-weight: 600;
    color: var(--dark-color);
}

/* ===== 儀表板區域 ===== */
.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ===== 網路資訊 ===== */
.network-info {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.network-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--success-color);
    color: white;
    border-radius: 20px;
    font-weight: 600;
}

.contract-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.contract-info code {
    background: var(--light-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
}

/* ===== 卡片樣式 ===== */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
}

.card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.card h3 i {
    color: var(--primary-color);
}

/* ===== 用戶資訊卡片 ===== */
.user-info-card .user-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--light-color);
    border-radius: var(--border-radius);
}

.detail-item .label {
    font-weight: 600;
    color: var(--secondary-color);
}

.detail-item .value {
    font-weight: 700;
    color: var(--dark-color);
}

/* ===== 操作網格 ===== */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.action-card {
    border-left: 4px solid var(--primary-color);
}

.action-card p {
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
}

/* ===== 能量方案卡片 ===== */
.energy-plans-card {
    width: 100%;
}

.plan-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    color: var(--secondary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--light-color);
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.plan-card {
    background: var(--light-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.plan-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.plan-card.popular {
    border-color: var(--warning-color);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
}

.plan-card.popular::before {
    content: '🔥 熱門';
    position: absolute;
    top: -10px;
    right: 15px;
    background: var(--warning-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.plan-header {
    text-align: center;
    margin-bottom: 1rem;
}

.plan-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.plan-price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.plan-price .currency {
    font-size: 1rem;
    color: var(--secondary-color);
}

.plan-description {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.plan-features {
    list-style: none;
    margin: 1.5rem 0;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--dark-color);
}

.plan-features li i {
    color: var(--success-color);
    font-size: 0.9rem;
}

.plan-select-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: var(--border-radius);
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.plan-select-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.plan-select-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
}

/* ===== 自訂能量方案 ===== */
.plan-card.custom-plan {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.05));
}

.custom-energy-input {
    margin: 1rem 0;
}

.custom-energy-input label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.custom-energy-input .energy-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.custom-energy-input .energy-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.custom-energy-input .input-hint {
    display: block;
    margin-top: 0.5rem;
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.custom-price {
    font-size: 2rem;
    font-weight: bold;
    color: #8b5cf6;
}

/* ===== 授權狀態 ===== */
.approval-status {
    background: var(--light-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
}

.approval-status.approved {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.approval-status.not-approved {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.approval-status p {
    margin: 0;
    font-weight: 600;
}

.approval-status .status-icon {
    margin-right: 0.5rem;
}

/* ===== 輸入組 ===== */

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark-color);
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.cost-estimate {
    background: var(--light-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    text-align: center;
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.card-footer small {
    color: var(--secondary-color);
}

/* ===== 交易記錄 ===== */
.transaction-list {
    max-height: 400px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.transaction-item:hover {
    background: var(--light-color);
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-details {
    flex: 1;
}

.transaction-hash {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.transaction-status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.status-failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.no-transactions {
    text-align: center;
    color: var(--secondary-color);
    padding: 2rem;
}

/* ===== 頁尾 ===== */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin-top: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    padding: 2rem;
}

.footer-section h4 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section ul li a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--secondary-color);
}

/* ===== 載入覆蓋層 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* ===== 通知 ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    transform: translateX(500px);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: var(--success-color);
    color: white;
}

.notification.error {
    background: var(--danger-color);
    color: white;
}

.notification.warning {
    background: var(--warning-color);
    color: white;
}

.notification.info {
    background: var(--primary-color);
    color: white;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    .header {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
    }
    
    .welcome-card {
        padding: 2rem 1rem;
    }
    
    .welcome-card h2 {
        font-size: 2rem;
    }
    
    .features {
        gap: 1rem;
    }
    
    .action-grid {
        grid-template-columns: 1fr;
    }
    
    .network-info {
        flex-direction: column;
        text-align: center;
    }
    
    .user-details {
        grid-template-columns: 1fr;
    }
    
    .detail-item {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 1rem;
    }
    
    .welcome-card {
        padding: 1.5rem 1rem;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== 管理員面板樣式 ===== */
.admin-panel {
    border: 2px solid var(--warning-color);
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.admin-panel .card-header {
    background: var(--warning-color);
    color: white;
    padding: 1rem;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-role {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.875rem;
    font-weight: 500;
}

.admin-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.admin-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.admin-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.info-item label {
    font-weight: 600;
    color: var(--text-color);
}

.address-display {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    background: var(--secondary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-function {
    margin-bottom: 1.5rem;
}

.admin-function label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.admin-function .input-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: stretch;
}

.admin-function .input-group input,
.admin-function .input-group textarea {
    flex: 1;
    min-width: 150px;
}

.address-input {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.admin-function textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* 租用歷史樣式 */
.rental-history {
    margin-top: 1rem;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: var(--light-bg);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.history-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-item-title {
    font-weight: 600;
    color: var(--primary-color);
}

.history-item-status {
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
}

.history-item-status.active {
    background: var(--success-color);
    color: white;
}

.history-item-status.expired {
    background: var(--danger-color);
    color: white;
}

.history-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    font-size: 0.875rem;
}

.history-detail {
    display: flex;
    justify-content: space-between;
}

.history-detail-label {
    color: #666;
}

.history-detail-value {
    font-weight: 500;
    color: var(--text-color);
}

/* 批量查詢結果樣式 */
.batch-results {
    margin-top: 1rem;
}

.results-list {
    max-height: 300px;
    overflow-y: auto;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--light-bg);
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.result-address {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--secondary-color);
    flex: 1;
    margin-right: 1rem;
}

.result-balance {
    font-weight: 600;
    color: var(--success-color);
}

/* 權限指示器 */
.admin-role.owner {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
}

.admin-role.provider {
    background: linear-gradient(45deg, #4caf50, #66bb6a);
    color: white;
}

.admin-role.both {
    background: linear-gradient(45deg, #ff9800, #ffb74d);
    color: white;
}

/* ===== 動畫 ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.6s ease forwards;
}

/* ===== 滾動條樣式 ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-color);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ===== 已授權用戶列表樣式 ===== */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.user-card {
    background: var(--light-bg);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.user-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.user-address {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--secondary-color);
    font-weight: 600;
    word-break: break-all;
}

.user-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.user-status.authorized {
    background: var(--success-color);
    color: white;
}

.user-status.pending {
    background: #f59e0b;  /* 黃色 - 警告色 */
    color: white;
}

.user-status.revoked {
    background: var(--danger-color);
    color: white;
}

.user-card-body {
    font-size: 0.875rem;
}

.user-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px dashed #e0e0e0;
}

.user-detail:last-child {
    border-bottom: none;
}

.user-detail-label {
    color: #666;
}

.user-detail-value {
    font-weight: 500;
    color: var(--text-color);
}

.user-detail-value.highlight {
    color: var(--primary-color);
    font-weight: 600;
}

.authorized-users-list {
    max-height: 600px;
    overflow-y: auto;
}

.badge {
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 500;
}
