/* CSS 變數定義 */
:root {
    --primary-color: #ff9500;
    --success-color: #00c851;
    --danger-color: #ff4444;
    --warning-color: #ffbb33;
    --info-color: #33b5e5;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --border-color: #e9ecef;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 基礎樣式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 40px var(--shadow-color);
    overflow: hidden;
    width: 100%;
    max-width: 600px;
    animation: fadeInUp 0.6s ease-out;
}

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

/* 標題區域 */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #e67e22 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.aws-icon {
    font-size: 2.4rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
    max-width: 400px;
    margin: 0 auto;
}

/* 主內容 */
main {
    padding: 40px 30px;
}

.search-section {
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

#ip-input {
    flex: 1;
    padding: 16px 20px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: var(--transition);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

#ip-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.1);
}

#ip-input.error {
    border-color: var(--danger-color);
}

#search-btn {
    padding: 16px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#search-btn:hover:not(:disabled) {
    background: #e67e22;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 149, 0, 0.3);
}

#search-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.input-help {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

/* 載入動畫 */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 結果區域 */
.result-section {
    animation: slideIn 0.4s ease-out;
}

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

.result-card {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 24px;
    background: var(--light-color);
}

.result-card.success {
    border-color: var(--success-color);
    background: rgba(0, 200, 81, 0.05);
}

.result-card.danger {
    border-color: var(--danger-color);
    background: rgba(255, 68, 68, 0.05);
}

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

.result-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-icon {
    font-size: 1.5rem;
}

.result-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.result-ip {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 1rem;
    background: white;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.result-details {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.label {
    font-weight: 500;
    color: var(--text-secondary);
}

.value {
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* 錯誤區域 */
.error-section {
    animation: slideIn 0.4s ease-out;
}

.error-card {
    border: 2px solid var(--danger-color);
    border-radius: var(--border-radius-sm);
    padding: 30px;
    text-align: center;
    background: rgba(255, 68, 68, 0.05);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.error-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--danger-color);
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.retry-btn {
    padding: 12px 24px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: #cc0000;
    transform: translateY(-1px);
}

/* 頁腳 */
footer {
    background: var(--light-color);
    padding: 30px;
    border-top: 1px solid var(--border-color);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.footer-info {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.footer-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 4px 0;
}

.footer-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.footer-info a:hover {
    text-decoration: underline;
}

/* 響應式設計 */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .container {
        max-width: 100%;
    }
    
    header {
        padding: 30px 20px;
    }
    
    h1 {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 8px;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    main {
        padding: 30px 20px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    #search-btn {
        width: 100%;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    footer {
        padding: 25px 20px;
    }
    
    .stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }
    
    .aws-icon {
        font-size: 2rem;
    }
    
    #ip-input {
        font-size: 16px; /* 防止 iOS Safari 縮放 */
    }
}